OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/permission_reporter.h" | 5 #include "chrome/browser/safe_browsing/permission_reporter.h" |
6 | 6 |
7 #include <functional> | 7 #include <functional> |
8 | 8 |
9 #include "base/hash.h" | 9 #include "base/hash.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 clock_(std::move(clock)) {} | 162 clock_(std::move(clock)) {} |
163 | 163 |
164 PermissionReporter::~PermissionReporter() {} | 164 PermissionReporter::~PermissionReporter() {} |
165 | 165 |
166 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { | 166 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { |
167 if (IsReportThresholdExceeded(report_info.permission, report_info.origin)) | 167 if (IsReportThresholdExceeded(report_info.permission, report_info.origin)) |
168 return; | 168 return; |
169 | 169 |
170 std::string serialized_report; | 170 std::string serialized_report; |
171 BuildReport(report_info, &serialized_report); | 171 BuildReport(report_info, &serialized_report); |
172 permission_report_sender_->Send(GURL(kPermissionActionReportingUploadUrl), | 172 permission_report_sender_->Send( |
173 "application/octet-stream", serialized_report, | 173 GURL(kPermissionActionReportingUploadUrl), "application/octet-stream", |
174 base::Closure(), | 174 serialized_report, base::Callback<void(int)>(), |
175 base::Callback<void(const GURL&, int)>()); | 175 base::Callback<void(const GURL&, int, int)>()); |
176 } | 176 } |
177 | 177 |
178 // static | 178 // static |
179 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, | 179 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, |
180 std::string* output) { | 180 std::string* output) { |
181 PermissionReport report; | 181 PermissionReport report; |
182 report.set_origin(report_info.origin.spec()); | 182 report.set_origin(report_info.origin.spec()); |
183 report.set_permission(PermissionTypeForReport(report_info.permission)); | 183 report.set_permission(PermissionTypeForReport(report_info.permission)); |
184 report.set_action(PermissionActionForReport(report_info.action)); | 184 report.set_action(PermissionActionForReport(report_info.action)); |
185 report.set_source_ui(SourceUIForReport(report_info.source_ui)); | 185 report.set_source_ui(SourceUIForReport(report_info.source_ui)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 222 } |
223 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { | 223 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { |
224 log.push(current_time); | 224 log.push(current_time); |
225 return false; | 225 return false; |
226 } else { | 226 } else { |
227 return true; | 227 return true; |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 } // namespace safe_browsing | 231 } // namespace safe_browsing |
OLD | NEW |