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/log/net_log_with_source.h" |
23 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
| 26 class SkBitmap; |
| 27 |
26 namespace net { | 28 namespace net { |
27 class URLRequestContextGetter; | 29 class URLRequestContextGetter; |
28 } // namespace net | 30 } // namespace net |
29 | 31 |
30 namespace safe_browsing { | 32 namespace safe_browsing { |
31 | 33 |
| 34 class NotificationImageReporter; |
32 class PermissionReporter; | 35 class PermissionReporter; |
33 | 36 |
34 class SafeBrowsingPingManager : public net::URLFetcherDelegate { | 37 class SafeBrowsingPingManager : public net::URLFetcherDelegate { |
35 public: | 38 public: |
36 ~SafeBrowsingPingManager() override; | 39 ~SafeBrowsingPingManager() override; |
37 | 40 |
38 // Create an instance of the safe browsing ping manager. | 41 // Create an instance of the safe browsing ping manager. |
39 static std::unique_ptr<SafeBrowsingPingManager> Create( | 42 static std::unique_ptr<SafeBrowsingPingManager> Create( |
40 net::URLRequestContextGetter* request_context_getter, | 43 net::URLRequestContextGetter* request_context_getter, |
41 const SafeBrowsingProtocolConfig& config); | 44 const SafeBrowsingProtocolConfig& config); |
42 | 45 |
43 // net::URLFetcherDelegate interface. | 46 // net::URLFetcherDelegate interface. |
44 void OnURLFetchComplete(const net::URLFetcher* source) override; | 47 void OnURLFetchComplete(const net::URLFetcher* source) override; |
45 | 48 |
46 // Report to Google when a SafeBrowsing warning is shown to the user. | 49 // Report to Google when a SafeBrowsing warning is shown to the user. |
47 // |hit_report.threat_type| should be one of the types known by | 50 // |hit_report.threat_type| should be one of the types known by |
48 // SafeBrowsingtHitUrl. | 51 // SafeBrowsingtHitUrl. |
49 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); | 52 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); |
50 | 53 |
51 // Users can opt-in on the SafeBrowsing interstitial to send detailed | 54 // Users can opt-in on the SafeBrowsing interstitial to send detailed |
52 // threat reports. |report| is the serialized report. | 55 // threat reports. |report| is the serialized report. |
53 void ReportThreatDetails(const std::string& report); | 56 void ReportThreatDetails(const std::string& report); |
54 | 57 |
55 // Report permission action to SafeBrowsing servers. | 58 // Report permission action to SafeBrowsing servers. |
56 void ReportPermissionAction(const PermissionReportInfo& report_info); | 59 void ReportPermissionAction(const PermissionReportInfo& report_info); |
57 | 60 |
| 61 // Report notification content image to SafeBrowsing CSD server if necessary. |
| 62 void ReportNotificationImage(Profile* profile, |
| 63 const GURL& origin, |
| 64 const SkBitmap& image); |
| 65 |
58 private: | 66 private: |
59 friend class PermissionReporterBrowserTest; | 67 friend class PermissionReporterBrowserTest; |
60 friend class SafeBrowsingPingManagerTest; | 68 friend class SafeBrowsingPingManagerTest; |
61 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, | 69 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
62 TestSafeBrowsingHitUrl); | 70 TestSafeBrowsingHitUrl); |
63 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); | 71 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); |
64 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, | 72 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
65 TestReportThreatDetails); | 73 TestReportThreatDetails); |
66 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, | 74 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
67 TestReportSafeBrowsingHit); | 75 TestReportSafeBrowsingHit); |
(...skipping 27 matching lines...) Expand all Loading... |
95 // sends detaild threat reports for UMA users. | 103 // sends detaild threat reports for UMA users. |
96 std::string url_prefix_; | 104 std::string url_prefix_; |
97 | 105 |
98 // Track outstanding SafeBrowsing report fetchers for clean up. | 106 // Track outstanding SafeBrowsing report fetchers for clean up. |
99 // We add both "hit" and "detail" fetchers in this set. | 107 // We add both "hit" and "detail" fetchers in this set. |
100 Reports safebrowsing_reports_; | 108 Reports safebrowsing_reports_; |
101 | 109 |
102 // Sends reports of permission actions. | 110 // Sends reports of permission actions. |
103 std::unique_ptr<PermissionReporter> permission_reporter_; | 111 std::unique_ptr<PermissionReporter> permission_reporter_; |
104 | 112 |
| 113 // Sends reports of notification content images. |
| 114 scoped_refptr<NotificationImageReporter> notification_image_reporter_; |
| 115 |
105 net::NetLogWithSource net_log_; | 116 net::NetLogWithSource net_log_; |
106 | 117 |
107 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); | 118 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); |
108 }; | 119 }; |
109 | 120 |
110 } // namespace safe_browsing | 121 } // namespace safe_browsing |
111 | 122 |
112 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ | 123 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ |
OLD | NEW |