| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/gaia/gaia_auth_fetcher.h" | 5 #include "google_apis/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/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "base/profiler/scoped_profile.h" |
| 13 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 16 #include "base/values.h" | 17 #include "base/values.h" |
| 17 #include "google_apis/gaia/gaia_auth_consumer.h" | 18 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 18 #include "google_apis/gaia/gaia_constants.h" | 19 #include "google_apis/gaia/gaia_constants.h" |
| 19 #include "google_apis/gaia/gaia_urls.h" | 20 #include "google_apis/gaia/gaia_urls.h" |
| 20 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
| 21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
| 22 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| (...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 const net::URLRequestStatus& status, | 923 const net::URLRequestStatus& status, |
| 923 int response_code) { | 924 int response_code) { |
| 924 if (status.is_success() && response_code == net::HTTP_OK) { | 925 if (status.is_success() && response_code == net::HTTP_OK) { |
| 925 consumer_->OnGetCheckConnectionInfoSuccess(data); | 926 consumer_->OnGetCheckConnectionInfoSuccess(data); |
| 926 } else { | 927 } else { |
| 927 consumer_->OnGetCheckConnectionInfoError(GenerateAuthError(data, status)); | 928 consumer_->OnGetCheckConnectionInfoError(GenerateAuthError(data, status)); |
| 928 } | 929 } |
| 929 } | 930 } |
| 930 | 931 |
| 931 void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 932 void GaiaAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
| 933 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. |
| 934 tracked_objects::ScopedProfile tracking_profile( |
| 935 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 936 "422577 GaiaAuthFetcher::OnURLFetchComplete")); |
| 937 |
| 932 fetch_pending_ = false; | 938 fetch_pending_ = false; |
| 933 // Some of the GAIA requests perform redirects, which results in the final | 939 // Some of the GAIA requests perform redirects, which results in the final |
| 934 // URL of the fetcher not being the original URL requested. Therefore use | 940 // URL of the fetcher not being the original URL requested. Therefore use |
| 935 // the original URL when determining which OnXXX function to call. | 941 // the original URL when determining which OnXXX function to call. |
| 936 const GURL& url = source->GetOriginalURL(); | 942 const GURL& url = source->GetOriginalURL(); |
| 937 const net::URLRequestStatus& status = source->GetStatus(); | 943 const net::URLRequestStatus& status = source->GetStatus(); |
| 938 int response_code = source->GetResponseCode(); | 944 int response_code = source->GetResponseCode(); |
| 939 std::string data; | 945 std::string data; |
| 940 source->GetResponseAsString(&data); | 946 source->GetResponseAsString(&data); |
| 941 #ifndef NDEBUG | 947 #ifndef NDEBUG |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 NOTREACHED(); | 981 NOTREACHED(); |
| 976 } | 982 } |
| 977 } | 983 } |
| 978 | 984 |
| 979 // static | 985 // static |
| 980 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 986 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 981 const std::string& alleged_error) { | 987 const std::string& alleged_error) { |
| 982 return alleged_error.find(kSecondFactor) != | 988 return alleged_error.find(kSecondFactor) != |
| 983 std::string::npos; | 989 std::string::npos; |
| 984 } | 990 } |
| OLD | NEW |