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 // 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> |
| 11 #include <deque> | 11 #include <deque> |
| 12 #include <set> | |
|
Scott Hess - ex-Googler
2013/01/11 23:44:05
Is set used in this header?
not at google - send to devlin
2013/01/14 23:00:55
Done.
| |
| 12 #include <string> | 13 #include <string> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 16 #include "chrome/browser/safe_browsing/chunk_range.h" | 17 #include "chrome/browser/safe_browsing/chunk_range.h" |
| 17 | 18 |
| 18 class GURL; | 19 class GURL; |
| 19 | 20 |
| 20 class SBEntry; | 21 class SBEntry; |
| 21 | 22 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 BINURL = 2, | 296 BINURL = 2, |
| 296 BINHASH = 3, | 297 BINHASH = 3, |
| 297 CSDWHITELIST = 4, | 298 CSDWHITELIST = 4, |
| 298 // SafeBrowsing lists are stored in pairs. Keep ListType 5 | 299 // SafeBrowsing lists are stored in pairs. Keep ListType 5 |
| 299 // available for a potential second list that we would store in the | 300 // available for a potential second list that we would store in the |
| 300 // csd-whitelist store file. | 301 // csd-whitelist store file. |
| 301 DOWNLOADWHITELIST = 6, | 302 DOWNLOADWHITELIST = 6, |
| 302 }; | 303 }; |
| 303 | 304 |
| 304 // Maps a list name to ListType. | 305 // Maps a list name to ListType. |
| 305 int GetListId(const std::string& name); | 306 ListType GetListId(const std::string& name); |
| 307 | |
| 306 // Maps a ListId to list name. Return false if fails. | 308 // Maps a ListId to list name. Return false if fails. |
| 307 bool GetListName(int list_id, std::string* list); | 309 bool GetListName(ListType list_id, std::string* list); |
| 308 | |
| 309 | 310 |
| 310 // Canonicalizes url as per Google Safe Browsing Specification. | 311 // Canonicalizes url as per Google Safe Browsing Specification. |
| 311 // See section 6.1 in | 312 // See section 6.1 in |
| 312 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. | 313 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. |
| 313 void CanonicalizeUrl(const GURL& url, std::string* canonicalized_hostname, | 314 void CanonicalizeUrl(const GURL& url, std::string* canonicalized_hostname, |
| 314 std::string* canonicalized_path, | 315 std::string* canonicalized_path, |
| 315 std::string* canonicalized_query); | 316 std::string* canonicalized_query); |
| 316 | 317 |
| 317 // Given a URL, returns all the hosts we need to check. They are returned | 318 // Given a URL, returns all the hosts we need to check. They are returned |
| 318 // in order of size (i.e. b.c is first, then a.b.c). | 319 // in order of size (i.e. b.c is first, then a.b.c). |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 335 | 336 |
| 336 bool IsPhishingList(const std::string& list_name); | 337 bool IsPhishingList(const std::string& list_name); |
| 337 bool IsMalwareList(const std::string& list_name); | 338 bool IsMalwareList(const std::string& list_name); |
| 338 bool IsBadbinurlList(const std::string& list_name); | 339 bool IsBadbinurlList(const std::string& list_name); |
| 339 bool IsBadbinhashList(const std::string& list_name); | 340 bool IsBadbinhashList(const std::string& list_name); |
| 340 | 341 |
| 341 GURL GeneratePhishingReportUrl(const std::string& report_page, | 342 GURL GeneratePhishingReportUrl(const std::string& report_page, |
| 342 const std::string& url_to_report, | 343 const std::string& url_to_report, |
| 343 bool is_client_side_detection); | 344 bool is_client_side_detection); |
| 344 | 345 |
| 345 void StringToSBFullHash(const std::string& hash_in, SBFullHash* hash_out); | 346 SBFullHash StringToSBFullHash(const std::string& hash_in); |
| 346 std::string SBFullHashToString(const SBFullHash& hash_out); | 347 std::string SBFullHashToString(const SBFullHash& hash_out); |
| 348 | |
| 347 } // namespace safe_browsing_util | 349 } // namespace safe_browsing_util |
| 348 | 350 |
| 349 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ | 351 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ |
| OLD | NEW |