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

Side by Side Diff: chrome/common/net/gaia/gaia_auth_fetcher.h

Issue 7600003: Pre- and Auto-login should not log the user out of an already signed in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing review comments Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ 5 #ifndef CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_
6 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ 6 #define CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Start a request to get a particular key from user info. 64 // Start a request to get a particular key from user info.
65 // GaiaAuthConsumer will be called back on the same thread when 65 // GaiaAuthConsumer will be called back on the same thread when
66 // results come back. 66 // results come back.
67 // You can't make more than one request at a time. 67 // You can't make more than one request at a time.
68 void StartGetUserInfo(const std::string& lsid, 68 void StartGetUserInfo(const std::string& lsid,
69 const std::string& info_key); 69 const std::string& info_key);
70 70
71 // Start a TokenAuth request to pre-login the user with the given credentials. 71 // Start a TokenAuth request to pre-login the user with the given credentials.
72 void StartTokenAuth(const std::string& auth_token); 72 void StartTokenAuth(const std::string& auth_token);
73 73
74 // Start a MergeSession request to pre-login the user with the given
75 // credentials. Unlike TokenAuth above, MergeSession will not sign out any
76 // existing accounts.
77 void StartMergeSession(const std::string& auth_token);
78
74 // Implementation of URLFetcher::Delegate 79 // Implementation of URLFetcher::Delegate
75 virtual void OnURLFetchComplete(const URLFetcher* source, 80 virtual void OnURLFetchComplete(const URLFetcher* source,
76 const GURL& url, 81 const GURL& url,
77 const net::URLRequestStatus& status, 82 const net::URLRequestStatus& status,
78 int response_code, 83 int response_code,
79 const net::ResponseCookies& cookies, 84 const net::ResponseCookies& cookies,
80 const std::string& data); 85 const std::string& data);
81 86
82 // StartClientLogin been called && results not back yet? 87 // StartClientLogin been called && results not back yet?
83 bool HasPendingFetch(); 88 bool HasPendingFetch();
(...skipping 17 matching lines...) Expand all
101 // The format of the POST body for ClientLogin. 106 // The format of the POST body for ClientLogin.
102 static const char kClientLoginFormat[]; 107 static const char kClientLoginFormat[];
103 // The format of said POST body when CAPTCHA token & answer are specified. 108 // The format of said POST body when CAPTCHA token & answer are specified.
104 static const char kClientLoginCaptchaFormat[]; 109 static const char kClientLoginCaptchaFormat[];
105 // The format of the POST body for IssueAuthToken. 110 // The format of the POST body for IssueAuthToken.
106 static const char kIssueAuthTokenFormat[]; 111 static const char kIssueAuthTokenFormat[];
107 // The format of the POST body for GetUserInfo. 112 // The format of the POST body for GetUserInfo.
108 static const char kGetUserInfoFormat[]; 113 static const char kGetUserInfoFormat[];
109 // The format of the POST body for TokenAuth. 114 // The format of the POST body for TokenAuth.
110 static const char kTokenAuthFormat[]; 115 static const char kTokenAuthFormat[];
116 // The format of the POST body for MergeSession.
117 static const char kMergeSessionFormat[];
111 118
112 // Constants for parsing ClientLogin errors. 119 // Constants for parsing ClientLogin errors.
113 static const char kAccountDeletedError[]; 120 static const char kAccountDeletedError[];
114 static const char kAccountDeletedErrorCode[]; 121 static const char kAccountDeletedErrorCode[];
115 static const char kAccountDisabledError[]; 122 static const char kAccountDisabledError[];
116 static const char kAccountDisabledErrorCode[]; 123 static const char kAccountDisabledErrorCode[];
117 static const char kBadAuthenticationError[]; 124 static const char kBadAuthenticationError[];
118 static const char kBadAuthenticationErrorCode[]; 125 static const char kBadAuthenticationErrorCode[];
119 static const char kCaptchaError[]; 126 static const char kCaptchaError[];
120 static const char kCaptchaErrorCode[]; 127 static const char kCaptchaErrorCode[];
(...skipping 14 matching lines...) Expand all
135 int response_code); 142 int response_code);
136 143
137 void OnGetUserInfoFetched(const std::string& data, 144 void OnGetUserInfoFetched(const std::string& data,
138 const net::URLRequestStatus& status, 145 const net::URLRequestStatus& status,
139 int response_code); 146 int response_code);
140 147
141 void OnTokenAuthFetched(const std::string& data, 148 void OnTokenAuthFetched(const std::string& data,
142 const net::URLRequestStatus& status, 149 const net::URLRequestStatus& status,
143 int response_code); 150 int response_code);
144 151
152 void OnMergeSessionFetched(const std::string& data,
153 const net::URLRequestStatus& status,
154 int response_code);
155
145 // Tokenize the results of a ClientLogin fetch. 156 // Tokenize the results of a ClientLogin fetch.
146 static void ParseClientLoginResponse(const std::string& data, 157 static void ParseClientLoginResponse(const std::string& data,
147 std::string* sid, 158 std::string* sid,
148 std::string* lsid, 159 std::string* lsid,
149 std::string* token); 160 std::string* token);
150 161
151 static void ParseClientLoginFailure(const std::string& data, 162 static void ParseClientLoginFailure(const std::string& data,
152 std::string* error, 163 std::string* error,
153 std::string* error_url, 164 std::string* error_url,
154 std::string* captcha_url, 165 std::string* captcha_url,
(...skipping 18 matching lines...) Expand all
173 const char* const service); 184 const char* const service);
174 // Supply the lsid returned from ClientLogin in order to fetch 185 // Supply the lsid returned from ClientLogin in order to fetch
175 // user information. 186 // user information.
176 static std::string MakeGetUserInfoBody(const std::string& lsid); 187 static std::string MakeGetUserInfoBody(const std::string& lsid);
177 188
178 // Supply the authentication token returned from StartIssueAuthToken. 189 // Supply the authentication token returned from StartIssueAuthToken.
179 static std::string MakeTokenAuthBody(const std::string& auth_token, 190 static std::string MakeTokenAuthBody(const std::string& auth_token,
180 const std::string& continue_url, 191 const std::string& continue_url,
181 const std::string& source); 192 const std::string& source);
182 193
183 // Create a fetcher useable for making any Gaia request. 194 // Supply the authentication token returned from StartIssueAuthToken.
195 static std::string MakeMergeSessionBody(const std::string& auth_token,
196 const std::string& continue_url,
197 const std::string& source);
198
199 // Create a fetcher useable for making any Gaia request. The flags
200 // net::LOAD_DO_NOT_SEND_COOKIES are used when creating the fetcher.
Rick Campbell 2011/08/09 21:02:52 Please update the comment, probably either by appe
Roger Tawa OOO till Jul 10th 2011/08/10 17:26:47 Done.
184 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, 201 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter,
185 const std::string& body, 202 const std::string& body,
186 const GURL& gaia_gurl_, 203 const GURL& gaia_gurl,
204 bool send_cookies,
187 URLFetcher::Delegate* delegate); 205 URLFetcher::Delegate* delegate);
188 206
189 // From a URLFetcher result, generate an appropriate error. 207 // From a URLFetcher result, generate an appropriate error.
190 // From the API documentation, both IssueAuthToken and ClientLogin have 208 // From the API documentation, both IssueAuthToken and ClientLogin have
191 // the same error returns. 209 // the same error returns.
192 static GoogleServiceAuthError GenerateAuthError( 210 static GoogleServiceAuthError GenerateAuthError(
193 const std::string& data, 211 const std::string& data,
194 const net::URLRequestStatus& status); 212 const net::URLRequestStatus& status);
195 213
196 // These fields are common to GaiaAuthFetcher, same every request 214 // These fields are common to GaiaAuthFetcher, same every request
197 GaiaAuthConsumer* const consumer_; 215 GaiaAuthConsumer* const consumer_;
198 net::URLRequestContextGetter* const getter_; 216 net::URLRequestContextGetter* const getter_;
199 std::string source_; 217 std::string source_;
200 const GURL client_login_gurl_; 218 const GURL client_login_gurl_;
201 const GURL issue_auth_token_gurl_; 219 const GURL issue_auth_token_gurl_;
202 const GURL get_user_info_gurl_; 220 const GURL get_user_info_gurl_;
203 const GURL token_auth_gurl_; 221 const GURL token_auth_gurl_;
222 const GURL merge_session_gurl_;
204 223
205 // While a fetch is going on: 224 // While a fetch is going on:
206 scoped_ptr<URLFetcher> fetcher_; 225 scoped_ptr<URLFetcher> fetcher_;
207 std::string request_body_; 226 std::string request_body_;
208 std::string requested_service_; // Currently tracked for IssueAuthToken only 227 std::string requested_service_; // Currently tracked for IssueAuthToken only
209 std::string requested_info_key_; // Currently tracked for GetUserInfo only 228 std::string requested_info_key_; // Currently tracked for GetUserInfo only
210 bool fetch_pending_; 229 bool fetch_pending_;
211 230
212 friend class GaiaAuthFetcherTest; 231 friend class GaiaAuthFetcherTest;
213 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); 232 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse);
214 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError); 233 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError);
215 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError); 234 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError);
216 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError); 235 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError);
217 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); 236 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError);
218 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); 237 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError);
219 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); 238 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode);
220 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); 239 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse);
221 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); 240 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure);
222 241
223 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); 242 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher);
224 }; 243 };
225 244
226 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ 245 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_auth_consumer.h ('k') | chrome/common/net/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698