Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/safe_browsing/permission_reporter.h

Issue 2035753004: Add implementation of PermissionReporter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor-certificate-report-sender
Patch Set: Fix small mistakes Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace net { 13 namespace net {
14 class ReportSender;
14 class URLRequestContext; 15 class URLRequestContext;
15 } // namespace net 16 } // namespace net
16 17
17 namespace safe_browsing { 18 namespace safe_browsing {
18 19
19 // Provides functionality for building and serializing reports about permissions 20 // Provides functionality for building and serializing reports about permissions
20 // to a report collection server. 21 // to a report collection server.
21 class PermissionReporter { 22 class PermissionReporter {
22 public: 23 public:
23 // Creates a permission reporter that will send permission reports to 24 // Creates a permission reporter that will send permission reports to
24 // the SafeBrowsing permission action server, using |request_context| as the 25 // the SafeBrowsing permission action server, using |request_context| as the
25 // context for the reports. 26 // context for the reports.
26 explicit PermissionReporter(net::URLRequestContext* request_context); 27 explicit PermissionReporter(net::URLRequestContext* request_context);
27 28
29 // Used by tests. This constructor allows tests to have access to the
30 // ReportSender.
31 explicit PermissionReporter(std::unique_ptr<net::ReportSender> report_sender);
raymes 2016/06/09 01:30:40 We might as well make this private and make the te
stefanocs 2016/06/09 05:56:11 Done.
32
28 ~PermissionReporter(); 33 ~PermissionReporter();
29 34
30 // Sends a serialized permission report to the report collection server. 35 // Sends a serialized permission report to the report collection server.
31 // The permission report includes |origin| as the origin of 36 // The permission report includes |origin| as the origin of
32 // the site requesting permission, |permission| as the type of permission 37 // the site requesting permission, |permission| as the type of permission
33 // requested, and |action| as the action taken. The report will be serialized 38 // requested, and |action| as the action taken. The report will be serialized
34 // using protobuf defined in 39 // using protobuf defined in
35 // //src/chrome/common/safe_browsing/permission_report.proto 40 // //src/chrome/common/safe_browsing/permission_report.proto
36 void SendReport(const GURL& origin, 41 void SendReport(const GURL& origin,
37 content::PermissionType permission, 42 content::PermissionType permission,
38 PermissionAction action); 43 PermissionAction action);
39 44
40 // Builds and serializes a permission report with |origin| as the origin of 45 // Builds and serializes a permission report with |origin| as the origin of
41 // the site requesting permission, |permission| as the type of permission 46 // the site requesting permission, |permission| as the type of permission
42 // requested, and |action| as the action taken. The serialized report is 47 // requested, and |action| as the action taken. The serialized report is
43 // written into |output|. Returns true if the serialization was successful and 48 // written into |output|. Returns true if the serialization was successful and
44 // false otherwise. 49 // false otherwise.
45 static bool BuildReport(const GURL& origin, 50 static bool BuildReport(const GURL& origin,
raymes 2016/06/09 01:30:41 Can this be private?
stefanocs 2016/06/09 05:56:11 Done.
46 content::PermissionType permission, 51 content::PermissionType permission,
47 PermissionAction action, 52 PermissionAction action,
48 std::string* output); 53 std::string* output);
49 54
50 private: 55 private:
56 std::unique_ptr<net::ReportSender> permission_report_sender_;
57
51 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); 58 DISALLOW_COPY_AND_ASSIGN(PermissionReporter);
52 }; 59 };
53 60
54 } // namespace safe_browsing 61 } // namespace safe_browsing
55 62
56 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ 63 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698