| 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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/strings/string_split.h" | 15 #include "base/strings/string_split.h" |
| 16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 19 #include "google_apis/gaia/gaia_auth_consumer.h" | 20 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 20 #include "google_apis/gaia/gaia_constants.h" | 21 #include "google_apis/gaia/gaia_constants.h" |
| 21 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
| 22 #include "google_apis/gaia/google_service_auth_error.h" | 23 #include "google_apis/gaia/google_service_auth_error.h" |
| 23 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 24 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 25 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_status_code.h" | 27 #include "net/http/http_status_code.h" |
| 27 #include "net/url_request/url_fetcher.h" | 28 #include "net/url_request/url_fetcher.h" |
| 28 #include "net/url_request/url_request_context_getter.h" | 29 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, | 221 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, |
| 221 const std::string& headers, | 222 const std::string& headers, |
| 222 const GURL& gaia_gurl, | 223 const GURL& gaia_gurl, |
| 223 int load_flags) { | 224 int load_flags) { |
| 224 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | 225 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
| 225 fetcher_ = net::URLFetcher::Create( | 226 fetcher_ = net::URLFetcher::Create( |
| 226 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, | 227 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, |
| 227 this); | 228 this); |
| 228 fetcher_->SetRequestContext(getter_); | 229 fetcher_->SetRequestContext(getter_); |
| 229 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); | 230 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); |
| 231 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 232 fetcher_.get(), data_use_measurement::DataUseUserData::GAIA_AUTH_FETCHER); |
| 230 | 233 |
| 231 VLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); | 234 VLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); |
| 232 VLOG(2) << "Gaia fetcher headers: " << headers; | 235 VLOG(2) << "Gaia fetcher headers: " << headers; |
| 233 VLOG(2) << "Gaia fetcher body: " << body; | 236 VLOG(2) << "Gaia fetcher body: " << body; |
| 234 | 237 |
| 235 // The Gaia token exchange requests do not require any cookie-based | 238 // The Gaia token exchange requests do not require any cookie-based |
| 236 // identification as part of requests. We suppress sending any cookies to | 239 // identification as part of requests. We suppress sending any cookies to |
| 237 // maintain a separation between the user's browsing and Chrome's internal | 240 // maintain a separation between the user's browsing and Chrome's internal |
| 238 // services. Where such mixing is desired (MergeSession or OAuthLogin), it | 241 // services. Where such mixing is desired (MergeSession or OAuthLogin), it |
| 239 // will be done explicitly. | 242 // will be done explicitly. |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 return alleged_error.find(kSecondFactor) != | 1014 return alleged_error.find(kSecondFactor) != |
| 1012 std::string::npos; | 1015 std::string::npos; |
| 1013 } | 1016 } |
| 1014 | 1017 |
| 1015 // static | 1018 // static |
| 1016 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 1019 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
| 1017 const std::string& alleged_error) { | 1020 const std::string& alleged_error) { |
| 1018 return alleged_error.find(kWebLoginRequired) != | 1021 return alleged_error.find(kWebLoginRequired) != |
| 1019 std::string::npos; | 1022 std::string::npos; |
| 1020 } | 1023 } |
| OLD | NEW |