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

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: Created 3 years, 8 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 "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.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 LoginReputationClientRequest::TriggerType type, 23 LoginReputationClientRequest::TriggerType type,
23 bool is_extended_reporting, 24 bool is_extended_reporting,
24 bool is_incognito, 25 bool is_incognito,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 password_protection_service_->GetStoredVerdictCount()); 103 password_protection_service_->GetStoredVerdictCount());
103 104
104 std::string serialized_request; 105 std::string serialized_request;
105 if (!request.SerializeToString(&serialized_request)) { 106 if (!request.SerializeToString(&serialized_request)) {
106 Finish(RequestOutcome::REQUEST_MALFORMED, nullptr); 107 Finish(RequestOutcome::REQUEST_MALFORMED, nullptr);
107 return; 108 return;
108 } 109 }
109 110
110 // In case the request take too long, we set a timer to cancel this request. 111 // In case the request take too long, we set a timer to cancel this request.
111 StartTimeout(); 112 StartTimeout();
112 113 net::NetworkTrafficAnnotationTag traffic_annotation =
114 net::DefineNetworkTrafficAnnotation("...", R"(
115 semantics {
116 sender: "..."
Nathan Parker 2017/04/14 21:39:38 Sender: Safe Browsing desc: When the user is about
Ramin Halavati 2017/04/18 08:52:53 Done.
117 description: "..."
118 trigger: "..."
119 data: "..."
120 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER
121 }
122 policy {
123 cookies_allowed: false/true
124 cookies_store: "..."
125 setting: "..."
126 chrome_policy {
127 [POLICY_NAME] {
128 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
129 [POLICY_NAME]: ... //(value to disable it)
130 }
131 }
132 policy_exception_justification: "..."
Nathan Parker 2017/04/14 21:39:38 User can turn off Safe Browsing.
Ramin Halavati 2017/04/18 08:52:53 Done.
133 })");
113 fetcher_ = net::URLFetcher::Create( 134 fetcher_ = net::URLFetcher::Create(
114 0, PasswordProtectionService::GetPasswordProtectionRequestUrl(), 135 0, PasswordProtectionService::GetPasswordProtectionRequestUrl(),
115 net::URLFetcher::POST, this); 136 net::URLFetcher::POST, this, traffic_annotation);
116 data_use_measurement::DataUseUserData::AttachToFetcher( 137 data_use_measurement::DataUseUserData::AttachToFetcher(
117 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING); 138 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING);
118 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); 139 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
119 fetcher_->SetAutomaticallyRetryOn5xx(false); 140 fetcher_->SetAutomaticallyRetryOn5xx(false);
120 fetcher_->SetRequestContext( 141 fetcher_->SetRequestContext(
121 password_protection_service_->request_context_getter().get()); 142 password_protection_service_->request_context_getter().get());
122 fetcher_->SetUploadData("application/octet-stream", serialized_request); 143 fetcher_->SetUploadData("application/octet-stream", serialized_request);
123 request_start_time_ = base::TimeTicks::Now(); 144 request_start_time_ = base::TimeTicks::Now();
124 fetcher_->Start(); 145 fetcher_->Start();
125 } 146 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 221 }
201 222
202 void PasswordProtectionRequest::Cancel(bool timed_out) { 223 void PasswordProtectionRequest::Cancel(bool timed_out) {
203 DCHECK_CURRENTLY_ON(BrowserThread::UI); 224 DCHECK_CURRENTLY_ON(BrowserThread::UI);
204 fetcher_.reset(); 225 fetcher_.reset();
205 226
206 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr); 227 Finish(timed_out ? TIMEDOUT : CANCELED, nullptr);
207 } 228 }
208 229
209 } // namespace safe_browsing 230 } // 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