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_tracker.h" | 13 #include "base/profiler/scoped_tracker.h" |
14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "components/data_use_measurement/core/data_use_user_data.h" |
18 #include "google_apis/gaia/gaia_auth_consumer.h" | 19 #include "google_apis/gaia/gaia_auth_consumer.h" |
19 #include "google_apis/gaia/gaia_constants.h" | 20 #include "google_apis/gaia/gaia_constants.h" |
20 #include "google_apis/gaia/gaia_urls.h" | 21 #include "google_apis/gaia/gaia_urls.h" |
21 #include "google_apis/gaia/google_service_auth_error.h" | 22 #include "google_apis/gaia/google_service_auth_error.h" |
22 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
23 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
24 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
25 #include "net/http/http_status_code.h" | 26 #include "net/http/http_status_code.h" |
26 #include "net/url_request/url_fetcher.h" | 27 #include "net/url_request/url_fetcher.h" |
27 #include "net/url_request/url_request_context_getter.h" | 28 #include "net/url_request/url_request_context_getter.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 202 } |
202 | 203 |
203 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, | 204 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, |
204 const std::string& headers, | 205 const std::string& headers, |
205 const GURL& gaia_gurl, | 206 const GURL& gaia_gurl, |
206 int load_flags) { | 207 int load_flags) { |
207 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | 208 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
208 fetcher_ = net::URLFetcher::Create( | 209 fetcher_ = net::URLFetcher::Create( |
209 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, | 210 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, |
210 this); | 211 this); |
| 212 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 213 fetcher_.get(), data_use_measurement::DataUseUserData::GOOGLE_APIS); |
211 fetcher_->SetRequestContext(getter_); | 214 fetcher_->SetRequestContext(getter_); |
212 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); | 215 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); |
213 | 216 |
214 DVLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); | 217 DVLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); |
215 DVLOG(2) << "Gaia fetcher headers: " << headers; | 218 DVLOG(2) << "Gaia fetcher headers: " << headers; |
216 DVLOG(2) << "Gaia fetcher body: " << body; | 219 DVLOG(2) << "Gaia fetcher body: " << body; |
217 | 220 |
218 // The Gaia token exchange requests do not require any cookie-based | 221 // The Gaia token exchange requests do not require any cookie-based |
219 // identification as part of requests. We suppress sending any cookies to | 222 // identification as part of requests. We suppress sending any cookies to |
220 // maintain a separation between the user's browsing and Chrome's internal | 223 // maintain a separation between the user's browsing and Chrome's internal |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 return alleged_error.find(kSecondFactor) != | 979 return alleged_error.find(kSecondFactor) != |
977 std::string::npos; | 980 std::string::npos; |
978 } | 981 } |
979 | 982 |
980 // static | 983 // static |
981 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 984 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
982 const std::string& alleged_error) { | 985 const std::string& alleged_error) { |
983 return alleged_error.find(kWebLoginRequired) != | 986 return alleged_error.find(kWebLoginRequired) != |
984 std::string::npos; | 987 std::string::npos; |
985 } | 988 } |
OLD | NEW |