| 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 #include "chrome/browser/safe_browsing/local_database_manager.h" | 5 #include "chrome/browser/safe_browsing/local_database_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 const scoped_refptr<SafeBrowsingService>& service) | 261 const scoped_refptr<SafeBrowsingService>& service) |
| 262 : sb_service_(service), | 262 : sb_service_(service), |
| 263 database_(NULL), | 263 database_(NULL), |
| 264 enabled_(false), | 264 enabled_(false), |
| 265 enable_download_protection_(false), | 265 enable_download_protection_(false), |
| 266 enable_csd_whitelist_(false), | 266 enable_csd_whitelist_(false), |
| 267 enable_download_whitelist_(false), | 267 enable_download_whitelist_(false), |
| 268 enable_extension_blacklist_(false), | 268 enable_extension_blacklist_(false), |
| 269 enable_ip_blacklist_(false), | 269 enable_ip_blacklist_(false), |
| 270 enable_unwanted_software_blacklist_(true), | 270 enable_unwanted_software_blacklist_(true), |
| 271 enable_module_whitelist_(true), |
| 271 update_in_progress_(false), | 272 update_in_progress_(false), |
| 272 database_update_in_progress_(false), | 273 database_update_in_progress_(false), |
| 273 closing_database_(false), | 274 closing_database_(false), |
| 274 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { | 275 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { |
| 275 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 276 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 276 DCHECK(sb_service_.get() != NULL); | 277 DCHECK(sb_service_.get() != NULL); |
| 277 | 278 |
| 278 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 279 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 279 enable_download_protection_ = | 280 enable_download_protection_ = |
| 280 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 281 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } | 427 } |
| 427 | 428 |
| 428 bool LocalSafeBrowsingDatabaseManager::MatchInclusionWhitelistUrl( | 429 bool LocalSafeBrowsingDatabaseManager::MatchInclusionWhitelistUrl( |
| 429 const GURL& url) { | 430 const GURL& url) { |
| 430 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 431 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 431 if (!enabled_ || !MakeDatabaseAvailable()) | 432 if (!enabled_ || !MakeDatabaseAvailable()) |
| 432 return true; | 433 return true; |
| 433 return database_->ContainsInclusionWhitelistedUrl(url); | 434 return database_->ContainsInclusionWhitelistedUrl(url); |
| 434 } | 435 } |
| 435 | 436 |
| 437 bool LocalSafeBrowsingDatabaseManager::MatchModuleWhitelistString( |
| 438 const std::string& str) { |
| 439 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 440 if (!enabled_ || !enable_module_whitelist_ || !MakeDatabaseAvailable()) { |
| 441 return true; |
| 442 } |
| 443 return database_->ContainsModuleWhitelistedString(str); |
| 444 } |
| 445 |
| 436 bool LocalSafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { | 446 bool LocalSafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { |
| 437 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 447 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 438 if (!enabled_ || !MakeDatabaseAvailable()) { | 448 if (!enabled_ || !MakeDatabaseAvailable()) { |
| 439 return true; | 449 return true; |
| 440 } | 450 } |
| 441 return database_->IsMalwareIPMatchKillSwitchOn(); | 451 return database_->IsMalwareIPMatchKillSwitchOn(); |
| 442 } | 452 } |
| 443 | 453 |
| 444 bool LocalSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 454 bool LocalSafeBrowsingDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 445 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 455 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); | 783 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); |
| 774 | 784 |
| 775 if (database_) | 785 if (database_) |
| 776 return database_; | 786 return database_; |
| 777 | 787 |
| 778 const base::TimeTicks before = base::TimeTicks::Now(); | 788 const base::TimeTicks before = base::TimeTicks::Now(); |
| 779 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create( | 789 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create( |
| 780 safe_browsing_task_runner_, enable_download_protection_, | 790 safe_browsing_task_runner_, enable_download_protection_, |
| 781 enable_csd_whitelist_, enable_download_whitelist_, | 791 enable_csd_whitelist_, enable_download_whitelist_, |
| 782 enable_extension_blacklist_, enable_ip_blacklist_, | 792 enable_extension_blacklist_, enable_ip_blacklist_, |
| 783 enable_unwanted_software_blacklist_); | 793 enable_unwanted_software_blacklist_, enable_module_whitelist_); |
| 784 | 794 |
| 785 database->Init(SafeBrowsingService::GetBaseFilename()); | 795 database->Init(SafeBrowsingService::GetBaseFilename()); |
| 786 { | 796 { |
| 787 // Acquiring the lock here guarantees correct ordering between the writes to | 797 // Acquiring the lock here guarantees correct ordering between the writes to |
| 788 // the new database object above, and the setting of |database_| below. | 798 // the new database object above, and the setting of |database_| below. |
| 789 base::AutoLock lock(database_lock_); | 799 base::AutoLock lock(database_lock_); |
| 790 database_ = database; | 800 database_ = database; |
| 791 } | 801 } |
| 792 | 802 |
| 793 BrowserThread::PostTask( | 803 BrowserThread::PostTask( |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, | 1203 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, |
| 1194 check->weak_ptr_factory_->GetWeakPtr(), check), | 1204 check->weak_ptr_factory_->GetWeakPtr(), check), |
| 1195 check_timeout_); | 1205 check_timeout_); |
| 1196 } | 1206 } |
| 1197 | 1207 |
| 1198 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { | 1208 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { |
| 1199 return enable_download_protection_; | 1209 return enable_download_protection_; |
| 1200 } | 1210 } |
| 1201 | 1211 |
| 1202 } // namespace safe_browsing | 1212 } // namespace safe_browsing |
| OLD | NEW |