| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 // Called after the chunks that were parsed were inserted in the database. | 105 // Called after the chunks that were parsed were inserted in the database. |
| 106 void OnChunkInserted(); | 106 void OnChunkInserted(); |
| 107 | 107 |
| 108 // The last time we received an update. | 108 // The last time we received an update. |
| 109 base::Time last_update() const { return last_update_; } | 109 base::Time last_update() const { return last_update_; } |
| 110 | 110 |
| 111 // Reports a malware resource to the SafeBrowsing service. | 111 // Reports a malware resource to the SafeBrowsing service. |
| 112 void ReportMalware(const GURL& malware_url, | 112 void ReportMalware(const GURL& malware_url, |
| 113 const GURL& page_url, | 113 const GURL& page_url, |
| 114 const GURL& referrer_url); | 114 const GURL& referrer_url, |
| 115 bool is_subresource); |
| 115 | 116 |
| 116 // Setter for additional_query_. To make sure the additional_query_ won't | 117 // Setter for additional_query_. To make sure the additional_query_ won't |
| 117 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) | 118 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) |
| 118 // should call this after callbacks triggered in UpdateFinished() or before | 119 // should call this after callbacks triggered in UpdateFinished() or before |
| 119 // IssueUpdateRequest(). | 120 // IssueUpdateRequest(). |
| 120 void set_additional_query(const std::string& query) { | 121 void set_additional_query(const std::string& query) { |
| 121 additional_query_ = query; | 122 additional_query_ = query; |
| 122 } | 123 } |
| 123 const std::string& additional_query() const { | 124 const std::string& additional_query() const { |
| 124 return additional_query_; | 125 return additional_query_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 147 // Generates Update URL for querying about the latest set of chunk updates. | 148 // Generates Update URL for querying about the latest set of chunk updates. |
| 148 // Append "wrkey=xxx" to the URL when |use_mac| is true. | 149 // Append "wrkey=xxx" to the URL when |use_mac| is true. |
| 149 GURL UpdateUrl(bool use_mac) const; | 150 GURL UpdateUrl(bool use_mac) const; |
| 150 // Generates GetHash request URL for retrieving full hashes. | 151 // Generates GetHash request URL for retrieving full hashes. |
| 151 // Append "wrkey=xxx" to the URL when |use_mac| is true. | 152 // Append "wrkey=xxx" to the URL when |use_mac| is true. |
| 152 GURL GetHashUrl(bool use_mac) const; | 153 GURL GetHashUrl(bool use_mac) const; |
| 153 // Generates new MAC client key request URL. | 154 // Generates new MAC client key request URL. |
| 154 GURL MacKeyUrl() const; | 155 GURL MacKeyUrl() const; |
| 155 // Generates URL for reporting malware pages. | 156 // Generates URL for reporting malware pages. |
| 156 GURL MalwareReportUrl(const GURL& malware_url, const GURL& page_url, | 157 GURL MalwareReportUrl(const GURL& malware_url, const GURL& page_url, |
| 157 const GURL& referrer_url) const; | 158 const GURL& referrer_url, bool is_subresource) const; |
| 158 // Composes a ChunkUrl based on input string. | 159 // Composes a ChunkUrl based on input string. |
| 159 GURL NextChunkUrl(const std::string& input) const; | 160 GURL NextChunkUrl(const std::string& input) const; |
| 160 | 161 |
| 161 // Returns the time (in milliseconds) for the next update request. If | 162 // Returns the time (in milliseconds) for the next update request. If |
| 162 // 'back_off' is true, the time returned will increment an error count and | 163 // 'back_off' is true, the time returned will increment an error count and |
| 163 // return the appriate next time (see ScheduleNextUpdate below). | 164 // return the appriate next time (see ScheduleNextUpdate below). |
| 164 int GetNextUpdateTime(bool back_off); | 165 int GetNextUpdateTime(bool back_off); |
| 165 | 166 |
| 166 // Worker function for calculating GetHash and Update backoff times (in | 167 // Worker function for calculating GetHash and Update backoff times (in |
| 167 // seconds). 'Multiplier' is doubled for each consecutive error between the | 168 // seconds). 'Multiplier' is doubled for each consecutive error between the |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 std::string mackey_url_prefix_; | 310 std::string mackey_url_prefix_; |
| 310 | 311 |
| 311 // When true, protocol manager will not start an update unless | 312 // When true, protocol manager will not start an update unless |
| 312 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 313 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
| 313 bool disable_auto_update_; | 314 bool disable_auto_update_; |
| 314 | 315 |
| 315 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 316 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
| 316 }; | 317 }; |
| 317 | 318 |
| 318 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 319 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| OLD | NEW |