Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/autofill/core/browser/autofill_download_manager.cc

Issue 2740213003: Network traffic annotation added to autofill_download_manager. (Closed)
Patch Set: Annotation updated. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 and its fields. User data is not "
49 "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 }
66
67 DCHECK_EQ(request_type, autofill::AutofillDownloadManager::REQUEST_UPLOAD);
68 return net::DefineNetworkTrafficAnnotation("autofill_upload", R"(
69 semantics {
70 sender: "Autofill"
71 description:
72 "Chromium relies on crowd-sourced field type classifications to "
73 "help it automatically fill in web forms. If the feature is "
74 "enabled, Chromium will send a non-identifying description of the "
75 "form to Google's servers along with the type of data Chromium "
76 "observed being given to the form. I.e., if you entered your first "
77 "name into a form field, Chromium will 'vote' for that form field "
78 "being a first name field."
79 trigger: "User submits a web form."
80 data:
81 "Hashed descriptions of the form and its fields along with type of "
82 "data given to each field, if recognized from the user's "
83 "profile(s). User data is not sent."
84 destination: GOOGLE_OWNED_SERVICE
85 }
86 policy {
87 cookies_allowed: false
88 setting:
89 "You can enable or disable this feature via 'Enable autofill to "
90 "fill out web forms in a single click.' in Chromium's settings "
91 "under 'Passwords and forms'. The feature is enabled by default."
92 chrome_policy {
93 AutofillEnabled {
94 policy_options {mode: MANDATORY}
95 AutofillEnabled: false
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698