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