| OLD | NEW |
| 1 // Copyright (c) 2010 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" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 // Start a request to get a particular key from user info. | 69 // Start a request to get a particular key from user info. |
| 70 // GaiaAuthConsumer will be called back on the same thread when | 70 // GaiaAuthConsumer will be called back on the same thread when |
| 71 // results come back. | 71 // results come back. |
| 72 // You can't make more than one request at a time. | 72 // You can't make more than one request at a time. |
| 73 void StartGetUserInfo(const std::string& lsid, | 73 void StartGetUserInfo(const std::string& lsid, |
| 74 const std::string& info_key); | 74 const std::string& info_key); |
| 75 | 75 |
| 76 // Implementation of URLFetcher::Delegate | 76 // Implementation of URLFetcher::Delegate |
| 77 virtual void OnURLFetchComplete(const URLFetcher* source, | 77 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 78 const GURL& url, | 78 const GURL& url, |
| 79 const URLRequestStatus& status, | 79 const net::URLRequestStatus& status, |
| 80 int response_code, | 80 int response_code, |
| 81 const ResponseCookies& cookies, | 81 const ResponseCookies& cookies, |
| 82 const std::string& data); | 82 const std::string& data); |
| 83 | 83 |
| 84 // StartClientLogin been called && results not back yet? | 84 // StartClientLogin been called && results not back yet? |
| 85 bool HasPendingFetch(); | 85 bool HasPendingFetch(); |
| 86 | 86 |
| 87 // Stop any URL fetches in progress. | 87 // Stop any URL fetches in progress. |
| 88 void CancelRequest(); | 88 void CancelRequest(); |
| 89 | 89 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 109 static const char kCaptchaError[]; | 109 static const char kCaptchaError[]; |
| 110 static const char kServiceUnavailableError[]; | 110 static const char kServiceUnavailableError[]; |
| 111 static const char kErrorParam[]; | 111 static const char kErrorParam[]; |
| 112 static const char kErrorUrlParam[]; | 112 static const char kErrorUrlParam[]; |
| 113 static const char kCaptchaUrlParam[]; | 113 static const char kCaptchaUrlParam[]; |
| 114 static const char kCaptchaTokenParam[]; | 114 static const char kCaptchaTokenParam[]; |
| 115 static const char kCaptchaUrlPrefix[]; | 115 static const char kCaptchaUrlPrefix[]; |
| 116 | 116 |
| 117 // Process the results of a ClientLogin fetch. | 117 // Process the results of a ClientLogin fetch. |
| 118 void OnClientLoginFetched(const std::string& data, | 118 void OnClientLoginFetched(const std::string& data, |
| 119 const URLRequestStatus& status, | 119 const net::URLRequestStatus& status, |
| 120 int response_code); | 120 int response_code); |
| 121 | 121 |
| 122 void OnIssueAuthTokenFetched(const std::string& data, | 122 void OnIssueAuthTokenFetched(const std::string& data, |
| 123 const URLRequestStatus& status, | 123 const net::URLRequestStatus& status, |
| 124 int response_code); | 124 int response_code); |
| 125 | 125 |
| 126 void OnGetUserInfoFetched(const std::string& data, | 126 void OnGetUserInfoFetched(const std::string& data, |
| 127 const URLRequestStatus& status, | 127 const net::URLRequestStatus& status, |
| 128 int response_code); | 128 int response_code); |
| 129 | 129 |
| 130 // Tokenize the results of a ClientLogin fetch. | 130 // Tokenize the results of a ClientLogin fetch. |
| 131 static void ParseClientLoginResponse(const std::string& data, | 131 static void ParseClientLoginResponse(const std::string& data, |
| 132 std::string* sid, | 132 std::string* sid, |
| 133 std::string* lsid, | 133 std::string* lsid, |
| 134 std::string* token); | 134 std::string* token); |
| 135 | 135 |
| 136 static void ParseClientLoginFailure(const std::string& data, | 136 static void ParseClientLoginFailure(const std::string& data, |
| 137 std::string* error, | 137 std::string* error, |
| 138 std::string* error_url, | 138 std::string* error_url, |
| 139 std::string* captcha_url, | 139 std::string* captcha_url, |
| 140 std::string* captcha_token); | 140 std::string* captcha_token); |
| 141 | 141 |
| 142 // From a URLFetcher result, generate an appropriate error. | 142 // From a URLFetcher result, generate an appropriate error. |
| 143 // From the API documentation, both IssueAuthToken and ClientLogin have | 143 // From the API documentation, both IssueAuthToken and ClientLogin have |
| 144 // the same error returns. | 144 // the same error returns. |
| 145 static GoogleServiceAuthError GenerateAuthError( | 145 static GoogleServiceAuthError GenerateAuthError( |
| 146 const std::string& data, | 146 const std::string& data, |
| 147 const URLRequestStatus& status); | 147 const net::URLRequestStatus& status); |
| 148 | 148 |
| 149 // Is this a special case Gaia error for TwoFactor auth? | 149 // Is this a special case Gaia error for TwoFactor auth? |
| 150 static bool IsSecondFactorSuccess(const std::string& alleged_error); | 150 static bool IsSecondFactorSuccess(const std::string& alleged_error); |
| 151 | 151 |
| 152 // Given parameters, create a ClientLogin request body. | 152 // Given parameters, create a ClientLogin request body. |
| 153 static std::string MakeClientLoginBody( | 153 static std::string MakeClientLoginBody( |
| 154 const std::string& username, | 154 const std::string& username, |
| 155 const std::string& password, | 155 const std::string& password, |
| 156 const std::string& source, | 156 const std::string& source, |
| 157 const char* const service, | 157 const char* const service, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); | 197 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); |
| 198 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); | 198 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); |
| 199 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); | 199 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); |
| 200 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); | 200 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); |
| 201 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); | 201 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); |
| 202 | 202 |
| 203 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); | 203 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ | 206 #endif // CHROME_COMMON_NET_GAIA_GAIA_AUTH_FETCHER_H_ |
| OLD | NEW |