Chromium Code Reviews| 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 | |
| 35 // The ServiceType specified by GAIA in the response header accompanying the 204 | 33 // The ServiceType specified by GAIA in the response header accompanying the 204 |
| 36 // response. This indicates the action Chrome is supposed to lead the user to | 34 // response. This indicates the action Chrome is supposed to lead the user to |
| 37 // perform. | 35 // perform. |
| 38 enum GAIAServiceType { | 36 enum GAIAServiceType { |
| 39 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. | 37 GAIA_SERVICE_TYPE_NONE = 0, // No GAIA response header. |
| 40 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. | 38 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. |
| 41 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. | 39 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. |
| 42 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. | 40 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. |
| 43 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. | 41 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. |
| 44 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. | 42 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 64 // The child id associated with the web content of the request. | 62 // The child id associated with the web content of the request. |
| 65 int child_id; | 63 int child_id; |
| 66 // The route id associated with the web content of the request. | 64 // The route id associated with the web content of the request. |
| 67 int route_id; | 65 int route_id; |
| 68 #endif // !defined(OS_IOS) | 66 #endif // !defined(OS_IOS) |
| 69 | 67 |
| 70 ManageAccountsParams(); | 68 ManageAccountsParams(); |
| 71 ManageAccountsParams(const ManageAccountsParams& other); | 69 ManageAccountsParams(const ManageAccountsParams& other); |
| 72 }; | 70 }; |
| 73 | 71 |
| 72 // Base class for managing the signin headers (Dice and Chrome-Connected). | |
| 73 class SigninHeaderHelper { | |
| 74 public: | |
| 75 // Appends or remove the header to a network request if necessary. | |
| 76 bool AppendOrRemoveRequestHeader( | |
| 77 net::URLRequest* request, | |
| 78 const char* header_name, | |
| 79 const GURL& redirect_url, | |
| 80 const std::string& account_id, | |
| 81 const content_settings::CookieSettings* cookie_settings, | |
| 82 int profile_mode_mask); | |
| 83 | |
| 84 protected: | |
| 85 // Returns the value of the request header, or empty if the header should not | |
| 86 // be added. Calls into BuildRequestHeader() which is customized by | |
| 87 // subclasses. | |
| 88 std::string BuildRequestHeaderIfPossible( | |
| 89 bool is_header_request, | |
| 90 const GURL& url, | |
| 91 const std::string& account_id, | |
| 92 const content_settings::CookieSettings* cookie_settings, | |
| 93 int profile_mode_mask); | |
| 94 | |
| 95 private: | |
| 96 // Returns whether the url is eligible for the request header. | |
| 97 virtual bool IsUrlEligibleForRequestHeader(const GURL& url) = 0; | |
| 98 | |
| 99 // Returns the value of the request header, or empty if the header should not | |
| 100 // be added. | |
| 101 // The request is assumed to be eligible. | |
| 102 virtual std::string BuildRequestHeader(bool is_header_request, | |
| 103 const GURL& url, | |
| 104 const std::string& account_id, | |
| 105 int profile_mode_mask) = 0; | |
| 106 }; | |
| 107 | |
| 74 // Returns true if signin cookies are allowed. | 108 // Returns true if signin cookies are allowed. |
| 75 bool SettingsAllowSigninCookies( | 109 bool SettingsAllowSigninCookies( |
| 76 const content_settings::CookieSettings* cookie_settings); | 110 const content_settings::CookieSettings* cookie_settings); |
| 77 | 111 |
|
msarda
2017/06/08 23:43:05
I think it would be good to continue to have the f
droger
2017/06/09 09:52:24
Done.
| |
| 78 // Returns the CHROME_CONNECTED cookie, or an empty string if it should not be | |
| 79 // added to the request to |url|. | |
| 80 std::string BuildMirrorRequestCookieIfPossible( | |
| 81 const GURL& url, | |
| 82 const std::string& account_id, | |
| 83 const content_settings::CookieSettings* cookie_settings, | |
| 84 int profile_mode_mask); | |
| 85 | |
| 86 // Adds account consistency header to all Gaia requests from a connected | 112 // Adds account consistency header to all Gaia requests from a connected |
| 87 // profile, with the exception of requests from gaia webview. | 113 // profile, with the exception of requests from gaia webview. |
| 88 // Removes the header in case it should not be transfered to a redirected url. | 114 // Removes the header in case it should not be transfered to a redirected url. |
| 89 bool AppendOrRemoveAccountConsistentyRequestHeader( | 115 void AppendOrRemoveAccountConsistentyRequestHeader( |
| 90 net::URLRequest* request, | 116 net::URLRequest* request, |
| 91 const GURL& redirect_url, | 117 const GURL& redirect_url, |
| 92 const std::string& account_id, | 118 const std::string& account_id, |
| 93 const content_settings::CookieSettings* cookie_settings, | 119 const content_settings::CookieSettings* cookie_settings, |
| 94 int profile_mode_mask); | 120 int profile_mode_mask); |
| 95 | 121 |
| 96 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | 122 // Returns the parameters contained in the X-Chrome-Manage-Accounts response |
| 97 // header. | 123 // header. |
| 98 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); | 124 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); |
| 99 | 125 |
| 100 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | 126 // Returns the parameters contained in the X-Chrome-Manage-Accounts response |
| 101 // header. | 127 // header. |
| 102 // If the request does not have a response header or if the header contains | 128 // If the request does not have a response header or if the header contains |
| 103 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. | 129 // garbage, then |service_type| is set to |GAIA_SERVICE_TYPE_NONE|. |
| 104 ManageAccountsParams BuildManageAccountsParamsIfExists(net::URLRequest* request, | 130 ManageAccountsParams BuildManageAccountsParamsIfExists(net::URLRequest* request, |
| 105 bool is_off_the_record); | 131 bool is_off_the_record); |
| 106 | 132 |
| 107 } // namespace signin | 133 } // namespace signin |
| 108 | 134 |
| 109 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ | 135 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ |
| OLD | NEW |