| OLD | NEW |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 // Start a TokenAuth request to pre-login the user with the given credentials. | 76 // Start a TokenAuth request to pre-login the user with the given credentials. |
| 77 void StartTokenAuth(const std::string& auth_token); | 77 void StartTokenAuth(const std::string& auth_token); |
| 78 | 78 |
| 79 // Start a MergeSession request to pre-login the user with the given | 79 // Start a MergeSession request to pre-login the user with the given |
| 80 // credentials. Unlike TokenAuth above, MergeSession will not sign out any | 80 // credentials. Unlike TokenAuth above, MergeSession will not sign out any |
| 81 // existing accounts. | 81 // existing accounts. |
| 82 void StartMergeSession(const std::string& auth_token); | 82 void StartMergeSession(const std::string& auth_token); |
| 83 | 83 |
| 84 // Implementation of content::URLFetcherDelegate | 84 // Implementation of content::URLFetcherDelegate |
| 85 virtual void OnURLFetchComplete(const URLFetcher* source); | 85 virtual void OnURLFetchComplete(const content::URLFetcher* source); |
| 86 | 86 |
| 87 // StartClientLogin been called && results not back yet? | 87 // StartClientLogin been called && results not back yet? |
| 88 bool HasPendingFetch(); | 88 bool HasPendingFetch(); |
| 89 | 89 |
| 90 // Stop any URL fetches in progress. | 90 // Stop any URL fetches in progress. |
| 91 void CancelRequest(); | 91 void CancelRequest(); |
| 92 | 92 |
| 93 // From a URLFetcher result, generate an appropriate error. | 93 // From a URLFetcher result, generate an appropriate error. |
| 94 // From the API documentation, both IssueAuthToken and ClientLogin have | 94 // From the API documentation, both IssueAuthToken and ClientLogin have |
| 95 // the same error returns. | 95 // the same error returns. |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 static std::string MakeTokenAuthBody(const std::string& auth_token, | 190 static std::string MakeTokenAuthBody(const std::string& auth_token, |
| 191 const std::string& continue_url, | 191 const std::string& continue_url, |
| 192 const std::string& source); | 192 const std::string& source); |
| 193 | 193 |
| 194 // Supply the authentication token returned from StartIssueAuthToken. | 194 // Supply the authentication token returned from StartIssueAuthToken. |
| 195 static std::string MakeMergeSessionBody(const std::string& auth_token, | 195 static std::string MakeMergeSessionBody(const std::string& auth_token, |
| 196 const std::string& continue_url, | 196 const std::string& continue_url, |
| 197 const std::string& source); | 197 const std::string& source); |
| 198 | 198 |
| 199 // Create a fetcher useable for making any Gaia request. | 199 // Create a fetcher useable for making any Gaia request. |
| 200 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, | 200 static content::URLFetcher* CreateGaiaFetcher( |
| 201 const std::string& body, | 201 net::URLRequestContextGetter* getter, |
| 202 const GURL& gaia_gurl, | 202 const std::string& body, |
| 203 bool send_cookies, | 203 const GURL& gaia_gurl, |
| 204 content::URLFetcherDelegate* delegate); | 204 bool send_cookies, |
| 205 content::URLFetcherDelegate* delegate); |
| 205 | 206 |
| 206 // From a URLFetcher result, generate an appropriate error. | 207 // From a URLFetcher result, generate an appropriate error. |
| 207 // From the API documentation, both IssueAuthToken and ClientLogin have | 208 // From the API documentation, both IssueAuthToken and ClientLogin have |
| 208 // the same error returns. | 209 // the same error returns. |
| 209 static GoogleServiceAuthError GenerateAuthError( | 210 static GoogleServiceAuthError GenerateAuthError( |
| 210 const std::string& data, | 211 const std::string& data, |
| 211 const net::URLRequestStatus& status); | 212 const net::URLRequestStatus& status); |
| 212 | 213 |
| 213 // These fields are common to GaiaAuthFetcher, same every request | 214 // These fields are common to GaiaAuthFetcher, same every request |
| 214 GaiaAuthConsumer* const consumer_; | 215 GaiaAuthConsumer* const consumer_; |
| 215 net::URLRequestContextGetter* const getter_; | 216 net::URLRequestContextGetter* const getter_; |
| 216 std::string source_; | 217 std::string source_; |
| 217 const GURL client_login_gurl_; | 218 const GURL client_login_gurl_; |
| 218 const GURL issue_auth_token_gurl_; | 219 const GURL issue_auth_token_gurl_; |
| 219 const GURL get_user_info_gurl_; | 220 const GURL get_user_info_gurl_; |
| 220 const GURL token_auth_gurl_; | 221 const GURL token_auth_gurl_; |
| 221 const GURL merge_session_gurl_; | 222 const GURL merge_session_gurl_; |
| 222 | 223 |
| 223 // While a fetch is going on: | 224 // While a fetch is going on: |
| 224 scoped_ptr<URLFetcher> fetcher_; | 225 scoped_ptr<content::URLFetcher> fetcher_; |
| 225 std::string request_body_; | 226 std::string request_body_; |
| 226 std::string requested_service_; // Currently tracked for IssueAuthToken only | 227 std::string requested_service_; // Currently tracked for IssueAuthToken only |
| 227 std::string requested_info_key_; // Currently tracked for GetUserInfo only | 228 std::string requested_info_key_; // Currently tracked for GetUserInfo only |
| 228 bool fetch_pending_; | 229 bool fetch_pending_; |
| 229 | 230 |
| 230 friend class GaiaAuthFetcherTest; | 231 friend class GaiaAuthFetcherTest; |
| 231 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); | 232 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); |
| 232 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError); | 233 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError); |
| 233 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError); | 234 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError); |
| 234 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError); | 235 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError); |
| 235 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); | 236 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); |
| 236 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); | 237 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); |
| 237 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); | 238 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); |
| 238 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); | 239 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); |
| 239 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); | 240 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); |
| 240 | 241 |
| 241 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); | 242 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); |
| 242 }; | 243 }; |
| 243 | 244 |
| 244 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ | 245 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ |
| OLD | NEW |