OLD | NEW |
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 Loading... |
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 incidents to Google.' in " |
| 156 "Chrome's settings under Advanced Settings, Privacy. The feature " |
| 157 "is disabled by default." |
| 158 chrome_policy { |
| 159 SafeBrowsingExtendedReportingOptInAllowed { |
| 160 policy_options {mode: MANDATORY} |
| 161 SafeBrowsingExtendedReportingOptInAllowed: 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 Loading... |
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 |
OLD | NEW |