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

Side by Side Diff: chrome/browser/safe_browsing/download_feedback.cc

Issue 2697193003: Network traffic annotation added to safe_browsing (Closed)
Patch Set: Unittests updated. Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/safe_browsing/download_feedback.h" 5 #include "chrome/browser/safe_browsing/download_feedback.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 ping_request_); 121 ping_request_);
122 DCHECK(r); 122 DCHECK(r);
123 r = report_metadata.mutable_download_response()->ParseFromString( 123 r = report_metadata.mutable_download_response()->ParseFromString(
124 ping_response_); 124 ping_response_);
125 DCHECK(r); 125 DCHECK(r);
126 file_size_ = report_metadata.download_request().length(); 126 file_size_ = report_metadata.download_request().length();
127 127
128 std::string metadata_string; 128 std::string metadata_string;
129 bool ok = report_metadata.SerializeToString(&metadata_string); 129 bool ok = report_metadata.SerializeToString(&metadata_string);
130 DCHECK(ok); 130 DCHECK(ok);
131
132 net::NetworkTrafficAnnotationTag traffic_annotation =
133 net::DefineNetworkTrafficAnnotation("safe_browsing_feedback", R"(
134 semantics {
135 sender: "Safe Browsing Download Protection Feedback"
136 description:
137 "When a user downloads a binary that Safe Browsing declares as "
138 "suspicious, opted-in clients may upload that binary to Safe "
139 "Browsing to improve the classification. This helps protect users "
140 "from malware and unwanted software."
141 trigger:
142 "The browser will upload the binary to Google when a "
143 "download-protection verdict is 'Not Safe', and the user is opted "
144 "in to extended-reporting."
145 data:
146 "The suspicious binary file."
147 destination: GOOGLE_OWNED_SERVICE
148 }
149 policy {
150 cookies_allowed: true
151 cookies_store: "Safe Browsing Cookie Store"
152 setting:
153 "Users can enable or disable this feature by stopping sending "
154 "security incident reports to Google via disabling 'Automatically "
155 "report details of possible security incdients to Google.' in "
Nathan Parker 2017/03/06 17:48:54 spelling: incidents
Ramin Halavati 2017/03/07 08:24:47 Done.
156 "Chrome's settings under Advanced Settings, Privacy. The feature "
157 "is enabled by default."
Nathan Parker 2017/03/06 17:48:54 should be: "is disabled by default"
Ramin Halavati 2017/03/07 08:24:47 Done.
158 policy {
159 SafeBrowsingExtendedReportingOptInAllowed {
160 policy_options {mode: MANDATORY}
161 value: false
162 }
163 }
164 })");
165
131 uploader_ = TwoPhaseUploader::Create( 166 uploader_ = TwoPhaseUploader::Create(
132 request_context_getter_.get(), file_task_runner_.get(), 167 request_context_getter_.get(), file_task_runner_.get(),
133 GURL(kSbFeedbackURL), metadata_string, file_path_, 168 GURL(kSbFeedbackURL), metadata_string, file_path_,
134 TwoPhaseUploader::ProgressCallback(), 169 TwoPhaseUploader::ProgressCallback(),
135 base::Bind(&DownloadFeedbackImpl::FinishedUpload, base::Unretained(this), 170 base::Bind(&DownloadFeedbackImpl::FinishedUpload, base::Unretained(this),
136 finish_callback)); 171 finish_callback),
172 traffic_annotation);
137 uploader_->Start(); 173 uploader_->Start();
138 } 174 }
139 175
140 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback, 176 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback,
141 TwoPhaseUploader::State state, 177 TwoPhaseUploader::State state,
142 int net_error, 178 int net_error,
143 int response_code, 179 int response_code,
144 const std::string& response_data) { 180 const std::string& response_data) {
145 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 181 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
146 DVLOG(1) << __func__ << " " << state << " rlen=" << response_data.size(); 182 DVLOG(1) << __func__ << " " << state << " rlen=" << response_data.size();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 new DownloadFeedbackImpl(request_context_getter, file_task_runner, 247 new DownloadFeedbackImpl(request_context_getter, file_task_runner,
212 file_path, ping_request, ping_response)); 248 file_path, ping_request, ping_response));
213 } 249 }
214 return DownloadFeedback::factory_->CreateDownloadFeedback( 250 return DownloadFeedback::factory_->CreateDownloadFeedback(
215 request_context_getter, file_task_runner, file_path, ping_request, 251 request_context_getter, file_task_runner, file_path, ping_request,
216 ping_response); 252 ping_response);
217 } 253 }
218 254
219 } // namespace safe_browsing 255 } // namespace safe_browsing
220 256
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698