Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.h

Issue 1970823002: Remove the unused OffDomainInclusionDetector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nits Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // The download whitelist is used for two purposes: a white-domain list of 151 // The download whitelist is used for two purposes: a white-domain list of
152 // sites that are considered to host only harmless binaries as well as a 152 // sites that are considered to host only harmless binaries as well as a
153 // whitelist of arbitrary strings such as hashed certificate authorities that 153 // whitelist of arbitrary strings such as hashed certificate authorities that
154 // are considered to be trusted. The two methods below let you lookup the 154 // are considered to be trusted. The two methods below let you lookup the
155 // whitelist either for a URL or an arbitrary string. These methods will 155 // whitelist either for a URL or an arbitrary string. These methods will
156 // return false if no match is found and true otherwise. This function is safe 156 // return false if no match is found and true otherwise. This function is safe
157 // to call from any thread. 157 // to call from any thread.
158 virtual bool ContainsDownloadWhitelistedUrl(const GURL& url) = 0; 158 virtual bool ContainsDownloadWhitelistedUrl(const GURL& url) = 0;
159 virtual bool ContainsDownloadWhitelistedString(const std::string& str) = 0; 159 virtual bool ContainsDownloadWhitelistedString(const std::string& str) = 0;
160 160
161 // Returns true if |url| is on the off-domain inclusion whitelist.
162 virtual bool ContainsInclusionWhitelistedUrl(const GURL& url) = 0;
163
164 // Returns true if the given module is on the module whitelist. 161 // Returns true if the given module is on the module whitelist.
165 virtual bool ContainsModuleWhitelistedString(const std::string& str) = 0; 162 virtual bool ContainsModuleWhitelistedString(const std::string& str) = 0;
166 163
167 // Populates |prefix_hits| with any prefixes in |prefixes| that have matches 164 // Populates |prefix_hits| with any prefixes in |prefixes| that have matches
168 // in the database, returning true if there were any matches. 165 // in the database, returning true if there were any matches.
169 // 166 //
170 // This function can ONLY be accessed from the creation thread. 167 // This function can ONLY be accessed from the creation thread.
171 virtual bool ContainsExtensionPrefixes( 168 virtual bool ContainsExtensionPrefixes(
172 const std::vector<SBPrefix>& prefixes, 169 const std::vector<SBPrefix>& prefixes,
173 std::vector<SBPrefix>* prefix_hits) = 0; 170 std::vector<SBPrefix>* prefix_hits) = 0;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 const base::FilePath& db_base_filename); 244 const base::FilePath& db_base_filename);
248 245
249 // Filename for client-side phishing detection whitelist databsae. 246 // Filename for client-side phishing detection whitelist databsae.
250 static base::FilePath CsdWhitelistDBFilename( 247 static base::FilePath CsdWhitelistDBFilename(
251 const base::FilePath& csd_whitelist_base_filename); 248 const base::FilePath& csd_whitelist_base_filename);
252 249
253 // Filename for download whitelist databsae. 250 // Filename for download whitelist databsae.
254 static base::FilePath DownloadWhitelistDBFilename( 251 static base::FilePath DownloadWhitelistDBFilename(
255 const base::FilePath& download_whitelist_base_filename); 252 const base::FilePath& download_whitelist_base_filename);
256 253
257 // Filename for the off-domain inclusion whitelist databsae. 254 // Filename for the off-domain inclusion whitelist databsae. This database no
255 // longer exists, but the filename is retained so the database may be deleted.
258 static base::FilePath InclusionWhitelistDBFilename( 256 static base::FilePath InclusionWhitelistDBFilename(
259 const base::FilePath& inclusion_whitelist_base_filename); 257 const base::FilePath& inclusion_whitelist_base_filename);
260 258
261 // Filename for extension blacklist database. 259 // Filename for extension blacklist database.
262 static base::FilePath ExtensionBlacklistDBFilename( 260 static base::FilePath ExtensionBlacklistDBFilename(
263 const base::FilePath& extension_blacklist_base_filename); 261 const base::FilePath& extension_blacklist_base_filename);
264 262
265 // Filename for side-effect free whitelist database. This database no longer 263 // Filename for side-effect free whitelist database. This database no longer
266 // exists, but the filename is retained so the database may be deleted. 264 // exists, but the filename is retained so the database may be deleted.
267 static base::FilePath SideEffectFreeWhitelistDBFilename( 265 static base::FilePath SideEffectFreeWhitelistDBFilename(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 public: 346 public:
349 // Create a database with the stores below. Takes ownership of all store 347 // Create a database with the stores below. Takes ownership of all store
350 // objects handed to this constructor. Ignores all future operations on lists 348 // objects handed to this constructor. Ignores all future operations on lists
351 // for which the store is initialized to NULL. 349 // for which the store is initialized to NULL.
352 SafeBrowsingDatabaseNew( 350 SafeBrowsingDatabaseNew(
353 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 351 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
354 SafeBrowsingStore* browse_store, 352 SafeBrowsingStore* browse_store,
355 SafeBrowsingStore* download_store, 353 SafeBrowsingStore* download_store,
356 SafeBrowsingStore* csd_whitelist_store, 354 SafeBrowsingStore* csd_whitelist_store,
357 SafeBrowsingStore* download_whitelist_store, 355 SafeBrowsingStore* download_whitelist_store,
358 SafeBrowsingStore* inclusion_whitelist_store,
359 SafeBrowsingStore* extension_blacklist_store, 356 SafeBrowsingStore* extension_blacklist_store,
360 SafeBrowsingStore* ip_blacklist_store, 357 SafeBrowsingStore* ip_blacklist_store,
361 SafeBrowsingStore* unwanted_software_store, 358 SafeBrowsingStore* unwanted_software_store,
362 SafeBrowsingStore* module_whitelist_store, 359 SafeBrowsingStore* module_whitelist_store,
363 SafeBrowsingStore* resource_blacklist_store); 360 SafeBrowsingStore* resource_blacklist_store);
364 361
365 ~SafeBrowsingDatabaseNew() override; 362 ~SafeBrowsingDatabaseNew() override;
366 363
367 // Implement SafeBrowsingDatabase interface. 364 // Implement SafeBrowsingDatabase interface.
368 void Init(const base::FilePath& filename) override; 365 void Init(const base::FilePath& filename) override;
(...skipping 10 matching lines...) Expand all
379 std::vector<SBFullHashResult>* cache_hits) override; 376 std::vector<SBFullHashResult>* cache_hits) override;
380 bool ContainsUnwantedSoftwareHashes( 377 bool ContainsUnwantedSoftwareHashes(
381 const std::vector<SBFullHash>& full_hashes, 378 const std::vector<SBFullHash>& full_hashes,
382 std::vector<SBPrefix>* prefix_hits, 379 std::vector<SBPrefix>* prefix_hits,
383 std::vector<SBFullHashResult>* cache_hits) override; 380 std::vector<SBFullHashResult>* cache_hits) override;
384 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes, 381 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes,
385 std::vector<SBPrefix>* prefix_hits) override; 382 std::vector<SBPrefix>* prefix_hits) override;
386 bool ContainsCsdWhitelistedUrl(const GURL& url) override; 383 bool ContainsCsdWhitelistedUrl(const GURL& url) override;
387 bool ContainsDownloadWhitelistedUrl(const GURL& url) override; 384 bool ContainsDownloadWhitelistedUrl(const GURL& url) override;
388 bool ContainsDownloadWhitelistedString(const std::string& str) override; 385 bool ContainsDownloadWhitelistedString(const std::string& str) override;
389 bool ContainsInclusionWhitelistedUrl(const GURL& url) override;
390 bool ContainsModuleWhitelistedString(const std::string& str) override; 386 bool ContainsModuleWhitelistedString(const std::string& str) override;
391 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes, 387 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes,
392 std::vector<SBPrefix>* prefix_hits) override; 388 std::vector<SBPrefix>* prefix_hits) override;
393 bool ContainsMalwareIP(const std::string& ip_address) override; 389 bool ContainsMalwareIP(const std::string& ip_address) override;
394 bool ContainsResourceUrlPrefixes(const std::vector<SBPrefix>& prefixes, 390 bool ContainsResourceUrlPrefixes(const std::vector<SBPrefix>& prefixes,
395 std::vector<SBPrefix>* prefix_hits) override; 391 std::vector<SBPrefix>* prefix_hits) override;
396 392
397 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override; 393 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override;
398 void InsertChunks( 394 void InsertChunks(
399 const std::string& list_name, 395 const std::string& list_name,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // will automatically handle thread-safety. 437 // will automatically handle thread-safety.
442 class ThreadSafeStateManager { 438 class ThreadSafeStateManager {
443 public: 439 public:
444 // Identifiers for stores held by the ThreadSafeStateManager. Allows helper 440 // Identifiers for stores held by the ThreadSafeStateManager. Allows helper
445 // methods to start a transaction themselves and keep it as short as 441 // methods to start a transaction themselves and keep it as short as
446 // possible rather than force callers to start the transaction early to pass 442 // possible rather than force callers to start the transaction early to pass
447 // a store pointer to the said helper methods. 443 // a store pointer to the said helper methods.
448 enum class SBWhitelistId { 444 enum class SBWhitelistId {
449 CSD, 445 CSD,
450 DOWNLOAD, 446 DOWNLOAD,
451 INCLUSION,
452 MODULE, 447 MODULE,
453 }; 448 };
454 enum class PrefixSetId { 449 enum class PrefixSetId {
455 BROWSE, 450 BROWSE,
456 UNWANTED_SOFTWARE, 451 UNWANTED_SOFTWARE,
457 }; 452 };
458 453
459 // Obtained through BeginReadTransaction(NoLockOnMainTaskRunner)?(): a 454 // Obtained through BeginReadTransaction(NoLockOnMainTaskRunner)?(): a
460 // ReadTransaction allows read-only observations of the 455 // ReadTransaction allows read-only observations of the
461 // ThreadSafeStateManager's state. The |prefix_gethash_cache_| has a special 456 // ThreadSafeStateManager's state. The |prefix_gethash_cache_| has a special
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Underlying persistent stores for chunk data: 697 // Underlying persistent stores for chunk data:
703 // - |browse_store_|: For browsing related (phishing and malware URLs) 698 // - |browse_store_|: For browsing related (phishing and malware URLs)
704 // chunks and prefixes. 699 // chunks and prefixes.
705 // - |download_store_|: For download related (download URL and binary hash) 700 // - |download_store_|: For download related (download URL and binary hash)
706 // chunks and prefixes. 701 // chunks and prefixes.
707 // - |csd_whitelist_store_|: For the client-side phishing detection 702 // - |csd_whitelist_store_|: For the client-side phishing detection
708 // whitelist chunks and full-length hashes. This list only contains 256 703 // whitelist chunks and full-length hashes. This list only contains 256
709 // bit hashes. 704 // bit hashes.
710 // - |download_whitelist_store_|: For the download whitelist chunks and 705 // - |download_whitelist_store_|: For the download whitelist chunks and
711 // full-length hashes. This list only contains 256 bit hashes. 706 // full-length hashes. This list only contains 256 bit hashes.
712 // - |inclusion_whitelist_store_|: For the inclusion whitelist. Same format
713 // as |download_whitelist_store_|.
714 // - |extension_blacklist_store_|: For extension IDs. 707 // - |extension_blacklist_store_|: For extension IDs.
715 // - |ip_blacklist_store_|: For IP blacklist. 708 // - |ip_blacklist_store_|: For IP blacklist.
716 // - |unwanted_software_store_|: For unwanted software list (format 709 // - |unwanted_software_store_|: For unwanted software list (format
717 // identical to browsing lists). 710 // identical to browsing lists).
718 // - |module_whitelist_store_|: For module whitelist. This list only 711 // - |module_whitelist_store_|: For module whitelist. This list only
719 // contains 256 bit hashes. 712 // contains 256 bit hashes.
720 // - |resource_blacklist_store_|: For script resource list (format identical 713 // - |resource_blacklist_store_|: For script resource list (format identical
721 // to browsing lists). 714 // to browsing lists).
722 // 715 //
723 // The stores themselves will be modified throughout the existence of this 716 // The stores themselves will be modified throughout the existence of this
724 // database, but shouldn't ever be swapped out (hence the const 717 // database, but shouldn't ever be swapped out (hence the const
725 // std::unique_ptr -- which could be swapped for C++11's std::optional when 718 // std::unique_ptr -- which could be swapped for C++11's std::optional when
726 // that's available). They are NonThreadSafe and should thus only be accessed 719 // that's available). They are NonThreadSafe and should thus only be accessed
727 // on the database's main thread as enforced by SafeBrowsingStoreFile's 720 // on the database's main thread as enforced by SafeBrowsingStoreFile's
728 // implementation. 721 // implementation.
729 const std::unique_ptr<SafeBrowsingStore> browse_store_; 722 const std::unique_ptr<SafeBrowsingStore> browse_store_;
730 const std::unique_ptr<SafeBrowsingStore> download_store_; 723 const std::unique_ptr<SafeBrowsingStore> download_store_;
731 const std::unique_ptr<SafeBrowsingStore> csd_whitelist_store_; 724 const std::unique_ptr<SafeBrowsingStore> csd_whitelist_store_;
732 const std::unique_ptr<SafeBrowsingStore> download_whitelist_store_; 725 const std::unique_ptr<SafeBrowsingStore> download_whitelist_store_;
733 const std::unique_ptr<SafeBrowsingStore> inclusion_whitelist_store_;
734 const std::unique_ptr<SafeBrowsingStore> extension_blacklist_store_; 726 const std::unique_ptr<SafeBrowsingStore> extension_blacklist_store_;
735 const std::unique_ptr<SafeBrowsingStore> ip_blacklist_store_; 727 const std::unique_ptr<SafeBrowsingStore> ip_blacklist_store_;
736 const std::unique_ptr<SafeBrowsingStore> unwanted_software_store_; 728 const std::unique_ptr<SafeBrowsingStore> unwanted_software_store_;
737 const std::unique_ptr<SafeBrowsingStore> module_whitelist_store_; 729 const std::unique_ptr<SafeBrowsingStore> module_whitelist_store_;
738 const std::unique_ptr<SafeBrowsingStore> resource_blacklist_store_; 730 const std::unique_ptr<SafeBrowsingStore> resource_blacklist_store_;
739 731
740 // Used to schedule resetting the database because of corruption. This factory 732 // Used to schedule resetting the database because of corruption. This factory
741 // and the WeakPtrs it issues should only be used on the database's main 733 // and the WeakPtrs it issues should only be used on the database's main
742 // thread. 734 // thread.
743 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; 735 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_;
744 }; 736 };
745 737
746 } // namespace safe_browsing 738 } // namespace safe_browsing
747 739
748 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 740 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | chrome/browser/safe_browsing/safe_browsing_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698