OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "chrome/browser/permissions/permission_uma_util.h" |
| 11 #include "url/gurl.h" |
| 12 |
| 13 namespace net { |
| 14 class URLRequestContext; |
| 15 } // namespace net |
| 16 |
| 17 namespace safe_browsing { |
| 18 |
| 19 // Provides functionality for building and serializing reports about permissions |
| 20 // to a report collection server. |
| 21 class PermissionReporter { |
| 22 public: |
| 23 // Creates a permission reporter that will send permission reports to |
| 24 // the SafeBrowsing permission action server, using |request_context| as the |
| 25 // context for the reports. |
| 26 explicit PermissionReporter(net::URLRequestContext* request_context); |
| 27 |
| 28 ~PermissionReporter(); |
| 29 |
| 30 // Sends a serialized permission report to the report collection server. |
| 31 // The permission report includes |origin| as the origin of |
| 32 // the site requesting permission, |permission| as the type of permission |
| 33 // requested, and |action| as the action taken. The report will be serialized |
| 34 // using protobuf defined in |
| 35 // //src/chrome/common/safe_browsing/permission_report.proto |
| 36 void SendReport(const GURL& origin, |
| 37 content::PermissionType permission, |
| 38 PermissionAction action); |
| 39 |
| 40 // Builds and serializes a permission report with |origin| as the origin of |
| 41 // the site requesting permission, |permission| as the type of permission |
| 42 // requested, and |action| as the action taken. The serialized report is |
| 43 // written into |output|. Returns true if the serialization was successful and |
| 44 // false otherwise. |
| 45 static bool BuildReport(const GURL& origin, |
| 46 content::PermissionType permission, |
| 47 PermissionAction action, |
| 48 std::string* output); |
| 49 |
| 50 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); |
| 52 }; |
| 53 |
| 54 } // namespace safe_browsing |
| 55 |
| 56 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
OLD | NEW |