| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 5 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 "Session=%s"; | 46 "Session=%s"; |
| 47 // static | 47 // static |
| 48 const char GaiaAuthFetcher::kGetUserInfoFormat[] = | 48 const char GaiaAuthFetcher::kGetUserInfoFormat[] = |
| 49 "LSID=%s"; | 49 "LSID=%s"; |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 const char GaiaAuthFetcher::kAccountDeletedError[] = "AccountDeleted"; | 52 const char GaiaAuthFetcher::kAccountDeletedError[] = "AccountDeleted"; |
| 53 // static | 53 // static |
| 54 const char GaiaAuthFetcher::kAccountDisabledError[] = "AccountDisabled"; | 54 const char GaiaAuthFetcher::kAccountDisabledError[] = "AccountDisabled"; |
| 55 // static | 55 // static |
| 56 const char GaiaAuthFetcher::kBadAuthenticationError[] = "BadAuthentication"; |
| 57 // static |
| 56 const char GaiaAuthFetcher::kCaptchaError[] = "CaptchaRequired"; | 58 const char GaiaAuthFetcher::kCaptchaError[] = "CaptchaRequired"; |
| 57 // static | 59 // static |
| 58 const char GaiaAuthFetcher::kServiceUnavailableError[] = | 60 const char GaiaAuthFetcher::kServiceUnavailableError[] = |
| 59 "ServiceUnavailable"; | 61 "ServiceUnavailable"; |
| 60 // static | 62 // static |
| 61 const char GaiaAuthFetcher::kErrorParam[] = "Error"; | 63 const char GaiaAuthFetcher::kErrorParam[] = "Error"; |
| 62 // static | 64 // static |
| 63 const char GaiaAuthFetcher::kErrorUrlParam[] = "Url"; | 65 const char GaiaAuthFetcher::kErrorUrlParam[] = "Url"; |
| 64 // static | 66 // static |
| 65 const char GaiaAuthFetcher::kCaptchaUrlParam[] = "CaptchaUrl"; | 67 const char GaiaAuthFetcher::kCaptchaUrlParam[] = "CaptchaUrl"; |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 if (error == kCaptchaError) { | 339 if (error == kCaptchaError) { |
| 338 GURL image_url(kCaptchaUrlPrefix + captcha_url); | 340 GURL image_url(kCaptchaUrlPrefix + captcha_url); |
| 339 GURL unlock_url(url); | 341 GURL unlock_url(url); |
| 340 return GoogleServiceAuthError::FromCaptchaChallenge( | 342 return GoogleServiceAuthError::FromCaptchaChallenge( |
| 341 captcha_token, image_url, unlock_url); | 343 captcha_token, image_url, unlock_url); |
| 342 } | 344 } |
| 343 if (error == kAccountDeletedError) | 345 if (error == kAccountDeletedError) |
| 344 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED); | 346 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DELETED); |
| 345 if (error == kAccountDisabledError) | 347 if (error == kAccountDisabledError) |
| 346 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED); | 348 return GoogleServiceAuthError(GoogleServiceAuthError::ACCOUNT_DISABLED); |
| 349 if (error == kBadAuthenticationError) { |
| 350 return GoogleServiceAuthError( |
| 351 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 352 } |
| 347 if (error == kServiceUnavailableError) { | 353 if (error == kServiceUnavailableError) { |
| 348 return GoogleServiceAuthError( | 354 return GoogleServiceAuthError( |
| 349 GoogleServiceAuthError::SERVICE_UNAVAILABLE); | 355 GoogleServiceAuthError::SERVICE_UNAVAILABLE); |
| 350 } | 356 } |
| 351 | 357 |
| 358 LOG(WARNING) << "Incomprehensible response from Google Accounts servers."; |
| 352 return GoogleServiceAuthError( | 359 return GoogleServiceAuthError( |
| 353 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 360 GoogleServiceAuthError::SERVICE_UNAVAILABLE); |
| 354 } | 361 } |
| 355 | 362 |
| 356 NOTREACHED(); | 363 NOTREACHED(); |
| 357 } | 364 } |
| 358 | 365 |
| 359 void GaiaAuthFetcher::OnClientLoginFetched(const std::string& data, | 366 void GaiaAuthFetcher::OnClientLoginFetched(const std::string& data, |
| 360 const URLRequestStatus& status, | 367 const URLRequestStatus& status, |
| 361 int response_code) { | 368 int response_code) { |
| 362 | 369 |
| 363 if (status.is_success() && response_code == RC_REQUEST_OK) { | 370 if (status.is_success() && response_code == RC_REQUEST_OK) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 NOTREACHED(); | 435 NOTREACHED(); |
| 429 } | 436 } |
| 430 } | 437 } |
| 431 | 438 |
| 432 // static | 439 // static |
| 433 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 440 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 434 const std::string& alleged_error) { | 441 const std::string& alleged_error) { |
| 435 return alleged_error.find(kSecondFactor) != | 442 return alleged_error.find(kSecondFactor) != |
| 436 std::string::npos; | 443 std::string::npos; |
| 437 } | 444 } |
| OLD | NEW |