| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 PermissionReporter::~PermissionReporter() {} | 162 PermissionReporter::~PermissionReporter() {} |
| 163 | 163 |
| 164 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { | 164 void PermissionReporter::SendReport(const PermissionReportInfo& report_info) { |
| 165 if (IsReportThresholdExceeded(report_info.permission, report_info.origin)) | 165 if (IsReportThresholdExceeded(report_info.permission, report_info.origin)) |
| 166 return; | 166 return; |
| 167 | 167 |
| 168 std::string serialized_report; | 168 std::string serialized_report; |
| 169 BuildReport(report_info, &serialized_report); | 169 BuildReport(report_info, &serialized_report); |
| 170 permission_report_sender_->Send(GURL(kPermissionActionReportingUploadUrl), | 170 permission_report_sender_->Send(GURL(kPermissionActionReportingUploadUrl), |
| 171 "application/octet-stream", |
| 171 serialized_report); | 172 serialized_report); |
| 172 } | 173 } |
| 173 | 174 |
| 174 // static | 175 // static |
| 175 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, | 176 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, |
| 176 std::string* output) { | 177 std::string* output) { |
| 177 PermissionReport report; | 178 PermissionReport report; |
| 178 report.set_origin(report_info.origin.spec()); | 179 report.set_origin(report_info.origin.spec()); |
| 179 report.set_permission(PermissionTypeForReport(report_info.permission)); | 180 report.set_permission(PermissionTypeForReport(report_info.permission)); |
| 180 report.set_action(PermissionActionForReport(report_info.action)); | 181 report.set_action(PermissionActionForReport(report_info.action)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 219 } |
| 219 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { | 220 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { |
| 220 log.push(current_time); | 221 log.push(current_time); |
| 221 return false; | 222 return false; |
| 222 } else { | 223 } else { |
| 223 return true; | 224 return true; |
| 224 } | 225 } |
| 225 } | 226 } |
| 226 | 227 |
| 227 } // namespace safe_browsing | 228 } // namespace safe_browsing |
| OLD | NEW |