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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(GURL(kPermissionActionReportingUploadUrl), |
| 173 "application/octet-stream", |
173 serialized_report); | 174 serialized_report); |
174 } | 175 } |
175 | 176 |
176 // static | 177 // static |
177 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, | 178 bool PermissionReporter::BuildReport(const PermissionReportInfo& report_info, |
178 std::string* output) { | 179 std::string* output) { |
179 PermissionReport report; | 180 PermissionReport report; |
180 report.set_origin(report_info.origin.spec()); | 181 report.set_origin(report_info.origin.spec()); |
181 report.set_permission(PermissionTypeForReport(report_info.permission)); | 182 report.set_permission(PermissionTypeForReport(report_info.permission)); |
182 report.set_action(PermissionActionForReport(report_info.action)); | 183 report.set_action(PermissionActionForReport(report_info.action)); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 221 } |
221 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { | 222 if (log.size() < kMaximumReportsPerOriginPerPermissionPerMinute) { |
222 log.push(current_time); | 223 log.push(current_time); |
223 return false; | 224 return false; |
224 } else { | 225 } else { |
225 return true; | 226 return true; |
226 } | 227 } |
227 } | 228 } |
228 | 229 |
229 } // namespace safe_browsing | 230 } // namespace safe_browsing |
OLD | NEW |