Chromium Code Reviews| 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/command_line.h" | |
|
raymes
2016/06/16 01:10:22
nit: is this needed here?
stefanocs
2016/06/16 01:52:20
Done.
| |
| 15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "chrome/browser/permissions/permission_uma_util.h" | |
| 19 #include "chrome/browser/profiles/profile_manager.h" | |
| 17 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" | 20 #include "chrome/browser/safe_browsing/protocol_manager_helper.h" |
| 21 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/common/pref_names.h" | |
| 24 #include "components/browser_sync/browser/profile_sync_service.h" | |
| 25 #include "components/prefs/pref_service.h" | |
|
raymes
2016/06/16 01:10:22
Same with most of these?
stefanocs
2016/06/16 01:52:19
Done.
| |
| 18 #include "components/safe_browsing_db/hit_report.h" | 26 #include "components/safe_browsing_db/hit_report.h" |
| 19 #include "components/safe_browsing_db/util.h" | 27 #include "components/safe_browsing_db/util.h" |
| 20 #include "net/url_request/url_fetcher_delegate.h" | 28 #include "net/url_request/url_fetcher_delegate.h" |
| 21 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 22 | 30 |
| 23 namespace certificate_reporting { | 31 namespace certificate_reporting { |
| 24 class ErrorReporter; | 32 class ErrorReporter; |
| 25 } | 33 } |
| 26 | 34 |
| 27 namespace net { | 35 namespace net { |
| 28 class SSLInfo; | 36 class SSLInfo; |
| 29 class URLRequestContextGetter; | 37 class URLRequestContextGetter; |
| 30 } // namespace net | 38 } // namespace net |
| 31 | 39 |
| 32 namespace safe_browsing { | 40 namespace safe_browsing { |
| 33 | 41 |
| 42 class PermissionReporter; | |
| 43 | |
| 34 class SafeBrowsingPingManager : public net::URLFetcherDelegate { | 44 class SafeBrowsingPingManager : public net::URLFetcherDelegate { |
| 35 public: | 45 public: |
| 36 ~SafeBrowsingPingManager() override; | 46 ~SafeBrowsingPingManager() override; |
| 37 | 47 |
| 38 // Create an instance of the safe browsing ping manager. | 48 // Create an instance of the safe browsing ping manager. |
| 39 static SafeBrowsingPingManager* Create( | 49 static SafeBrowsingPingManager* Create( |
| 40 net::URLRequestContextGetter* request_context_getter, | 50 net::URLRequestContextGetter* request_context_getter, |
| 41 const SafeBrowsingProtocolConfig& config); | 51 const SafeBrowsingProtocolConfig& config); |
| 42 | 52 |
| 43 // net::URLFetcherDelegate interface. | 53 // net::URLFetcherDelegate interface. |
| 44 void OnURLFetchComplete(const net::URLFetcher* source) override; | 54 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 45 | 55 |
| 46 // Report to Google when a SafeBrowsing warning is shown to the user. | 56 // 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 | 57 // |hit_report.threat_type| should be one of the types known by |
| 48 // SafeBrowsingtHitUrl. | 58 // SafeBrowsingtHitUrl. |
| 49 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); | 59 void ReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report); |
| 50 | 60 |
| 51 // Users can opt-in on the SafeBrowsing interstitial to send detailed | 61 // Users can opt-in on the SafeBrowsing interstitial to send detailed |
| 52 // threat reports. |report| is the serialized report. | 62 // threat reports. |report| is the serialized report. |
| 53 void ReportThreatDetails(const std::string& report); | 63 void ReportThreatDetails(const std::string& report); |
| 54 | 64 |
| 55 // Users can opt-in on the SSL interstitial to send reports of invalid | 65 // Users can opt-in on the SSL interstitial to send reports of invalid |
| 56 // certificate chains. | 66 // certificate chains. |
| 57 void ReportInvalidCertificateChain(const std::string& serialized_report); | 67 void ReportInvalidCertificateChain(const std::string& serialized_report); |
| 58 | 68 |
| 59 void SetCertificateErrorReporterForTesting( | 69 void SetCertificateErrorReporterForTesting( |
| 60 std::unique_ptr<certificate_reporting::ErrorReporter> | 70 std::unique_ptr<certificate_reporting::ErrorReporter> |
| 61 certificate_error_reporter); | 71 certificate_error_reporter); |
| 62 | 72 |
| 73 // Report permission action to SafeBrowsing servers. | |
| 74 void ReportPermissionAction(const GURL& origin, | |
| 75 content::PermissionType permission, | |
|
raymes
2016/06/16 01:10:22
nit: we should include permission_type.h
stefanocs
2016/06/16 01:52:20
Do we still need to include that even though it wa
raymes
2016/06/20 02:46:33
Yes - you either need to forward declare or #inclu
| |
| 76 PermissionAction action); | |
| 77 | |
| 63 private: | 78 private: |
| 64 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, | 79 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, |
| 65 TestSafeBrowsingHitUrl); | 80 TestSafeBrowsingHitUrl); |
| 66 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); | 81 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingPingManagerTest, TestThreatDetailsUrl); |
| 67 | 82 |
| 68 typedef std::set<const net::URLFetcher*> Reports; | 83 typedef std::set<const net::URLFetcher*> Reports; |
| 69 | 84 |
| 70 // Constructs a SafeBrowsingPingManager that issues network requests | 85 // Constructs a SafeBrowsingPingManager that issues network requests |
| 71 // using |request_context_getter|. | 86 // using |request_context_getter|. |
| 72 SafeBrowsingPingManager( | 87 SafeBrowsingPingManager( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 93 std::string url_prefix_; | 108 std::string url_prefix_; |
| 94 | 109 |
| 95 // Track outstanding SafeBrowsing report fetchers for clean up. | 110 // Track outstanding SafeBrowsing report fetchers for clean up. |
| 96 // We add both "hit" and "detail" fetchers in this set. | 111 // We add both "hit" and "detail" fetchers in this set. |
| 97 Reports safebrowsing_reports_; | 112 Reports safebrowsing_reports_; |
| 98 | 113 |
| 99 // Sends reports of invalid SSL certificate chains. | 114 // Sends reports of invalid SSL certificate chains. |
| 100 std::unique_ptr<certificate_reporting::ErrorReporter> | 115 std::unique_ptr<certificate_reporting::ErrorReporter> |
| 101 certificate_error_reporter_; | 116 certificate_error_reporter_; |
| 102 | 117 |
| 118 // Sends reports of permission actions. | |
| 119 std::unique_ptr<PermissionReporter> permission_reporter_; | |
| 120 | |
| 103 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); | 121 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingPingManager); |
| 104 }; | 122 }; |
| 105 | 123 |
| 106 } // namespace safe_browsing | 124 } // namespace safe_browsing |
| 107 | 125 |
| 108 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ | 126 #endif // CHROME_BROWSER_SAFE_BROWSING_PING_MANAGER_H_ |
| OLD | NEW |