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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: take out CHECKs Created 9 years, 1 month 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
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 13 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
14 #include "content/common/net/url_fetcher.h" 14 #include "content/public/common/url_fetcher_delegate.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 16
17 // Authenticate a user against the Google Accounts ClientLogin API 17 // Authenticate a user against the Google Accounts ClientLogin API
18 // with various capabilities and return results to a GaiaAuthConsumer. 18 // with various capabilities and return results to a GaiaAuthConsumer.
19 // 19 //
20 // In the future, we will also issue auth tokens from this class. 20 // In the future, we will also issue auth tokens from this class.
21 // This class should be used on a single thread, but it can be whichever thread 21 // This class should be used on a single thread, but it can be whichever thread
22 // that you like. 22 // that you like.
23 // 23 //
24 // This class can handle one request at a time. To parallelize requests, 24 // This class can handle one request at a time. To parallelize requests,
25 // create multiple GaiaAuthFetcher's. 25 // create multiple GaiaAuthFetcher's.
26 26
27 class GaiaAuthFetcherTest; 27 class GaiaAuthFetcherTest;
28 28
29 class GaiaAuthFetcher : public URLFetcher::Delegate { 29 namespace net {
30 class URLRequestContextGetter;
31 }
32
33 class GaiaAuthFetcher : public content::URLFetcherDelegate {
30 public: 34 public:
31 enum HostedAccountsSetting { 35 enum HostedAccountsSetting {
32 HostedAccountsAllowed, 36 HostedAccountsAllowed,
33 HostedAccountsNotAllowed 37 HostedAccountsNotAllowed
34 }; 38 };
35 39
36 // Magic string indicating that, while a second factor is still 40 // Magic string indicating that, while a second factor is still
37 // needed to complete authentication, the user provided the right password. 41 // needed to complete authentication, the user provided the right password.
38 static const char kSecondFactor[]; 42 static const char kSecondFactor[];
39 43
(...skipping 29 matching lines...) Expand all
69 const std::string& info_key); 73 const std::string& info_key);
70 74
71 // Start a TokenAuth request to pre-login the user with the given credentials. 75 // Start a TokenAuth request to pre-login the user with the given credentials.
72 void StartTokenAuth(const std::string& auth_token); 76 void StartTokenAuth(const std::string& auth_token);
73 77
74 // Start a MergeSession request to pre-login the user with the given 78 // Start a MergeSession request to pre-login the user with the given
75 // credentials. Unlike TokenAuth above, MergeSession will not sign out any 79 // credentials. Unlike TokenAuth above, MergeSession will not sign out any
76 // existing accounts. 80 // existing accounts.
77 void StartMergeSession(const std::string& auth_token); 81 void StartMergeSession(const std::string& auth_token);
78 82
79 // Implementation of URLFetcher::Delegate 83 // Implementation of content::URLFetcherDelegate
80 virtual void OnURLFetchComplete(const URLFetcher* source, 84 virtual void OnURLFetchComplete(const URLFetcher* source);
81 const GURL& url,
82 const net::URLRequestStatus& status,
83 int response_code,
84 const net::ResponseCookies& cookies,
85 const std::string& data);
86 85
87 // StartClientLogin been called && results not back yet? 86 // StartClientLogin been called && results not back yet?
88 bool HasPendingFetch(); 87 bool HasPendingFetch();
89 88
90 // Stop any URL fetches in progress. 89 // Stop any URL fetches in progress.
91 void CancelRequest(); 90 void CancelRequest();
92 91
93 // From a URLFetcher result, generate an appropriate error. 92 // From a URLFetcher result, generate an appropriate error.
94 // From the API documentation, both IssueAuthToken and ClientLogin have 93 // From the API documentation, both IssueAuthToken and ClientLogin have
95 // the same error returns. 94 // the same error returns.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // Supply the authentication token returned from StartIssueAuthToken. 193 // Supply the authentication token returned from StartIssueAuthToken.
195 static std::string MakeMergeSessionBody(const std::string& auth_token, 194 static std::string MakeMergeSessionBody(const std::string& auth_token,
196 const std::string& continue_url, 195 const std::string& continue_url,
197 const std::string& source); 196 const std::string& source);
198 197
199 // Create a fetcher useable for making any Gaia request. 198 // Create a fetcher useable for making any Gaia request.
200 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, 199 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter,
201 const std::string& body, 200 const std::string& body,
202 const GURL& gaia_gurl, 201 const GURL& gaia_gurl,
203 bool send_cookies, 202 bool send_cookies,
204 URLFetcher::Delegate* delegate); 203 content::URLFetcherDelegate* delegate);
205 204
206 // From a URLFetcher result, generate an appropriate error. 205 // From a URLFetcher result, generate an appropriate error.
207 // From the API documentation, both IssueAuthToken and ClientLogin have 206 // From the API documentation, both IssueAuthToken and ClientLogin have
208 // the same error returns. 207 // the same error returns.
209 static GoogleServiceAuthError GenerateAuthError( 208 static GoogleServiceAuthError GenerateAuthError(
210 const std::string& data, 209 const std::string& data,
211 const net::URLRequestStatus& status); 210 const net::URLRequestStatus& status);
212 211
213 // These fields are common to GaiaAuthFetcher, same every request 212 // These fields are common to GaiaAuthFetcher, same every request
214 GaiaAuthConsumer* const consumer_; 213 GaiaAuthConsumer* const consumer_;
(...skipping 20 matching lines...) Expand all
235 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); 234 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError);
236 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); 235 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError);
237 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); 236 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode);
238 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); 237 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse);
239 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); 238 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure);
240 239
241 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); 240 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher);
242 }; 241 };
243 242
244 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ 243 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698