Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: components/signin/core/browser/signin_header_helper.h

Issue 2918403009: [Dice] Parse the Dice response header (Closed)
Patch Set: Remove logout url Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
50 // Struct describing the paramters received in the manage account header. 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.
54 };
55
56 // Struct describing the parameters 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 parameters received in the Dice response header.
83 struct DiceResponseParams {
84 DiceResponseParams();
85 ~DiceResponseParams();
86 DiceResponseParams(const DiceResponseParams& other);
87
88 DiceAction user_intention;
89
90 // Gaia ID of the account signed in or signed out (which may be a secondary
91 // account). When |user_intention| is SIGNOUT, this is the ID of the primary
92 // account.
93 std::string obfuscated_gaia_id;
94
95 // Email of the account signed in or signed out. When |user_intention| is
96 // SIGNOUT, this is the email of the primary account.
97 std::string email;
98
99 // Session index for the account signed in or signed out. When
100 // |user_intention| is SIGNOUT, this is 0.
101 int session_index;
102
103 // Optional. Must be set when |user_intention| is SIGNIN.
104 std::string authorization_code;
105 };
106
76 // Base class for managing the signin headers (Dice and Chrome-Connected). 107 // Base class for managing the signin headers (Dice and Chrome-Connected).
77 class SigninHeaderHelper { 108 class SigninHeaderHelper {
78 public: 109 public:
79 // Appends or remove the header to a network request if necessary. 110 // Appends or remove the header to a network request if necessary.
80 bool AppendOrRemoveRequestHeader( 111 bool AppendOrRemoveRequestHeader(
81 net::URLRequest* request, 112 net::URLRequest* request,
82 const char* header_name, 113 const char* header_name,
83 const GURL& redirect_url, 114 const GURL& redirect_url,
84 const std::string& account_id, 115 const std::string& account_id,
85 const content_settings::CookieSettings* cookie_settings, 116 const content_settings::CookieSettings* cookie_settings,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 net::URLRequest* request, 170 net::URLRequest* request,
140 const GURL& redirect_url, 171 const GURL& redirect_url,
141 const std::string& account_id, 172 const std::string& account_id,
142 const content_settings::CookieSettings* cookie_settings, 173 const content_settings::CookieSettings* cookie_settings,
143 int profile_mode_mask); 174 int profile_mode_mask);
144 175
145 // Returns the parameters contained in the X-Chrome-Manage-Accounts response 176 // Returns the parameters contained in the X-Chrome-Manage-Accounts response
146 // header. 177 // header.
147 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value); 178 ManageAccountsParams BuildManageAccountsParams(const std::string& header_value);
148 179
180 #if !defined(OS_IOS) && !defined(OS_ANDROID)
181 // Returns the parameters contained in the X-Chrome-ID-Consistency-Response
182 // response header.
183 // Returns DiceAction::NONE in case of error (such as missing or malformed
184 // parameters).
185 DiceResponseParams BuildDiceResponseParams(const std::string& header_value);
186 #endif
187
149 } // namespace signin 188 } // namespace signin
150 189
151 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_ 190 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_HEADER_HELPER_H_
OLDNEW
« no previous file with comments | « components/signin/core/browser/dice_header_helper.cc ('k') | components/signin/core/browser/signin_header_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698