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

Side by Side Diff: components/safe_browsing/password_protection/password_protection_request.cc

Issue 2802643002: Network traffic annotation added to password_protection_request (Closed)
Patch Set: Extended reporting added. Created 3 years, 7 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #include "components/safe_browsing/password_protection/password_protection_reque st.h" 4 #include "components/safe_browsing/password_protection/password_protection_reque st.h"
5 5
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "components/data_use_measurement/core/data_use_user_data.h" 9 #include "components/data_use_measurement/core/data_use_user_data.h"
10 #include "components/safe_browsing_db/database_manager.h" 10 #include "components/safe_browsing_db/database_manager.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "net/base/load_flags.h" 12 #include "net/base/load_flags.h"
13 #include "net/base/url_util.h" 13 #include "net/base/url_util.h"
14 #include "net/http/http_status_code.h" 14 #include "net/http/http_status_code.h"
15 #include "net/traffic_annotation/network_traffic_annotation.h"
15 16
16 using content::BrowserThread; 17 using content::BrowserThread;
17 18
18 namespace safe_browsing { 19 namespace safe_browsing {
19 20
20 PasswordProtectionRequest::PasswordProtectionRequest( 21 PasswordProtectionRequest::PasswordProtectionRequest(
21 const GURL& main_frame_url, 22 const GURL& main_frame_url,
22 const GURL& password_form_action, 23 const GURL& password_form_action,
23 const GURL& password_form_frame_url, 24 const GURL& password_form_frame_url,
24 LoginReputationClientRequest::TriggerType type, 25 LoginReputationClientRequest::TriggerType type,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 FillRequestProto(); 120 FillRequestProto();
120 121
121 std::string serialized_request; 122 std::string serialized_request;
122 if (!request_proto_->SerializeToString(&serialized_request)) { 123 if (!request_proto_->SerializeToString(&serialized_request)) {
123 Finish(RequestOutcome::REQUEST_MALFORMED, nullptr); 124 Finish(RequestOutcome::REQUEST_MALFORMED, nullptr);
124 return; 125 return;
125 } 126 }
126 127
127 // In case the request take too long, we set a timer to cancel this request. 128 // In case the request take too long, we set a timer to cancel this request.
128 StartTimeout(); 129 StartTimeout();
129 130 net::NetworkTrafficAnnotationTag traffic_annotation =
131 net::DefineNetworkTrafficAnnotation("password_protection_request", R"(
132 semantics {
133 sender: "Safe Browsing"
134 description:
135 "When the user is about to log in to a new, uncommon site, Chrome "
136 "will send a request to Safe Browsing to determine if the page is "
137 "phishing. It'll then show a warning if the page is bad."
msramek 2017/05/12 19:10:19 nit: "bad" is a subjective term. Maybe "...if the
Jialiu Lin 2017/05/12 19:59:33 Agree, "...if the page poses a risk of phishing."
Ramin Halavati 2017/05/14 13:21:33 Done.
138 trigger:
139 "When the user has opted-in to Safe Browsing extended reporting, "
140 "focuses on a password field on a page that isn't popular or known "
msramek 2017/05/12 19:10:19 nit: I would rephrase a bit for readability. "Whe
Jialiu Lin 2017/05/12 19:59:33 SGTM
Ramin Halavati 2017/05/14 13:21:33 Done.
141 "to be safe, and they haven't visited."
142 data:
143 "URL and referrer of the current page, password form action, and "
144 "iframe structure."
145 destination: GOOGLE_OWNED_SERVICE
146 }
147 policy {
148 cookies_allowed: true
149 cookies_store: "Safe Browsing Cookie Store"
150 setting:
151 "Users can control this feature via 'Protect you and your device "
152 "from dangerous sites' or 'Automatically report details of "
153 "possible security incidents to Google' setting under 'Privacy'. "
msramek 2017/05/12 19:10:19 Do we normally list both SB and SBER as the settin
Jialiu Lin 2017/05/12 19:59:33 SBER condition is temporary, eventually this featu
msramek 2017/05/15 12:57:28 I'm just saying that all SBER features can be disa
Ramin Halavati 2017/05/15 13:37:18 We usually set the most fine grained policy that d
154 "By default, the first setting is enabled and the second is not."
155 chrome_policy {
156 SafeBrowsingEnabled {
157 policy_options {mode: MANDATORY}
158 SafeBrowsingEnabled: false
159 }
160 }
161 chrome_policy {
162 SafeBrowsingExtendedReportingOptInAllowed {
163 policy_options {mode: MANDATORY}
164 SafeBrowsingExtendedReportingOptInAllowed: false
165 }
166 }
167 })");
130 fetcher_ = net::URLFetcher::Create( 168 fetcher_ = net::URLFetcher::Create(
131 0, PasswordProtectionService::GetPasswordProtectionRequestUrl(), 169 0, PasswordProtectionService::GetPasswordProtectionRequestUrl(),
132 net::URLFetcher::POST, this); 170 net::URLFetcher::POST, this, traffic_annotation);
133 data_use_measurement::DataUseUserData::AttachToFetcher( 171 data_use_measurement::DataUseUserData::AttachToFetcher(
134 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING); 172 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING);
135 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 173 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
136 fetcher_->SetAutomaticallyRetryOn5xx(false); 174 fetcher_->SetAutomaticallyRetryOn5xx(false);
137 fetcher_->SetRequestContext( 175 fetcher_->SetRequestContext(
138 password_protection_service_->request_context_getter().get()); 176 password_protection_service_->request_context_getter().get());
139 fetcher_->SetUploadData("application/octet-stream", serialized_request); 177 fetcher_->SetUploadData("application/octet-stream", serialized_request);
140 request_start_time_ = base::TimeTicks::Now(); 178 request_start_time_ = base::TimeTicks::Now();
141 fetcher_->Start(); 179 fetcher_->Start();
142 } 180 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 255 }
218 256
219 void PasswordProtectionRequest::Cancel(bool timed_out) { 257 void PasswordProtectionRequest::Cancel(bool timed_out) {
220 DCHECK_CURRENTLY_ON(BrowserThread::UI); 258 DCHECK_CURRENTLY_ON(BrowserThread::UI);
221 fetcher_.reset(); 259 fetcher_.reset();
222 260
223 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr); 261 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr);
224 } 262 }
225 263
226 } // namespace safe_browsing 264 } // namespace safe_browsing
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