Chromium Code Reviews| 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("...", R"( | |
| 134 semantics { | |
| 135 sender: "..." | |
|
Nathan Parker
2017/02/23 01:16:52
"Safe Browsing Download Protection Feedback"
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 136 description: "..." | |
|
Nathan Parker
2017/02/23 01:16:53
"When a user downloads a binary that Safe Browsing
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 137 trigger: "..." | |
|
Nathan Parker
2017/02/23 01:16:52
"When a download-protection verdict is !SAFE, and
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 138 data: "..." | |
| 139 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 140 } | |
| 141 policy { | |
| 142 cookies_allowed: false/true | |
|
Nathan Parker
2017/02/23 01:16:53
true
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 143 cookies_store: "..." | |
|
Nathan Parker
2017/02/23 01:16:53
Safe Browsing cookie store
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 144 setting: "..." | |
|
Nathan Parker
2017/02/23 01:16:53
I'm not sure where we say that this is enabled by
Ramin Halavati
2017/02/23 08:18:24
Done.
| |
| 145 policy { | |
| 146 [POLICY_NAME] { | |
| 147 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 148 value: ... | |
| 149 } | |
| 150 } | |
| 151 policy_exception_justification: "..." | |
| 152 })"); | |
| 153 | |
| 131 uploader_ = TwoPhaseUploader::Create( | 154 uploader_ = TwoPhaseUploader::Create( |
| 132 request_context_getter_.get(), file_task_runner_.get(), | 155 request_context_getter_.get(), file_task_runner_.get(), |
| 133 GURL(kSbFeedbackURL), metadata_string, file_path_, | 156 GURL(kSbFeedbackURL), metadata_string, file_path_, |
| 134 TwoPhaseUploader::ProgressCallback(), | 157 TwoPhaseUploader::ProgressCallback(), |
| 135 base::Bind(&DownloadFeedbackImpl::FinishedUpload, base::Unretained(this), | 158 base::Bind(&DownloadFeedbackImpl::FinishedUpload, base::Unretained(this), |
| 136 finish_callback)); | 159 finish_callback), |
| 160 traffic_annotation); | |
| 137 uploader_->Start(); | 161 uploader_->Start(); |
| 138 } | 162 } |
| 139 | 163 |
| 140 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback, | 164 void DownloadFeedbackImpl::FinishedUpload(base::Closure finish_callback, |
| 141 TwoPhaseUploader::State state, | 165 TwoPhaseUploader::State state, |
| 142 int net_error, | 166 int net_error, |
| 143 int response_code, | 167 int response_code, |
| 144 const std::string& response_data) { | 168 const std::string& response_data) { |
| 145 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 169 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 146 DVLOG(1) << __func__ << " " << state << " rlen=" << response_data.size(); | 170 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, | 235 new DownloadFeedbackImpl(request_context_getter, file_task_runner, |
| 212 file_path, ping_request, ping_response)); | 236 file_path, ping_request, ping_response)); |
| 213 } | 237 } |
| 214 return DownloadFeedback::factory_->CreateDownloadFeedback( | 238 return DownloadFeedback::factory_->CreateDownloadFeedback( |
| 215 request_context_getter, file_task_runner, file_path, ping_request, | 239 request_context_getter, file_task_runner, file_path, ping_request, |
| 216 ping_response); | 240 ping_response); |
| 217 } | 241 } |
| 218 | 242 |
| 219 } // namespace safe_browsing | 243 } // namespace safe_browsing |
| 220 | 244 |
| OLD | NEW |