OLD | NEW |
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" | 17 #include "chrome/browser/permissions/permission_uma_util.h" |
18 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" | 18 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" |
19 #include "components/safe_browsing_db/hit_report.h" | 19 #include "components/safe_browsing_db/hit_report.h" |
20 #include "components/safe_browsing_db/util.h" | 20 #include "components/safe_browsing_db/util.h" |
21 #include "content/public/browser/permission_type.h" | 21 #include "content/public/browser/permission_type.h" |
| 22 #include "net/log/net_log_with_source.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace certificate_reporting { | 26 namespace certificate_reporting { |
26 class ErrorReporter; | 27 class ErrorReporter; |
27 } | 28 } |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 class SSLInfo; | 31 class SSLInfo; |
31 class URLRequestContextGetter; | 32 class URLRequestContextGetter; |
(...skipping 30 matching lines...) Expand all Loading... |
62 | 63 |
63 void SetCertificateErrorReporterForTesting( | 64 void SetCertificateErrorReporterForTesting( |
64 std::unique_ptr<certificate_reporting::ErrorReporter> | 65 std::unique_ptr<certificate_reporting::ErrorReporter> |
65 certificate_error_reporter); | 66 certificate_error_reporter); |
66 | 67 |
67 // Report permission action to SafeBrowsing servers. | 68 // Report permission action to SafeBrowsing servers. |
68 void ReportPermissionAction(const PermissionReportInfo& report_info); | 69 void ReportPermissionAction(const PermissionReportInfo& report_info); |
69 | 70 |
70 private: | 71 private: |
71 friend class PermissionReporterBrowserTest; | 72 friend class PermissionReporterBrowserTest; |
| 73 friend class SafeBrowsingPingManagerTest; |
72 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, | 74 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
73 TestSafeBrowsingHitUrl); | 75 TestSafeBrowsingHitUrl); |
74 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); | 76 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); |
| 77 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
| 78 TestReportThreatDetails); |
| 79 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
| 80 TestReportSafeBrowsingHit); |
75 | 81 |
76 typedef std::set<std::unique_ptr<net::URLFetcher>> Reports; | 82 typedef std::set<std::unique_ptr<net::URLFetcher>> Reports; |
77 | 83 |
78 // Constructs a SafeBrowsingPingManager that issues network requests | 84 // Constructs a SafeBrowsingPingManager that issues network requests |
79 // using |request_context_getter|. | 85 // using |request_context_getter|. |
80 SafeBrowsingPingManager( | 86 SafeBrowsingPingManager( |
81 net::URLRequestContextGetter* request_context_getter, | 87 net::URLRequestContextGetter* request_context_getter, |
82 const SafeBrowsingProtocolConfig& config); | 88 const SafeBrowsingProtocolConfig& config); |
83 | 89 |
84 // Generates URL for reporting safe browsing hits. | 90 // Generates URL for reporting safe browsing hits. |
(...skipping 19 matching lines...) Expand all Loading... |
104 // We add both "hit" and "detail" fetchers in this set. | 110 // We add both "hit" and "detail" fetchers in this set. |
105 Reports safebrowsing_reports_; | 111 Reports safebrowsing_reports_; |
106 | 112 |
107 // Sends reports of invalid SSL certificate chains. | 113 // Sends reports of invalid SSL certificate chains. |
108 std::unique_ptr<certificate_reporting::ErrorReporter> | 114 std::unique_ptr<certificate_reporting::ErrorReporter> |
109 certificate_error_reporter_; | 115 certificate_error_reporter_; |
110 | 116 |
111 // Sends reports of permission actions. | 117 // Sends reports of permission actions. |
112 std::unique_ptr<PermissionReporter> permission_reporter_; | 118 std::unique_ptr<PermissionReporter> permission_reporter_; |
113 | 119 |
| 120 net::NetLogWithSource net_log_; |
| 121 |
114 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); | 122 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); |
115 }; | 123 }; |
116 | 124 |
117 } // namespace safe_browsing | 125 } // namespace safe_browsing |
118 | 126 |
119 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ | 127 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ |
OLD | NEW |