Chromium Code Reviews| 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 "google_apis/gaia/gaia_auth_consumer.h" | 19 #include "google_apis/gaia/gaia_auth_consumer.h" |
| 20 #include "google_apis/gaia/gaia_auth_util.h" | 20 #include "google_apis/gaia/gaia_auth_util.h" |
| 21 #include "google_apis/gaia/gaia_constants.h" | 21 #include "google_apis/gaia/gaia_constants.h" |
| 22 #include "google_apis/gaia/gaia_urls.h" | 22 #include "google_apis/gaia/gaia_urls.h" |
| 23 #include "google_apis/gaia/google_service_auth_error.h" | 23 #include "google_apis/gaia/google_service_auth_error.h" |
| 24 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 25 #include "net/base/load_flags.h" | 25 #include "net/base/load_flags.h" |
| 26 #include "net/http/http_response_headers.h" | 26 #include "net/http/http_response_headers.h" |
| 27 #include "net/http/http_status_code.h" | 27 #include "net/http/http_status_code.h" |
| 28 #include "net/http/http_util.h" | 28 #include "net/http/http_util.h" |
| 29 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 29 #include "net/url_request/url_fetcher.h" | 30 #include "net/url_request/url_fetcher.h" |
| 30 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
| 31 #include "net/url_request/url_request_status.h" | 32 #include "net/url_request/url_request_status.h" |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 const int kLoadFlagsIgnoreCookies = net::LOAD_DO_NOT_SEND_COOKIES | | 35 const int kLoadFlagsIgnoreCookies = net::LOAD_DO_NOT_SEND_COOKIES | |
| 35 net::LOAD_DO_NOT_SAVE_COOKIES; | 36 net::LOAD_DO_NOT_SAVE_COOKIES; |
| 36 | 37 |
| 37 static bool CookiePartsContains(const std::vector<std::string>& parts, | 38 static bool CookiePartsContains(const std::vector<std::string>& parts, |
| 38 const char* part) { | 39 const char* part) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 void GaiaAuthFetcher::CancelRequest() { | 218 void GaiaAuthFetcher::CancelRequest() { |
| 218 fetcher_.reset(); | 219 fetcher_.reset(); |
| 219 fetch_pending_ = false; | 220 fetch_pending_ = false; |
| 220 } | 221 } |
| 221 | 222 |
| 222 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, | 223 void GaiaAuthFetcher::CreateAndStartGaiaFetcher(const std::string& body, |
| 223 const std::string& headers, | 224 const std::string& headers, |
| 224 const GURL& gaia_gurl, | 225 const GURL& gaia_gurl, |
| 225 int load_flags) { | 226 int load_flags) { |
| 226 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; | 227 DCHECK(!fetch_pending_) << "Tried to fetch two things at once!"; |
| 228 net::NetworkTrafficAnnotationTag traffic_annotation = | |
|
msarda
2017/05/03 09:03:53
This is a helper method that creates a fetcher tha
Ramin Halavati
2017/05/03 09:45:06
OK, do you that suggest I add annotation as an inp
msarda
2017/05/10 09:01:54
If we need to annotate each call differently, then
Ramin Halavati
2017/05/10 09:25:20
Can we can have a generic one here?
If we decide t
| |
| 229 net::DefineNetworkTrafficAnnotation("...", R"( | |
| 230 semantics { | |
| 231 sender: "..." | |
| 232 description: "..." | |
| 233 trigger: "..." | |
| 234 data: "..." | |
| 235 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 236 } | |
| 237 policy { | |
| 238 cookies_allowed: false/true | |
| 239 cookies_store: "..." | |
| 240 setting: "..." | |
| 241 chrome_policy { | |
| 242 [POLICY_NAME] { | |
| 243 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 244 [POLICY_NAME]: ... //(value to disable it) | |
| 245 } | |
| 246 } | |
| 247 policy_exception_justification: "..." | |
| 248 })"); | |
| 227 fetcher_ = net::URLFetcher::Create( | 249 fetcher_ = net::URLFetcher::Create( |
| 228 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, | 250 0, gaia_gurl, body.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, |
| 229 this); | 251 this, traffic_annotation); |
| 230 fetcher_->SetRequestContext(getter_); | 252 fetcher_->SetRequestContext(getter_); |
| 231 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); | 253 fetcher_->SetUploadData("application/x-www-form-urlencoded", body); |
| 232 gaia::MarkURLFetcherAsGaia(fetcher_.get()); | 254 gaia::MarkURLFetcherAsGaia(fetcher_.get()); |
| 233 | 255 |
| 234 VLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); | 256 VLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); |
| 235 VLOG(2) << "Gaia fetcher headers: " << headers; | 257 VLOG(2) << "Gaia fetcher headers: " << headers; |
| 236 VLOG(2) << "Gaia fetcher body: " << body; | 258 VLOG(2) << "Gaia fetcher body: " << body; |
| 237 | 259 |
| 238 // The Gaia token exchange requests do not require any cookie-based | 260 // The Gaia token exchange requests do not require any cookie-based |
| 239 // identification as part of requests. We suppress sending any cookies to | 261 // identification as part of requests. We suppress sending any cookies to |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 return alleged_error.find(kSecondFactor) != | 1037 return alleged_error.find(kSecondFactor) != |
| 1016 std::string::npos; | 1038 std::string::npos; |
| 1017 } | 1039 } |
| 1018 | 1040 |
| 1019 // static | 1041 // static |
| 1020 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 1042 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
| 1021 const std::string& alleged_error) { | 1043 const std::string& alleged_error) { |
| 1022 return alleged_error.find(kWebLoginRequired) != | 1044 return alleged_error.find(kWebLoginRequired) != |
| 1023 std::string::npos; | 1045 std::string::npos; |
| 1024 } | 1046 } |
| OLD | NEW |