1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_
#define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_
#include <string>
#include "build/build_config.h" // For OS_IOS
namespace content_settings {
class CookieSettings;
}
namespace net {
class URLRequest;
}
class GURL;
namespace signin {
// Profile mode flags.
enum ProfileMode {
PROFILE_MODE_DEFAULT = 0,
// Incognito mode disabled by enterprise policy or by parental controls.
PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0,
// Adding account disabled in the Android-for-EDU mode.
PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1
};
// The ServiceType specified by GAIA in the response header accompanying the 204
// response. This indicates the action Chrome is supposed to lead the user to
// perform.
enum GAIAServiceType {
GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header.
GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions.
GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab.
GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account.
GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account.
GAIA_SERVICE_TYPE_SIGNUP, // Create a new account.
GAIA_SERVICE_TYPE_DEFAULT, // All other cases.
};
// Struct describing the paramters received in the manage account header.
struct ManageAccountsParams {
// The requested service type such as "ADDSESSION".
GAIAServiceType service_type;
// The prefilled email.
std::string email;
// Whether |email| is a saml account.
bool is_saml;
// The continue URL after the requested service is completed successfully.
// Defaults to the current URL if empty.
std::string continue_url;
// Whether the continue URL should be loaded in the same tab.
bool is_same_tab;
// iOS has no notion of route and child IDs.
#if !defined(OS_IOS)
// The child id associated with the web content of the request.
int child_id;
// The route id associated with the web content of the request.
int route_id;
#endif // !defined(OS_IOS)
ManageAccountsParams();
ManageAccountsParams(const ManageAccountsParams& other);
};
// Returns true if signin cookies are allowed.
bool SettingsAllowSigninCookies(
const content_settings::CookieSettings* cookie_settings);
// Returns the X-CHROME-CONNECTED cookie, or an empty string if it should not be
// added to the request to |url|.
std::string BuildMirrorRequestCookieIfPossible(
const GURL& url,
const std::string& account_id,
const content_settings::CookieSettings* cookie_settings,
int profile_mode_mask);
// Adds X-Chrome-Connected header to all Gaia requests from a connected profile,
// with the exception of requests from gaia webview.
// Returns true if the account management header was added to the request.
bool AppendMirrorRequestHeaderIfPossible(
net::URLRequest* request,
const GURL& redirect_url,
const std::string& account_id,
const content_settings::CookieSettings* cookie_settings,
int profile_mode_mask);
// Returns the parameters contained in the X-Chrome-Manage-Accounts response
// header.
ManageAccountsParams BuildManageAccountsParams(const std::string& header_value);
// Returns the parameters contained in the X-Chrome-Manage-Accounts response
// header.
// If the request does not have a response header or if the header contains
// garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|.
ManageAccountsParams BuildManageAccountsParamsIfExists(net::URLRequest* request,
bool is_off_the_record);
} // namespace signin
#endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_
|