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 // Utilities for the SafeBrowsing code. | 5 // Utilities for the SafeBrowsing code. |
6 | 6 |
7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ | 7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ |
8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ | 8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ |
9 | 9 |
10 #include <cstring> | 10 #include <cstring> |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // Converts between the SafeBrowsing list names and their enumerated value. | 267 // Converts between the SafeBrowsing list names and their enumerated value. |
268 // If the list names change, both of these methods must be updated. | 268 // If the list names change, both of these methods must be updated. |
269 enum ListType { | 269 enum ListType { |
270 INVALID = -1, | 270 INVALID = -1, |
271 MALWARE = 0, | 271 MALWARE = 0, |
272 PHISH = 1, | 272 PHISH = 1, |
273 }; | 273 }; |
274 int GetListId(const std::string& name); | 274 int GetListId(const std::string& name); |
275 std::string GetListName(int list_id); | 275 std::string GetListName(int list_id); |
276 | 276 |
| 277 // Canonicalizes url as per Google Safe Browsing Specification. |
| 278 // See section 6.1 in |
| 279 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. |
| 280 void CanonicalizeUrl(const GURL& url, std::string* canonicalized_hostname, |
| 281 std::string* canonicalized_path, |
| 282 std::string* canonicalized_query); |
| 283 |
277 // Given a URL, returns all the hosts we need to check. They are returned | 284 // Given a URL, returns all the hosts we need to check. They are returned |
278 // in order of size (i.e. b.c is first, then a.b.c). | 285 // in order of size (i.e. b.c is first, then a.b.c). |
279 void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts); | 286 void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts); |
280 | 287 |
281 // Given a URL, returns all the paths we need to check. | 288 // Given a URL, returns all the paths we need to check. |
282 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 289 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
283 | 290 |
284 // Given a URL, compare all the possible host + path full hashes to the set of | 291 // Given a URL, compare all the possible host + path full hashes to the set of |
285 // provided full hashes. Returns the index of the match if one is found, or -1 | 292 // provided full hashes. Returns the index of the match if one is found, or -1 |
286 // otherwise. | 293 // otherwise. |
287 int CompareFullHashes(const GURL& url, | 294 int CompareFullHashes(const GURL& url, |
288 const std::vector<SBFullHashResult>& full_hashes); | 295 const std::vector<SBFullHashResult>& full_hashes); |
289 | 296 |
290 bool IsPhishingList(const std::string& list_name); | 297 bool IsPhishingList(const std::string& list_name); |
291 bool IsMalwareList(const std::string& list_name); | 298 bool IsMalwareList(const std::string& list_name); |
292 | 299 |
293 // Returns 'true' if 'mac' can be verified using 'key' and 'data'. | 300 // Returns 'true' if 'mac' can be verified using 'key' and 'data'. |
294 bool VerifyMAC(const std::string& key, | 301 bool VerifyMAC(const std::string& key, |
295 const std::string& mac, | 302 const std::string& mac, |
296 const char* data, | 303 const char* data, |
297 int data_length); | 304 int data_length); |
298 | 305 |
299 GURL GeneratePhishingReportUrl(const std::string& report_page, | 306 GURL GeneratePhishingReportUrl(const std::string& report_page, |
300 const std::string& url_to_report); | 307 const std::string& url_to_report); |
301 | 308 |
302 } // namespace safe_browsing_util | 309 } // namespace safe_browsing_util |
303 | 310 |
304 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ | 311 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ |
OLD | NEW |