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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "url/gurl.h" | |
| 12 | 13 |
| 13 namespace content_settings { | 14 namespace content_settings { |
| 14 class CookieSettings; | 15 class CookieSettings; |
| 15 } | 16 } |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 class URLRequest; | 19 class URLRequest; |
| 19 } | 20 } |
| 20 | 21 |
| 21 class GURL; | |
| 22 | |
| 23 namespace signin { | 22 namespace signin { |
| 24 | 23 |
| 25 // Profile mode flags. | 24 // Profile mode flags. |
| 26 enum ProfileMode { | 25 enum ProfileMode { |
| 27 PROFILE_MODE_DEFAULT = 0, | 26 PROFILE_MODE_DEFAULT = 0, |
| 28 // Incognito mode disabled by enterprise policy or by parental controls. | 27 // Incognito mode disabled by enterprise policy or by parental controls. |
| 29 PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0, | 28 PROFILE_MODE_INCOGNITO_DISABLED = 1 << 0, |
| 30 // Adding account disabled in the Android-for-EDU mode. | 29 // Adding account disabled in the Android-for-EDU mode. |
| 31 PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1 | 30 PROFILE_MODE_ADD_ACCOUNT_DISABLED = 1 << 1 |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 extern const char kChromeConnectedHeader[]; | 33 extern const char kChromeConnectedHeader[]; |
| 35 extern const char kDiceRequestHeader[]; | 34 extern const char kDiceRequestHeader[]; |
| 36 | 35 |
| 37 // The ServiceType specified by Gaia in the response header accompanying the 204 | 36 // The ServiceType specified by Gaia in the response header accompanying the 204 |
| 38 // response. This indicates the action Chrome is supposed to lead the user to | 37 // response. This indicates the action Chrome is supposed to lead the user to |
| 39 // perform. | 38 // perform. |
| 40 enum GAIAServiceType { | 39 enum GAIAServiceType { |
| 41 GAIA_SERVICE_TYPE_NONE = 0, // No Gaia response header. | 40 GAIA_SERVICE_TYPE_NONE = 0, // No Gaia response header. |
| 42 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. | 41 GAIA_SERVICE_TYPE_SIGNOUT, // Logout all existing sessions. |
| 43 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. | 42 GAIA_SERVICE_TYPE_INCOGNITO, // Open an incognito tab. |
| 44 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. | 43 GAIA_SERVICE_TYPE_ADDSESSION, // Add a secondary account. |
| 45 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. | 44 GAIA_SERVICE_TYPE_REAUTH, // Re-authenticate an account. |
| 46 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. | 45 GAIA_SERVICE_TYPE_SIGNUP, // Create a new account. |
| 47 GAIA_SERVICE_TYPE_DEFAULT, // All other cases. | 46 GAIA_SERVICE_TYPE_DEFAULT, // All other cases. |
| 48 }; | 47 }; |
| 49 | 48 |
| 49 enum class DiceAction { | |
| 50 NONE, | |
| 51 SIGNIN, // Sign in an account. | |
| 52 SIGNOUT, // Sign out of all sessions. | |
| 53 SINGLE_SESSION_SIGNOUT // Sign out of a single session. | |
|
msarda
2017/06/12 11:52:21
I think I would not implement the single sign-out
droger
2017/06/12 12:39:14
Currently, all I'm doing is parsing the header. No
msarda
2017/06/12 14:03:42
That's why I thought. But I do not have a strong p
| |
| 54 }; | |
| 55 | |
| 50 // Struct describing the paramters received in the manage account header. | 56 // Struct describing the paramters received in the manage account header. |
| 51 struct ManageAccountsParams { | 57 struct ManageAccountsParams { |
| 52 // The requested service type such as "ADDSESSION". | 58 // The requested service type such as "ADDSESSION". |
| 53 GAIAServiceType service_type; | 59 GAIAServiceType service_type; |
| 54 // The prefilled email. | 60 // The prefilled email. |
| 55 std::string email; | 61 std::string email; |
| 56 // Whether |email| is a saml account. | 62 // Whether |email| is a saml account. |
| 57 bool is_saml; | 63 bool is_saml; |
| 58 // The continue URL after the requested service is completed successfully. | 64 // The continue URL after the requested service is completed successfully. |
| 59 // Defaults to the current URL if empty. | 65 // Defaults to the current URL if empty. |
| 60 std::string continue_url; | 66 std::string continue_url; |
| 61 // Whether the continue URL should be loaded in the same tab. | 67 // Whether the continue URL should be loaded in the same tab. |
| 62 bool is_same_tab; | 68 bool is_same_tab; |
| 63 | 69 |
| 64 // iOS has no notion of route and child IDs. | 70 // iOS has no notion of route and child IDs. |
| 65 #if !defined(OS_IOS) | 71 #if !defined(OS_IOS) |
| 66 // The child ID associated with the web content of the request. | 72 // The child ID associated with the web content of the request. |
| 67 int child_id; | 73 int child_id; |
| 68 // The route ID associated with the web content of the request. | 74 // The route ID associated with the web content of the request. |
| 69 int route_id; | 75 int route_id; |
| 70 #endif // !defined(OS_IOS) | 76 #endif // !defined(OS_IOS) |
| 71 | 77 |
| 72 ManageAccountsParams(); | 78 ManageAccountsParams(); |
| 73 ManageAccountsParams(const ManageAccountsParams& other); | 79 ManageAccountsParams(const ManageAccountsParams& other); |
| 74 }; | 80 }; |
| 75 | 81 |
| 82 // Struct describing the paramters received in the Dice response header. | |
|
msarda
2017/06/12 11:52:21
s/paramters/parameters
droger
2017/06/12 12:39:14
Done.
| |
| 83 struct DiceResponseParams { | |
| 84 DiceResponseParams(); | |
| 85 ~DiceResponseParams(); | |
| 86 DiceResponseParams(const DiceResponseParams& other); | |
| 87 | |
| 88 DiceAction user_intention; | |
| 89 | |
| 90 // ID of the account signed in or signed out. When |user_intention| is | |
| 91 // SIGNOUT, this is the ID of the primary account. | |
|
msarda
2017/06/12 11:52:21
"this is the Gaia ID of the account that was signe
droger
2017/06/12 12:39:14
Added the clarifications.
FYI: My comments were c
| |
| 92 std::string obfuscated_gaia_id; | |
| 93 | |
| 94 // Email of the account signed in or signed out. When |user_intention| is | |
| 95 // SIGNOUT, this is the email of the primary account. | |
| 96 std::string email; | |
| 97 | |
| 98 // Session index for the account signed in or signed out. When | |
| 99 // |user_intention| is SIGNOUT, this is 0. | |
| 100 std::string session_index; | |
|
droger
2017/06/09 14:51:07
I'm not quite sure what it is, but that should pro
msarda
2017/06/12 11:52:21
This is the index of the account in the Gaia authe
droger
2017/06/12 12:39:16
Done.
| |
| 101 | |
| 102 // Optional. | |
| 103 std::string authorization_code; | |
|
msarda
2017/06/12 11:52:21
This should be set when action is SIGNIN (otherwis
droger
2017/06/12 12:39:15
Done.
| |
| 104 | |
| 105 // Logout URL Chrome should call after revoking LSTs in sign out flow. | |
| 106 // Optional. | |
| 107 GURL logout_url; | |
|
msarda
2017/06/12 11:52:21
Should be set when action is SIGNOUT.
droger
2017/06/12 12:39:15
Done.
| |
| 108 }; | |
| 109 | |
| 76 // Base class for managing the signin headers (Dice and Chrome-Connected). | 110 // Base class for managing the signin headers (Dice and Chrome-Connected). |
| 77 class SigninHeaderHelper { | 111 class SigninHeaderHelper { |
| 78 public: | 112 public: |
| 79 // Appends or remove the header to a network request if necessary. | 113 // Appends or remove the header to a network request if necessary. |
| 80 bool AppendOrRemoveRequestHeader( | 114 bool AppendOrRemoveRequestHeader( |
| 81 net::URLRequest* request, | 115 net::URLRequest* request, |
| 82 const char* header_name, | 116 const char* header_name, |
| 83 const GURL& redirect_url, | 117 const GURL& redirect_url, |
| 84 const std::string& account_id, | 118 const std::string& account_id, |
| 85 const content_settings::CookieSettings* cookie_settings, | 119 const content_settings::CookieSettings* cookie_settings, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 net::URLRequest* request, | 173 net::URLRequest* request, |
| 140 const GURL& redirect_url, | 174 const GURL& redirect_url, |
| 141 const std::string& account_id, | 175 const std::string& account_id, |
| 142 const content_settings::CookieSettings* cookie_settings, | 176 const content_settings::CookieSettings* cookie_settings, |
| 143 int profile_mode_mask); | 177 int profile_mode_mask); |
| 144 | 178 |
| 145 // Returns the parameters contained in the X-Chrome-Manage-Accounts response | 179 // Returns the parameters contained in the X-Chrome-Manage-Accounts response |
| 146 // header. | 180 // header. |
| 147 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); | 181 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); |
| 148 | 182 |
| 183 #if !defined(OS_IOS) && !defined(OS_ANDROID) | |
| 184 // Returns the parameters contained in the X-Chrome-ID-Consistency-Response | |
| 185 // response header. | |
| 186 DiceResponseParams BuildDiceResponseParams(const std::string& header_value); | |
| 187 #endif | |
| 188 | |
| 149 } // namespace signin | 189 } // namespace signin |
| 150 | 190 |
| 151 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ | 191 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ |
| OLD | NEW |