| 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 #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 |
| 11 #include "base/stringprintf.h" | |
| 12 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/stringprintf.h" |
| 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 15 #include "chrome/common/net/gaia/gaia_constants.h" | 15 #include "chrome/common/net/gaia/gaia_constants.h" |
| 16 #include "chrome/common/net/gaia/gaia_urls.h" | 16 #include "chrome/common/net/gaia/gaia_urls.h" |
| 17 #include "chrome/common/net/gaia/google_service_auth_error.h" | 17 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 18 #include "chrome/common/net/http_return.h" | 18 #include "chrome/common/net/http_return.h" |
| 19 #include "net/base/escape.h" | 19 #include "net/base/escape.h" |
| 20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
| 21 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 22 #include "net/url_request/url_request_status.h" | 22 #include "net/url_request/url_request_status.h" |
| 23 | 23 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 // static | 402 // static |
| 403 GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( | 403 GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( |
| 404 const std::string& data, | 404 const std::string& data, |
| 405 const net::URLRequestStatus& status) { | 405 const net::URLRequestStatus& status) { |
| 406 if (!status.is_success()) { | 406 if (!status.is_success()) { |
| 407 if (status.status() == net::URLRequestStatus::CANCELED) { | 407 if (status.status() == net::URLRequestStatus::CANCELED) { |
| 408 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); | 408 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); |
| 409 } else { | 409 } else { |
| 410 LOG(WARNING) << "Could not reach Google Accounts servers: errno " | 410 LOG(WARNING) << "Could not reach Google Accounts servers: errno " |
| 411 << status.os_error(); | 411 << status.error(); |
| 412 return GoogleServiceAuthError::FromConnectionError(status.os_error()); | 412 return GoogleServiceAuthError::FromConnectionError(status.error()); |
| 413 } | 413 } |
| 414 } else { | 414 } else { |
| 415 if (IsSecondFactorSuccess(data)) { | 415 if (IsSecondFactorSuccess(data)) { |
| 416 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); | 416 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); |
| 417 } | 417 } |
| 418 | 418 |
| 419 std::string error; | 419 std::string error; |
| 420 std::string url; | 420 std::string url; |
| 421 std::string captcha_url; | 421 std::string captcha_url; |
| 422 std::string captcha_token; | 422 std::string captcha_token; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 454 |
| 455 // static | 455 // static |
| 456 GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError( | 456 GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError( |
| 457 const std::string& data, | 457 const std::string& data, |
| 458 const net::URLRequestStatus& status) { | 458 const net::URLRequestStatus& status) { |
| 459 if (!status.is_success()) { | 459 if (!status.is_success()) { |
| 460 if (status.status() == net::URLRequestStatus::CANCELED) { | 460 if (status.status() == net::URLRequestStatus::CANCELED) { |
| 461 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); | 461 return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED); |
| 462 } else { | 462 } else { |
| 463 LOG(WARNING) << "Could not reach Google Accounts servers: errno " | 463 LOG(WARNING) << "Could not reach Google Accounts servers: errno " |
| 464 << status.os_error(); | 464 << status.error(); |
| 465 return GoogleServiceAuthError::FromConnectionError(status.os_error()); | 465 return GoogleServiceAuthError::FromConnectionError(status.error()); |
| 466 } | 466 } |
| 467 } else { | 467 } else { |
| 468 if (IsSecondFactorSuccess(data)) { | 468 if (IsSecondFactorSuccess(data)) { |
| 469 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); | 469 return GoogleServiceAuthError(GoogleServiceAuthError::TWO_FACTOR); |
| 470 } | 470 } |
| 471 | 471 |
| 472 std::string error; | 472 std::string error; |
| 473 std::string url; | 473 std::string url; |
| 474 std::string captcha_url; | 474 std::string captcha_url; |
| 475 std::string captcha_token; | 475 std::string captcha_token; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 NOTREACHED(); | 602 NOTREACHED(); |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 // static | 606 // static |
| 607 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 607 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 608 const std::string& alleged_error) { | 608 const std::string& alleged_error) { |
| 609 return alleged_error.find(kSecondFactor) != | 609 return alleged_error.find(kSecondFactor) != |
| 610 std::string::npos; | 610 std::string::npos; |
| 611 } | 611 } |
| OLD | NEW |