Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_PROTOCOL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 9 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
| 10 // The SafeBrowsingProtocolManager handles formatting and making requests of, | 10 // The SafeBrowsingProtocolManager handles formatting and making requests of, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 | 44 |
| 45 class SafeBrowsingProtocolManager : public URLFetcher::Delegate { | 45 class SafeBrowsingProtocolManager : public URLFetcher::Delegate { |
| 46 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); | 46 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); |
| 47 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings); | 47 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings); |
| 48 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl); | 48 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl); |
| 49 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | 49 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, |
| 50 TestGetHashBackOffTimes); | 50 TestGetHashBackOffTimes); |
| 51 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestMacKeyUrl); | 51 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestMacKeyUrl); |
| 52 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | 52 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, |
| 53 TestSafeBrowsingReportUrl); | 53 TestSafeBrowsingReportUrl); |
| 54 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | |
| 55 TestMalwareClientUrl); | |
| 54 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestNextChunkUrl); | 56 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestNextChunkUrl); |
| 55 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestUpdateUrl); | 57 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestUpdateUrl); |
| 56 friend class SafeBrowsingServiceTest; | 58 friend class SafeBrowsingServiceTest; |
| 57 | 59 |
| 58 public: | 60 public: |
| 59 // Constructs a SafeBrowsingProtocolManager for |sb_service| that issues | 61 // Constructs a SafeBrowsingProtocolManager for |sb_service| that issues |
| 60 // network requests using |request_context_getter|. When |disable_auto_update| | 62 // network requests using |request_context_getter|. When |disable_auto_update| |
| 61 // is true, protocol manager won't schedule next update until | 63 // is true, protocol manager won't schedule next update until |
| 62 // ForceScheduleNextUpdate is called. | 64 // ForceScheduleNextUpdate is called. |
| 63 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, | 65 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 | 112 |
| 111 // For UMA users we report to Google when a SafeBrowsing interstitial is shown | 113 // For UMA users we report to Google when a SafeBrowsing interstitial is shown |
| 112 // to the user. We assume that the threat type is either URL_MALWARE or | 114 // to the user. We assume that the threat type is either URL_MALWARE or |
| 113 // URL_PHISHING. | 115 // URL_PHISHING. |
| 114 void ReportSafeBrowsingHit(const GURL& malicious_url, | 116 void ReportSafeBrowsingHit(const GURL& malicious_url, |
| 115 const GURL& page_url, | 117 const GURL& page_url, |
| 116 const GURL& referrer_url, | 118 const GURL& referrer_url, |
| 117 bool is_subresource, | 119 bool is_subresource, |
| 118 SafeBrowsingService::UrlCheckResult threat_type); | 120 SafeBrowsingService::UrlCheckResult threat_type); |
| 119 | 121 |
| 122 // Users can opt-in on the SafeBrowsing interstitial to send advanced | |
|
lzheng
2010/11/16 00:18:12
Maybe we should say 'detailed' instead of 'advance
panayiotis
2010/11/18 22:04:37
Done.
| |
| 123 // malware reports. | |
| 124 void SendMalwareReport(const std::string* request_data); | |
| 120 | 125 |
| 121 // Setter for additional_query_. To make sure the additional_query_ won't | 126 // Setter for additional_query_. To make sure the additional_query_ won't |
| 122 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) | 127 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) |
| 123 // should call this after callbacks triggered in UpdateFinished() or before | 128 // should call this after callbacks triggered in UpdateFinished() or before |
| 124 // IssueUpdateRequest(). | 129 // IssueUpdateRequest(). |
| 125 void set_additional_query(const std::string& query) { | 130 void set_additional_query(const std::string& query) { |
| 126 additional_query_ = query; | 131 additional_query_ = query; |
| 127 } | 132 } |
| 128 const std::string& additional_query() const { | 133 const std::string& additional_query() const { |
| 129 return additional_query_; | 134 return additional_query_; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 151 const std::string& additional_query); | 156 const std::string& additional_query); |
| 152 | 157 |
| 153 // Generates Update URL for querying about the latest set of chunk updates. | 158 // Generates Update URL for querying about the latest set of chunk updates. |
| 154 // Append "wrkey=xxx" to the URL when |use_mac| is true. | 159 // Append "wrkey=xxx" to the URL when |use_mac| is true. |
| 155 GURL UpdateUrl(bool use_mac) const; | 160 GURL UpdateUrl(bool use_mac) const; |
| 156 // Generates GetHash request URL for retrieving full hashes. | 161 // Generates GetHash request URL for retrieving full hashes. |
| 157 // Append "wrkey=xxx" to the URL when |use_mac| is true. | 162 // Append "wrkey=xxx" to the URL when |use_mac| is true. |
| 158 GURL GetHashUrl(bool use_mac) const; | 163 GURL GetHashUrl(bool use_mac) const; |
| 159 // Generates new MAC client key request URL. | 164 // Generates new MAC client key request URL. |
| 160 GURL MacKeyUrl() const; | 165 GURL MacKeyUrl() const; |
| 161 // Generates URL for reporting malicious pages. | 166 // Generates URL for reporting safe browsing hits. |
| 162 GURL SafeBrowsingReportUrl( | 167 GURL SafeBrowsingReportUrl( |
| 163 const GURL& malicious_url, const GURL& page_url, const GURL& referrer_url, | 168 const GURL& malicious_url, const GURL& page_url, const GURL& referrer_url, |
| 164 bool is_subresource, | 169 bool is_subresource, |
| 165 SafeBrowsingService::UrlCheckResult threat_type) const; | 170 SafeBrowsingService::UrlCheckResult threat_type) const; |
| 171 // Generates URL for malware reports. | |
| 172 GURL MalwareClientReportUrl() const; | |
| 173 | |
| 166 // Composes a ChunkUrl based on input string. | 174 // Composes a ChunkUrl based on input string. |
| 167 GURL NextChunkUrl(const std::string& input) const; | 175 GURL NextChunkUrl(const std::string& input) const; |
| 168 | 176 |
| 169 // Returns the time (in milliseconds) for the next update request. If | 177 // Returns the time (in milliseconds) for the next update request. If |
| 170 // 'back_off' is true, the time returned will increment an error count and | 178 // 'back_off' is true, the time returned will increment an error count and |
| 171 // return the appriate next time (see ScheduleNextUpdate below). | 179 // return the appriate next time (see ScheduleNextUpdate below). |
| 172 int GetNextUpdateTime(bool back_off); | 180 int GetNextUpdateTime(bool back_off); |
| 173 | 181 |
| 174 // Worker function for calculating GetHash and Update backoff times (in | 182 // Worker function for calculating GetHash and Update backoff times (in |
| 175 // seconds). 'Multiplier' is doubled for each consecutive error between the | 183 // seconds). 'Multiplier' is doubled for each consecutive error between the |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 std::string mackey_url_prefix_; | 325 std::string mackey_url_prefix_; |
| 318 | 326 |
| 319 // When true, protocol manager will not start an update unless | 327 // When true, protocol manager will not start an update unless |
| 320 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 328 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
| 321 bool disable_auto_update_; | 329 bool disable_auto_update_; |
| 322 | 330 |
| 323 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 331 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
| 324 }; | 332 }; |
| 325 | 333 |
| 326 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 334 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| OLD | NEW |