Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/autofill/core/browser/autofill_download_manager.h" | 5 #include "components/autofill/core/browser/autofill_download_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 15 #include "base/threading/thread_task_runner_handle.h" |
| 16 #include "components/autofill/core/browser/autofill_driver.h" | 16 #include "components/autofill/core/browser/autofill_driver.h" |
| 17 #include "components/autofill/core/browser/autofill_metrics.h" | 17 #include "components/autofill/core/browser/autofill_metrics.h" |
| 18 #include "components/autofill/core/browser/form_structure.h" | 18 #include "components/autofill/core/browser/form_structure.h" |
| 19 #include "components/autofill/core/browser/proto/server.pb.h" | 19 #include "components/autofill/core/browser/proto/server.pb.h" |
| 20 #include "components/autofill/core/common/autofill_pref_names.h" | 20 #include "components/autofill/core/common/autofill_pref_names.h" |
| 21 #include "components/data_use_measurement/core/data_use_user_data.h" | 21 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 22 #include "components/variations/net/variations_http_headers.h" | 22 #include "components/variations/net/variations_http_headers.h" |
| 23 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 24 #include "net/http/http_request_headers.h" | 24 #include "net/http/http_request_headers.h" |
| 25 #include "net/http/http_response_headers.h" | 25 #include "net/http/http_response_headers.h" |
| 26 #include "net/http/http_status_code.h" | 26 #include "net/http/http_status_code.h" |
| 27 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 27 #include "net/url_request/url_fetcher.h" | 28 #include "net/url_request/url_fetcher.h" |
| 28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 29 | 30 |
| 30 namespace autofill { | 31 namespace autofill { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 const size_t kMaxFormCacheSize = 16; | 35 const size_t kMaxFormCacheSize = 16; |
| 35 const size_t kMaxFieldsPerQueryRequest = 100; | 36 const size_t kMaxFieldsPerQueryRequest = 100; |
| 36 | 37 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 return StartRequest(request_data); | 225 return StartRequest(request_data); |
| 225 } | 226 } |
| 226 | 227 |
| 227 bool AutofillDownloadManager::StartRequest( | 228 bool AutofillDownloadManager::StartRequest( |
| 228 const FormRequestData& request_data) { | 229 const FormRequestData& request_data) { |
| 229 net::URLRequestContextGetter* request_context = | 230 net::URLRequestContextGetter* request_context = |
| 230 driver_->GetURLRequestContext(); | 231 driver_->GetURLRequestContext(); |
| 231 DCHECK(request_context); | 232 DCHECK(request_context); |
| 232 GURL request_url = GetRequestUrl(request_data.request_type); | 233 GURL request_url = GetRequestUrl(request_data.request_type); |
| 233 | 234 |
| 235 net::NetworkTrafficAnnotationTag traffic_annotation = | |
| 236 net::DefineNetworkTrafficAnnotation("...", R"( | |
| 237 semantics { | |
| 238 sender: "..." | |
| 239 description: "..." | |
| 240 trigger: "..." | |
| 241 data: "..." | |
| 242 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 243 } | |
| 244 policy { | |
| 245 cookies_allowed: false/true | |
| 246 cookies_store: "..." | |
| 247 setting: "..." | |
| 248 chrome_policy { | |
| 249 [POLICY_NAME] { | |
| 250 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 251 [POLICY_NAME]: ... //(value to disable it) | |
| 252 } | |
| 253 } | |
| 254 policy_exception_justification: "..." | |
| 255 })"); | |
|
Roger McFarlane (Chromium)
2017/03/15 14:54:56
There are actuallly two different requests that ca
| |
| 256 | |
| 234 // Id is ignored for regular chrome, in unit test id's for fake fetcher | 257 // Id is ignored for regular chrome, in unit test id's for fake fetcher |
| 235 // factory will be 0, 1, 2, ... | 258 // factory will be 0, 1, 2, ... |
| 236 std::unique_ptr<net::URLFetcher> owned_fetcher = net::URLFetcher::Create( | 259 std::unique_ptr<net::URLFetcher> owned_fetcher = |
| 237 fetcher_id_for_unittest_++, request_url, net::URLFetcher::POST, this); | 260 net::URLFetcher::Create(fetcher_id_for_unittest_++, request_url, |
| 261 net::URLFetcher::POST, this, traffic_annotation); | |
| 238 net::URLFetcher* fetcher = owned_fetcher.get(); | 262 net::URLFetcher* fetcher = owned_fetcher.get(); |
| 239 data_use_measurement::DataUseUserData::AttachToFetcher( | 263 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 240 fetcher, data_use_measurement::DataUseUserData::AUTOFILL); | 264 fetcher, data_use_measurement::DataUseUserData::AUTOFILL); |
| 241 url_fetchers_[fetcher] = | 265 url_fetchers_[fetcher] = |
| 242 std::make_pair(std::move(owned_fetcher), request_data); | 266 std::make_pair(std::move(owned_fetcher), request_data); |
| 243 fetcher->SetAutomaticallyRetryOn5xx(false); | 267 fetcher->SetAutomaticallyRetryOn5xx(false); |
| 244 fetcher->SetRequestContext(request_context); | 268 fetcher->SetRequestContext(request_context); |
| 245 fetcher->SetUploadData("text/proto", request_data.payload); | 269 fetcher->SetUploadData("text/proto", request_data.payload); |
| 246 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 270 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 247 net::LOAD_DO_NOT_SEND_COOKIES); | 271 net::LOAD_DO_NOT_SEND_COOKIES); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 it->second.second.form_signatures); | 374 it->second.second.form_signatures); |
| 351 } else { | 375 } else { |
| 352 VLOG(1) << "AutofillDownloadManager: upload request has succeeded."; | 376 VLOG(1) << "AutofillDownloadManager: upload request has succeeded."; |
| 353 observer_->OnUploadedPossibleFieldTypes(); | 377 observer_->OnUploadedPossibleFieldTypes(); |
| 354 } | 378 } |
| 355 } | 379 } |
| 356 url_fetchers_.erase(it); | 380 url_fetchers_.erase(it); |
| 357 } | 381 } |
| 358 | 382 |
| 359 } // namespace autofill | 383 } // namespace autofill |
| OLD | NEW |