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

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

Issue 2145373002: Revert of Add hooks to permission layer for permission action reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permission-reporter-implementation
Patch Set: Created 4 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PING_MANAGER_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_
7 7
8 // A class that reports safebrowsing statistics to Google's SafeBrowsing 8 // A class that reports safebrowsing statistics to Google's SafeBrowsing
9 // servers. 9 // servers.
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "chrome/browser/permissions/permission_uma_util.h"
18 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" 17 #include "chrome/browser/safe_browsing/protocol_manager_helper.h"
19 #include "components/safe_browsing_db/hit_report.h" 18 #include "components/safe_browsing_db/hit_report.h"
20 #include "components/safe_browsing_db/util.h" 19 #include "components/safe_browsing_db/util.h"
21 #include "content/public/browser/permission_type.h"
22 #include "net/url_request/url_fetcher_delegate.h" 20 #include "net/url_request/url_fetcher_delegate.h"
23 #include "url/gurl.h" 21 #include "url/gurl.h"
24 22
25 namespace certificate_reporting { 23 namespace certificate_reporting {
26 class ErrorReporter; 24 class ErrorReporter;
27 } 25 }
28 26
29 namespace net { 27 namespace net {
30 class SSLInfo; 28 class SSLInfo;
31 class URLRequestContextGetter; 29 class URLRequestContextGetter;
32 } // namespace net 30 } // namespace net
33 31
34 namespace safe_browsing { 32 namespace safe_browsing {
35 33
36 class PermissionReporter;
37
38 class SafeBrowsingPingManager : public net::URLFetcherDelegate { 34 class SafeBrowsingPingManager : public net::URLFetcherDelegate {
39 public: 35 public:
40 ~SafeBrowsingPingManager() override; 36 ~SafeBrowsingPingManager() override;
41 37
42 // Create an instance of the safe browsing ping manager. 38 // Create an instance of the safe browsing ping manager.
43 static SafeBrowsingPingManager* Create( 39 static SafeBrowsingPingManager* Create(
44 net::URLRequestContextGetter* request_context_getter, 40 net::URLRequestContextGetter* request_context_getter,
45 const SafeBrowsingProtocolConfig& config); 41 const SafeBrowsingProtocolConfig& config);
46 42
47 // net::URLFetcherDelegate interface. 43 // net::URLFetcherDelegate interface.
48 void OnURLFetchComplete(const net::URLFetcher* source) override; 44 void OnURLFetchComplete(const net::URLFetcher* source) override;
49 45
50 // Report to Google when a SafeBrowsing warning is shown to the user. 46 // Report to Google when a SafeBrowsing warning is shown to the user.
51 // |hit_report.threat_type| should be one of the types known by 47 // |hit_report.threat_type| should be one of the types known by
52 // SafeBrowsingtHitUrl. 48 // SafeBrowsingtHitUrl.
53 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); 49 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report);
54 50
55 // Users can opt-in on the SafeBrowsing interstitial to send detailed 51 // Users can opt-in on the SafeBrowsing interstitial to send detailed
56 // threat reports. |report| is the serialized report. 52 // threat reports. |report| is the serialized report.
57 void ReportThreatDetails(const std::string& report); 53 void ReportThreatDetails(const std::string& report);
58 54
59 // Users can opt-in on the SSL interstitial to send reports of invalid 55 // Users can opt-in on the SSL interstitial to send reports of invalid
60 // certificate chains. 56 // certificate chains.
61 void ReportInvalidCertificateChain(const std::string& serialized_report); 57 void ReportInvalidCertificateChain(const std::string& serialized_report);
62 58
63 void SetCertificateErrorReporterForTesting( 59 void SetCertificateErrorReporterForTesting(
64 std::unique_ptr<certificate_reporting::ErrorReporter> 60 std::unique_ptr<certificate_reporting::ErrorReporter>
65 certificate_error_reporter); 61 certificate_error_reporter);
66 62
67 // Report permission action to SafeBrowsing servers.
68 void ReportPermissionAction(const GURL& origin,
69 content::PermissionType permission,
70 PermissionAction action);
71
72 private: 63 private:
73 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, 64 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest,
74 TestSafeBrowsingHitUrl); 65 TestSafeBrowsingHitUrl);
75 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); 66 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl);
76 67
77 typedef std::set<const net::URLFetcher*> Reports; 68 typedef std::set<const net::URLFetcher*> Reports;
78 69
79 // Constructs a SafeBrowsingPingManager that issues network requests 70 // Constructs a SafeBrowsingPingManager that issues network requests
80 // using |request_context_getter|. 71 // using |request_context_getter|.
81 SafeBrowsingPingManager( 72 SafeBrowsingPingManager(
(...skipping 20 matching lines...) Expand all
102 std::string url_prefix_; 93 std::string url_prefix_;
103 94
104 // Track outstanding SafeBrowsing report fetchers for clean up. 95 // Track outstanding SafeBrowsing report fetchers for clean up.
105 // We add both "hit" and "detail" fetchers in this set. 96 // We add both "hit" and "detail" fetchers in this set.
106 Reports safebrowsing_reports_; 97 Reports safebrowsing_reports_;
107 98
108 // Sends reports of invalid SSL certificate chains. 99 // Sends reports of invalid SSL certificate chains.
109 std::unique_ptr<certificate_reporting::ErrorReporter> 100 std::unique_ptr<certificate_reporting::ErrorReporter>
110 certificate_error_reporter_; 101 certificate_error_reporter_;
111 102
112 // Sends reports of permission actions.
113 std::unique_ptr<PermissionReporter> permission_reporter_;
114
115 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); 103 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager);
116 }; 104 };
117 105
118 } // namespace safe_browsing 106 } // namespace safe_browsing
119 107
120 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ 108 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_permission_context.cc ('k') | chrome/browser/safe_browsing/ping_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698