OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" // For OS_IOS | 10 #include "build/build_config.h" // For OS_IOS |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // Profile mode flags. | 24 // Profile mode flags. |
25 enum ProfileMode { | 25 enum ProfileMode { |
26 PROFILE_MODE_DEFAULT = 0, | 26 PROFILE_MODE_DEFAULT = 0, |
27 // Incognito mode disabled by enterprise policy or by parental controls. | 27 // Incognito mode disabled by enterprise policy or by parental controls. |
28 PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0, | 28 PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0, |
29 // Adding account disabled in the Android-for-EDU mode. | 29 // Adding account disabled in the Android-for-EDU mode. |
30 PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1 | 30 PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1 |
31 }; | 31 }; |
32 | 32 |
| 33 extern const char kChromeConnectedHeader[]; |
| 34 |
33 // The ServiceType specified by GAIA in the response header accompanying the 204 | 35 // 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 // response. This indicates the action Chrome is supposed to lead the user to |
35 // perform. | 37 // perform. |
36 enum GAIAServiceType { | 38 enum GAIAServiceType { |
37 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. | 39 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. |
38 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. | 40 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. |
39 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. | 41 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. |
40 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. | 42 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. |
41 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. | 43 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. |
42 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. | 44 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. |
(...skipping 23 matching lines...) Expand all Loading... |
66 #endif // !defined(OS_IOS) | 68 #endif // !defined(OS_IOS) |
67 | 69 |
68 ManageAccountsParams(); | 70 ManageAccountsParams(); |
69 ManageAccountsParams(const ManageAccountsParams& other); | 71 ManageAccountsParams(const ManageAccountsParams& other); |
70 }; | 72 }; |
71 | 73 |
72 // Returns true if signin cookies are allowed. | 74 // Returns true if signin cookies are allowed. |
73 bool SettingsAllowSigninCookies( | 75 bool SettingsAllowSigninCookies( |
74 const content_settings::CookieSettings* cookie_settings); | 76 const content_settings::CookieSettings* cookie_settings); |
75 | 77 |
| 78 // Checks if the url has the required properties to have an |
| 79 // X-CHROME-CONNECTED header. |
| 80 bool IsUrlEligibleForXChromeConnectedHeader(const GURL& url); |
| 81 |
76 // Returns the X-CHROME-CONNECTED cookie, or an empty string if it should not be | 82 // Returns the X-CHROME-CONNECTED cookie, or an empty string if it should not be |
77 // added to the request to |url|. | 83 // added to the request to |url|. |
78 std::string BuildMirrorRequestCookieIfPossible( | 84 std::string BuildMirrorRequestCookieIfPossible( |
79 const GURL& url, | 85 const GURL& url, |
80 const std::string& account_id, | 86 const std::string& account_id, |
81 const content_settings::CookieSettings* cookie_settings, | 87 const content_settings::CookieSettings* cookie_settings, |
82 int profile_mode_mask); | 88 int profile_mode_mask); |
83 | 89 |
84 // Adds X-Chrome-Connected header to all Gaia requests from a connected profile, | 90 // Adds X-Chrome-Connected header to all Gaia requests from a connected profile, |
85 // with the exception of requests from gaia webview. | 91 // with the exception of requests from gaia webview. |
86 // Returns true if the account management header was added to the request. | 92 // Removes the header in case it should not be transfered to a redirected url. |
87 bool AppendMirrorRequestHeaderIfPossible( | 93 bool AppendOrRemoveMirrorRequestHeaderIfPossible( |
88 net::URLRequest* request, | 94 net::URLRequest* request, |
89 const GURL& redirect_url, | 95 const GURL& redirect_url, |
90 const std::string& account_id, | 96 const std::string& account_id, |
91 const content_settings::CookieSettings* cookie_settings, | 97 const content_settings::CookieSettings* cookie_settings, |
92 int profile_mode_mask); | 98 int profile_mode_mask); |
93 | 99 |
94 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | 100 // Returns the parameters contained in the X-Chrome-Manage-Accounts response |
95 // header. | 101 // header. |
96 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); | 102 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); |
97 | 103 |
98 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | 104 // Returns the parameters contained in the X-Chrome-Manage-Accounts response |
99 // header. | 105 // header. |
100 // If the request does not have a response header or if the header contains | 106 // If the request does not have a response header or if the header contains |
101 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. | 107 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. |
102 ManageAccountsParams BuildManageAccountsParamsIfExists(net::URLRequest* request, | 108 ManageAccountsParams BuildManageAccountsParamsIfExists(net::URLRequest* request, |
103 bool is_off_the_record); | 109 bool is_off_the_record); |
104 | 110 |
105 } // namespace signin | 111 } // namespace signin |
106 | 112 |
107 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ | 113 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ |
OLD | NEW |