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 "net/url_request/certificate_report_sender.h" | |
12 #include "url/gurl.h" | |
13 | |
14 namespace net { | |
15 class URLRequestContext; | |
16 } // namespace net | |
17 | |
18 namespace safe_browsing { | |
19 | |
20 // Provides functionality for building and serializing reports about permissions | |
21 // to a report collection server. | |
22 class PermissionReporter { | |
23 public: | |
24 // Creates a permission reporter that will send permission reports to | |
25 // |upload_url|, using |request_context| as the context for the reports. | |
26 PermissionReporter(net::URLRequestContext* request_context, | |
27 const GURL& upload_url); | |
28 | |
29 ~PermissionReporter(); | |
30 | |
31 // Sends a permission report to the report collection server. The | |
32 // |serialized_report| is expected to be a serialized protobuf of type | |
33 // PermissionReport defined in | |
34 // //src/chrome/common/safe_browsing/permission_report.proto | |
35 void SendReport(const std::string& serialized_report); | |
36 | |
37 // Builds and serializes a permission report with |origin| as the origin of | |
38 // the site requesting permission, |permission| as the type of permission | |
39 // requested, and |action| as the action taken. The serialized report is | |
40 // written into |output|. Returns true if the serialization was successful and | |
41 // false otherwise. | |
42 static bool BuildReport(const GURL& origin, | |
43 content::PermissionType permission, | |
44 PermissionAction action, | |
45 std::string* output); | |
46 | |
47 private: | |
48 std::unique_ptr<net::CertificateReportSender> permission_report_sender_; | |
Nathan Parker
2016/05/31 22:24:57
I think we should do some refactoring before than
stefanocs
2016/06/01 01:36:34
Done.
| |
49 | |
50 const GURL upload_url_; | |
51 | |
52 DISALLOW_COPY_AND_ASSIGN(PermissionReporter); | |
53 }; | |
54 | |
55 } // namespace safe_browsing | |
56 | |
57 #endif // CHROME_BROWSER_SAFE_BROWSING_PERMISSION_REPORTER_H_ | |
OLD | NEW |