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 |
| 31 namespace { | |
| 32 | |
| 33 net::NetworkTrafficAnnotationTag GetNetworkTrafficAnnotation( | |
| 34 const autofill::AutofillDownloadManager::RequestType& request_type) { | |
| 35 if (request_type == autofill::AutofillDownloadManager::REQUEST_QUERY) { | |
| 36 return net::DefineNetworkTrafficAnnotation("autofill_query", R"( | |
| 37 semantics { | |
| 38 sender: "Autofill" | |
| 39 description: | |
| 40 "Chromium can automatically fill in web forms. If the feature is " | |
| 41 "enabled, Chromium will send a non-identifying description of the " | |
| 42 "form to Google's servers, which will respond with the type of " | |
| 43 "data required by each of the form's fields, if known. I.e., if a " | |
| 44 "field expects to receive a name, phone number, street address, " | |
| 45 "etc." | |
| 46 trigger: "User encounters a web form." | |
| 47 data: | |
| 48 "Hashed descriptions of the form, its fields, and action. User data" | |
|
Roger McFarlane (Chromium)
2017/03/15 20:58:30
nit: maybe shorten to "Hashed descriptions of the
Ramin Halavati
2017/03/16 08:57:50
Done.
| |
| 49 "is not sent." | |
| 50 destination: GOOGLE_OWNED_SERVICE | |
| 51 } | |
| 52 policy { | |
| 53 cookies_allowed: false | |
| 54 setting: | |
| 55 "You can enable or disable this feature via 'Enable autofill to " | |
| 56 "fill out web forms in a single click.' in Chromium's settings " | |
| 57 "under 'Passwords and forms'. The feature is enabled by default." | |
| 58 chrome_policy { | |
| 59 AutofillEnabled { | |
| 60 policy_options {mode: MANDATORY} | |
| 61 AutofillEnabled: false | |
| 62 } | |
| 63 } | |
| 64 })"); | |
| 65 } else { | |
|
Roger McFarlane (Chromium)
2017/03/15 20:58:30
nit: no need to indent in an else as the if case e
Ramin Halavati
2017/03/16 08:57:50
Done.
| |
| 66 DCHECK_EQ(request_type, autofill::AutofillDownloadManager::REQUEST_UPLOAD); | |
| 67 return net::DefineNetworkTrafficAnnotation("autofill_upload", R"( | |
| 68 semantics { | |
| 69 sender: "Autofill" | |
| 70 description: | |
| 71 "Chromium relies on crowd-sourced field type classifications to " | |
| 72 "help it automatically fill in web forms. If the feature is " | |
| 73 "enabled, Chromium will send a non-identifying description of the " | |
| 74 "form to Google's servers along with the type of data Chromium " | |
| 75 "observed being given to the form. I.e., if you entered your first " | |
| 76 "name into a form field, Chromium will 'vote' for that form field " | |
| 77 "being a first name field." | |
| 78 trigger: "User submits a web form." | |
| 79 data: | |
| 80 "Hashed descriptions of the form and its fields along with type of " | |
| 81 "data given to each field, if recognized from the user's " | |
| 82 "profile(s). User data is not sent." | |
| 83 destination: GOOGLE_OWNED_SERVICE | |
| 84 } | |
| 85 policy { | |
| 86 cookies_allowed: false | |
| 87 setting: | |
| 88 "You can enable or disable this feature via 'Enable autofill to " | |
| 89 "fill out web forms in a single click.' in Chromium's settings " | |
| 90 "under 'Passwords and forms'. The feature is enabled by default." | |
| 91 chrome_policy { | |
| 92 AutofillEnabled { | |
| 93 policy_options {mode: MANDATORY} | |
| 94 AutofillEnabled: false | |
| 95 } | |
| 96 } | |
| 97 })"); | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 } // namespace | |
| 102 | |
| 30 namespace autofill { | 103 namespace autofill { |
| 31 | 104 |
| 32 namespace { | 105 namespace { |
| 33 | 106 |
| 34 const size_t kMaxFormCacheSize = 16; | 107 const size_t kMaxFormCacheSize = 16; |
| 35 const size_t kMaxFieldsPerQueryRequest = 100; | 108 const size_t kMaxFieldsPerQueryRequest = 100; |
| 36 | 109 |
| 37 const net::BackoffEntry::Policy kAutofillBackoffPolicy = { | 110 const net::BackoffEntry::Policy kAutofillBackoffPolicy = { |
| 38 // Number of initial errors (in sequence) to ignore before applying | 111 // Number of initial errors (in sequence) to ignore before applying |
| 39 // exponential back-off rules. | 112 // exponential back-off rules. |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 bool AutofillDownloadManager::StartRequest( | 300 bool AutofillDownloadManager::StartRequest( |
| 228 const FormRequestData& request_data) { | 301 const FormRequestData& request_data) { |
| 229 net::URLRequestContextGetter* request_context = | 302 net::URLRequestContextGetter* request_context = |
| 230 driver_->GetURLRequestContext(); | 303 driver_->GetURLRequestContext(); |
| 231 DCHECK(request_context); | 304 DCHECK(request_context); |
| 232 GURL request_url = GetRequestUrl(request_data.request_type); | 305 GURL request_url = GetRequestUrl(request_data.request_type); |
| 233 | 306 |
| 234 // Id is ignored for regular chrome, in unit test id's for fake fetcher | 307 // Id is ignored for regular chrome, in unit test id's for fake fetcher |
| 235 // factory will be 0, 1, 2, ... | 308 // factory will be 0, 1, 2, ... |
| 236 std::unique_ptr<net::URLFetcher> owned_fetcher = net::URLFetcher::Create( | 309 std::unique_ptr<net::URLFetcher> owned_fetcher = net::URLFetcher::Create( |
| 237 fetcher_id_for_unittest_++, request_url, net::URLFetcher::POST, this); | 310 fetcher_id_for_unittest_++, request_url, net::URLFetcher::POST, this, |
| 311 GetNetworkTrafficAnnotation(request_data.request_type)); | |
| 238 net::URLFetcher* fetcher = owned_fetcher.get(); | 312 net::URLFetcher* fetcher = owned_fetcher.get(); |
| 239 data_use_measurement::DataUseUserData::AttachToFetcher( | 313 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 240 fetcher, data_use_measurement::DataUseUserData::AUTOFILL); | 314 fetcher, data_use_measurement::DataUseUserData::AUTOFILL); |
| 241 url_fetchers_[fetcher] = | 315 url_fetchers_[fetcher] = |
| 242 std::make_pair(std::move(owned_fetcher), request_data); | 316 std::make_pair(std::move(owned_fetcher), request_data); |
| 243 fetcher->SetAutomaticallyRetryOn5xx(false); | 317 fetcher->SetAutomaticallyRetryOn5xx(false); |
| 244 fetcher->SetRequestContext(request_context); | 318 fetcher->SetRequestContext(request_context); |
| 245 fetcher->SetUploadData("text/proto", request_data.payload); | 319 fetcher->SetUploadData("text/proto", request_data.payload); |
| 246 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | | 320 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES | |
| 247 net::LOAD_DO_NOT_SEND_COOKIES); | 321 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); | 424 it->second.second.form_signatures); |
| 351 } else { | 425 } else { |
| 352 VLOG(1) << "AutofillDownloadManager: upload request has succeeded."; | 426 VLOG(1) << "AutofillDownloadManager: upload request has succeeded."; |
| 353 observer_->OnUploadedPossibleFieldTypes(); | 427 observer_->OnUploadedPossibleFieldTypes(); |
| 354 } | 428 } |
| 355 } | 429 } |
| 356 url_fetchers_.erase(it); | 430 url_fetchers_.erase(it); |
| 357 } | 431 } |
| 358 | 432 |
| 359 } // namespace autofill | 433 } // namespace autofill |
| OLD | NEW |