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

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

Issue 2637153002: Submit a sample of notification images to Safe Browsing (Closed)
Patch Set: nits Created 3 years, 11 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" 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 Profile;
27 class SkBitmap;
28
26 namespace net { 29 namespace net {
27 class URLRequestContextGetter; 30 class URLRequestContextGetter;
28 } // namespace net 31 } // namespace net
29 32
30 namespace safe_browsing { 33 namespace safe_browsing {
31 34
35 class NotificationImageReporter;
32 class PermissionReporter; 36 class PermissionReporter;
37 class SafeBrowsingDatabaseManager;
33 38
34 class SafeBrowsingPingManager : public net::URLFetcherDelegate { 39 class SafeBrowsingPingManager : public net::URLFetcherDelegate {
35 public: 40 public:
36 ~SafeBrowsingPingManager() override; 41 ~SafeBrowsingPingManager() override;
37 42
38 // Create an instance of the safe browsing ping manager. 43 // Create an instance of the safe browsing ping manager.
39 static std::unique_ptr<SafeBrowsingPingManager> Create( 44 static std::unique_ptr<SafeBrowsingPingManager> Create(
40 net::URLRequestContextGetter* request_context_getter, 45 net::URLRequestContextGetter* request_context_getter,
41 const SafeBrowsingProtocolConfig& config); 46 const SafeBrowsingProtocolConfig& config);
42 47
43 // net::URLFetcherDelegate interface. 48 // net::URLFetcherDelegate interface.
44 void OnURLFetchComplete(const net::URLFetcher* source) override; 49 void OnURLFetchComplete(const net::URLFetcher* source) override;
45 50
46 // Report to Google when a SafeBrowsing warning is shown to the user. 51 // 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 52 // |hit_report.threat_type| should be one of the types known by
48 // SafeBrowsingtHitUrl. 53 // SafeBrowsingtHitUrl.
49 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); 54 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report);
50 55
51 // Users can opt-in on the SafeBrowsing interstitial to send detailed 56 // Users can opt-in on the SafeBrowsing interstitial to send detailed
52 // threat reports. |report| is the serialized report. 57 // threat reports. |report| is the serialized report.
53 void ReportThreatDetails(const std::string& report); 58 void ReportThreatDetails(const std::string& report);
54 59
55 // Report permission action to SafeBrowsing servers. 60 // Report permission action to SafeBrowsing servers.
56 void ReportPermissionAction(const PermissionReportInfo& report_info); 61 void ReportPermissionAction(const PermissionReportInfo& report_info);
57 62
63 // Report notification content image to SafeBrowsing CSD server if necessary.
64 void ReportNotificationImage(
65 Profile* profile,
66 const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager,
67 const GURL& origin,
68 const SkBitmap& image);
69
58 private: 70 private:
71 friend class NotificationImageReporterTest;
59 friend class PermissionReporterBrowserTest; 72 friend class PermissionReporterBrowserTest;
60 friend class SafeBrowsingPingManagerTest; 73 friend class SafeBrowsingPingManagerTest;
61 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, 74 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest,
62 TestSafeBrowsingHitUrl); 75 TestSafeBrowsingHitUrl);
63 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); 76 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl);
64 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, 77 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest,
65 TestReportThreatDetails); 78 TestReportThreatDetails);
66 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, 79 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest,
67 TestReportSafeBrowsingHit); 80 TestReportSafeBrowsingHit);
68 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerCertReportingTest, 81 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerCertReportingTest,
(...skipping 26 matching lines...) Expand all
95 // sends detaild threat reports for UMA users. 108 // sends detaild threat reports for UMA users.
96 std::string url_prefix_; 109 std::string url_prefix_;
97 110
98 // Track outstanding SafeBrowsing report fetchers for clean up. 111 // Track outstanding SafeBrowsing report fetchers for clean up.
99 // We add both "hit" and "detail" fetchers in this set. 112 // We add both "hit" and "detail" fetchers in this set.
100 Reports safebrowsing_reports_; 113 Reports safebrowsing_reports_;
101 114
102 // Sends reports of permission actions. 115 // Sends reports of permission actions.
103 std::unique_ptr<PermissionReporter> permission_reporter_; 116 std::unique_ptr<PermissionReporter> permission_reporter_;
104 117
118 // Sends reports of notification content images.
119 std::unique_ptr<NotificationImageReporter> notification_image_reporter_;
120
105 net::NetLogWithSource net_log_; 121 net::NetLogWithSource net_log_;
106 122
107 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); 123 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager);
108 }; 124 };
109 125
110 } // namespace safe_browsing 126 } // namespace safe_browsing
111 127
112 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ 128 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/notification_image_reporter_unittest.cc ('k') | chrome/browser/safe_browsing/ping_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698