OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SAFE_BROWSING_DATABASE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Returns false if |url| is not in the browse database or already was cached | 92 // Returns false if |url| is not in the browse database or already was cached |
93 // as a miss. If it returns true, |prefix_hits| contains sorted unique | 93 // as a miss. If it returns true, |prefix_hits| contains sorted unique |
94 // matching hash prefixes which had no cached results and |cache_hits| | 94 // matching hash prefixes which had no cached results and |cache_hits| |
95 // contains any matching cached gethash results. This function is safe to | 95 // contains any matching cached gethash results. This function is safe to |
96 // call from any thread. | 96 // call from any thread. |
97 virtual bool ContainsBrowseUrl( | 97 virtual bool ContainsBrowseUrl( |
98 const GURL& url, | 98 const GURL& url, |
99 std::vector<SBPrefix>* prefix_hits, | 99 std::vector<SBPrefix>* prefix_hits, |
100 std::vector<SBFullHashResult>* cache_hits) = 0; | 100 std::vector<SBFullHashResult>* cache_hits) = 0; |
101 | 101 |
| 102 // Returns false if none of the hashes in |full_hashes| are in the browse |
| 103 // database or all were already cached as a miss. If it returns true, |
| 104 // |prefix_hits| contains sorted unique matching hash prefixes which had no |
| 105 // cached results and |cache_hits| contains any matching cached gethash |
| 106 // results. This function is safe to call from any thread. |
| 107 virtual bool ContainsBrowseHashes( |
| 108 const std::vector<SBFullHash>& full_hashes, |
| 109 std::vector<SBPrefix>* prefix_hits, |
| 110 std::vector<SBFullHashResult>* cache_hits) = 0; |
| 111 |
102 // Returns true iff the given url is on the unwanted software blacklist. | 112 // Returns true iff the given url is on the unwanted software blacklist. |
103 // Returns false if |url| is not in the browse database or already was cached | 113 // Returns false if |url| is not in the browse database or already was cached |
104 // as a miss. If it returns true, |prefix_hits| contains sorted unique | 114 // as a miss. If it returns true, |prefix_hits| contains sorted unique |
105 // matching hash prefixes which had no cached results and |cache_hits| | 115 // matching hash prefixes which had no cached results and |cache_hits| |
106 // contains any matching cached gethash results. This function is safe to | 116 // contains any matching cached gethash results. This function is safe to |
107 // call from any thread. | 117 // call from any thread. |
108 virtual bool ContainsUnwantedSoftwareUrl( | 118 virtual bool ContainsUnwantedSoftwareUrl( |
109 const GURL& url, | 119 const GURL& url, |
110 std::vector<SBPrefix>* prefix_hits, | 120 std::vector<SBPrefix>* prefix_hits, |
111 std::vector<SBFullHashResult>* cache_hits) = 0; | 121 std::vector<SBFullHashResult>* cache_hits) = 0; |
112 | 122 |
| 123 // Returns true iff any of the given hashes are on the unwanted software |
| 124 // blacklist. |
| 125 // Returns false if none of the hashes in |full_hashes| are in the browse |
| 126 // database or all were already cached as a miss. If it returns true, |
| 127 // |prefix_hits| contains sorted unique matching hash prefixes which had no |
| 128 // cached results and |cache_hits| contains any matching cached gethash |
| 129 // results. This function is safe to call from any thread. |
| 130 virtual bool ContainsUnwantedSoftwareHashes( |
| 131 const std::vector<SBFullHash>& full_hashes, |
| 132 std::vector<SBPrefix>* prefix_hits, |
| 133 std::vector<SBFullHashResult>* cache_hits) = 0; |
| 134 |
113 // Returns false if none of |prefixes| are in Download database. If it returns | 135 // Returns false if none of |prefixes| are in Download database. If it returns |
114 // true, |prefix_hits| should contain the prefixes for the URLs that were in | 136 // true, |prefix_hits| should contain the prefixes for the URLs that were in |
115 // the database. This function can ONLY be accessed from creation thread. | 137 // the database. This function can ONLY be accessed from creation thread. |
116 virtual bool ContainsDownloadUrlPrefixes( | 138 virtual bool ContainsDownloadUrlPrefixes( |
117 const std::vector<SBPrefix>& prefixes, | 139 const std::vector<SBPrefix>& prefixes, |
118 std::vector<SBPrefix>* prefix_hits) = 0; | 140 std::vector<SBPrefix>* prefix_hits) = 0; |
119 | 141 |
120 // Returns false if |url| is not on the client-side phishing detection | 142 // Returns false if |url| is not on the client-side phishing detection |
121 // whitelist. Otherwise, this function returns true. Note: the whitelist | 143 // whitelist. Otherwise, this function returns true. Note: the whitelist |
122 // only contains full-length hashes so we don't return any prefix hit. This | 144 // only contains full-length hashes so we don't return any prefix hit. This |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 SafeBrowsingStore* unwanted_software_store); | 336 SafeBrowsingStore* unwanted_software_store); |
315 | 337 |
316 ~SafeBrowsingDatabaseNew() override; | 338 ~SafeBrowsingDatabaseNew() override; |
317 | 339 |
318 // Implement SafeBrowsingDatabase interface. | 340 // Implement SafeBrowsingDatabase interface. |
319 void Init(const base::FilePath& filename) override; | 341 void Init(const base::FilePath& filename) override; |
320 bool ResetDatabase() override; | 342 bool ResetDatabase() override; |
321 bool ContainsBrowseUrl(const GURL& url, | 343 bool ContainsBrowseUrl(const GURL& url, |
322 std::vector<SBPrefix>* prefix_hits, | 344 std::vector<SBPrefix>* prefix_hits, |
323 std::vector<SBFullHashResult>* cache_hits) override; | 345 std::vector<SBFullHashResult>* cache_hits) override; |
| 346 bool ContainsBrowseHashes(const std::vector<SBFullHash>& full_hashes, |
| 347 std::vector<SBPrefix>* prefix_hits, |
| 348 std::vector<SBFullHashResult>* cache_hits) override; |
324 bool ContainsUnwantedSoftwareUrl( | 349 bool ContainsUnwantedSoftwareUrl( |
325 const GURL& url, | 350 const GURL& url, |
326 std::vector<SBPrefix>* prefix_hits, | 351 std::vector<SBPrefix>* prefix_hits, |
327 std::vector<SBFullHashResult>* cache_hits) override; | 352 std::vector<SBFullHashResult>* cache_hits) override; |
| 353 bool ContainsUnwantedSoftwareHashes( |
| 354 const std::vector<SBFullHash>& full_hashes, |
| 355 std::vector<SBPrefix>* prefix_hits, |
| 356 std::vector<SBFullHashResult>* cache_hits) override; |
328 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes, | 357 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes, |
329 std::vector<SBPrefix>* prefix_hits) override; | 358 std::vector<SBPrefix>* prefix_hits) override; |
330 bool ContainsCsdWhitelistedUrl(const GURL& url) override; | 359 bool ContainsCsdWhitelistedUrl(const GURL& url) override; |
331 bool ContainsDownloadWhitelistedUrl(const GURL& url) override; | 360 bool ContainsDownloadWhitelistedUrl(const GURL& url) override; |
332 bool ContainsDownloadWhitelistedString(const std::string& str) override; | 361 bool ContainsDownloadWhitelistedString(const std::string& str) override; |
333 bool ContainsInclusionWhitelistedUrl(const GURL& url) override; | 362 bool ContainsInclusionWhitelistedUrl(const GURL& url) override; |
334 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes, | 363 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes, |
335 std::vector<SBPrefix>* prefix_hits) override; | 364 std::vector<SBPrefix>* prefix_hits) override; |
336 bool ContainsMalwareIP(const std::string& ip_address) override; | 365 bool ContainsMalwareIP(const std::string& ip_address) override; |
337 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override; | 366 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 bool change_detected_; | 553 bool change_detected_; |
525 | 554 |
526 DISALLOW_COPY_AND_ASSIGN(DatabaseStateManager); | 555 DISALLOW_COPY_AND_ASSIGN(DatabaseStateManager); |
527 }; | 556 }; |
528 | 557 |
529 bool PrefixSetContainsUrl(const GURL& url, | 558 bool PrefixSetContainsUrl(const GURL& url, |
530 PrefixSetId prefix_set_id, | 559 PrefixSetId prefix_set_id, |
531 std::vector<SBPrefix>* prefix_hits, | 560 std::vector<SBPrefix>* prefix_hits, |
532 std::vector<SBFullHashResult>* cache_hits); | 561 std::vector<SBFullHashResult>* cache_hits); |
533 | 562 |
534 // Exposed for testing of PrefixSetContainsUrlHashes() on the | |
535 // PrefixSet backing kMalwareList. | |
536 bool ContainsBrowseUrlHashesForTesting( | |
537 const std::vector<SBFullHash>& full_hashes, | |
538 std::vector<SBPrefix>* prefix_hits, | |
539 std::vector<SBFullHashResult>* cache_hits); | |
540 | |
541 bool PrefixSetContainsUrlHashes(const std::vector<SBFullHash>& full_hashes, | 563 bool PrefixSetContainsUrlHashes(const std::vector<SBFullHash>& full_hashes, |
542 PrefixSetId prefix_set_id, | 564 PrefixSetId prefix_set_id, |
543 std::vector<SBPrefix>* prefix_hits, | 565 std::vector<SBPrefix>* prefix_hits, |
544 std::vector<SBFullHashResult>* cache_hits); | 566 std::vector<SBFullHashResult>* cache_hits); |
545 | 567 |
546 // Returns true if the whitelist is disabled or if any of the given hashes | 568 // Returns true if the whitelist is disabled or if any of the given hashes |
547 // matches the whitelist. | 569 // matches the whitelist. |
548 bool ContainsWhitelistedHashes(SBWhitelistId whitelist_id, | 570 bool ContainsWhitelistedHashes(SBWhitelistId whitelist_id, |
549 const std::vector<SBFullHash>& hashes); | 571 const std::vector<SBFullHash>& hashes); |
550 | 572 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 698 |
677 // Used to schedule resetting the database because of corruption. This factory | 699 // Used to schedule resetting the database because of corruption. This factory |
678 // and the WeakPtrs it issues should only be used on the database's main | 700 // and the WeakPtrs it issues should only be used on the database's main |
679 // thread. | 701 // thread. |
680 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; | 702 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; |
681 }; | 703 }; |
682 | 704 |
683 } // namespace safe_browsing | 705 } // namespace safe_browsing |
684 | 706 |
685 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ | 707 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ |
OLD | NEW |