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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/permissions/permission_uma_util.h" | 10 #include "chrome/browser/permissions/permission_uma_util.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // Creates a permission reporter that will send permission reports to | 24 // Creates a permission reporter that will send permission reports to |
25 // the SafeBrowsing permission action server, using |request_context| as the | 25 // the SafeBrowsing permission action server, using |request_context| as the |
26 // context for the reports. | 26 // context for the reports. |
27 explicit PermissionReporter(net::URLRequestContext* request_context); | 27 explicit PermissionReporter(net::URLRequestContext* request_context); |
28 | 28 |
29 ~PermissionReporter(); | 29 ~PermissionReporter(); |
30 | 30 |
31 // Sends a serialized permission report to the report collection server. | 31 // Sends a serialized permission report to the report collection server. |
32 // The permission report includes |origin| as the origin of | 32 // The permission report includes |origin| as the origin of |
33 // the site requesting permission, |permission| as the type of permission | 33 // the site requesting permission, |permission| as the type of permission |
34 // requested, and |action| as the action taken. The report will be serialized | 34 // requested, |action| as the action taken, and request trigger when |
| 35 // |user_gesture| is enabled. The report will be serialized |
35 // using protobuf defined in | 36 // using protobuf defined in |
36 // //src/chrome/common/safe_browsing/permission_report.proto | 37 // //src/chrome/common/safe_browsing/permission_report.proto |
37 void SendReport(const GURL& origin, | 38 void SendReport(const GURL& origin, |
38 content::PermissionType permission, | 39 content::PermissionType permission, |
39 PermissionAction action, | 40 PermissionAction action, |
40 PermissionSourceUI source_ui); | 41 PermissionSourceUI source_ui, |
| 42 bool user_gesture); |
41 | 43 |
42 private: | 44 private: |
43 friend class PermissionReporterTest; | 45 friend class PermissionReporterTest; |
44 | 46 |
45 // Used by tests. This constructor allows tests to have access to the | 47 // Used by tests. This constructor allows tests to have access to the |
46 // ReportSender. | 48 // ReportSender. |
47 explicit PermissionReporter(std::unique_ptr<net::ReportSender> report_sender); | 49 explicit PermissionReporter(std::unique_ptr<net::ReportSender> report_sender); |
48 | 50 |
49 // Builds and serializes a permission report with |origin| as the origin of | 51 // Builds and serializes a permission report with |origin| as the origin of |
50 // the site requesting permission, |permission| as the type of permission | 52 // the site requesting permission, |permission| as the type of permission |
51 // requested, and |action| as the action taken. The serialized report is | 53 // requested, and |action| as the action taken. The serialized report is |
52 // written into |output|. Returns true if the serialization was successful and | 54 // written into |output|. Returns true if the serialization was successful and |
53 // false otherwise. | 55 // false otherwise. |
54 static bool BuildReport(const GURL& origin, | 56 static bool BuildReport(const GURL& origin, |
55 content::PermissionType permission, | 57 content::PermissionType permission, |
56 PermissionAction action, | 58 PermissionAction action, |
57 PermissionSourceUI source_ui, | 59 PermissionSourceUI source_ui, |
| 60 bool user_gesture, |
58 std::string* output); | 61 std::string* output); |
59 | 62 |
60 std::unique_ptr<net::ReportSender> permission_report_sender_; | 63 std::unique_ptr<net::ReportSender> permission_report_sender_; |
61 | 64 |
62 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); | 65 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); |
63 }; | 66 }; |
64 | 67 |
65 } // namespace safe_browsing | 68 } // namespace safe_browsing |
66 | 69 |
67 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ | 70 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ |
OLD | NEW |