| 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 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // Returns threat level of the list. Lists with lower threat levels are more | 76 // Returns threat level of the list. Lists with lower threat levels are more |
| 77 // severe than lists with higher threat levels. Zero is the severest threat | 77 // severe than lists with higher threat levels. Zero is the severest threat |
| 78 // level possible. | 78 // level possible. |
| 79 int GetThreatSeverity(ListType threat) { | 79 int GetThreatSeverity(ListType threat) { |
| 80 switch (threat) { | 80 switch (threat) { |
| 81 case MALWARE: // Falls through. | 81 case MALWARE: // Falls through. |
| 82 case PHISH: // Falls through. | 82 case PHISH: // Falls through. |
| 83 case BINURL: // Falls through. | 83 case BINURL: // Falls through. |
| 84 case CSDWHITELIST: // Falls through. | 84 case CSDWHITELIST: // Falls through. |
| 85 case DOWNLOADWHITELIST: // Falls through. | 85 case DOWNLOADWHITELIST: // Falls through. |
| 86 case INCLUSIONWHITELIST: // Falls through. | |
| 87 case MODULEWHITELIST: // Falls through. | 86 case MODULEWHITELIST: // Falls through. |
| 88 case EXTENSIONBLACKLIST: // Falls through. | 87 case EXTENSIONBLACKLIST: // Falls through. |
| 89 case IPBLACKLIST: | 88 case IPBLACKLIST: |
| 90 return 0; | 89 return 0; |
| 91 case UNWANTEDURL: | 90 case UNWANTEDURL: |
| 92 // UNWANTEDURL is considered less severe than other threats. | 91 // UNWANTEDURL is considered less severe than other threats. |
| 93 return 1; | 92 return 1; |
| 94 case RESOURCEBLACKLIST: | 93 case RESOURCEBLACKLIST: |
| 95 // RESOURCEBLACKLIST is even less severe than UNWANTEDURL. | 94 // RESOURCEBLACKLIST is even less severe than UNWANTEDURL. |
| 96 return 2; | 95 return 2; |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 449 |
| 451 bool LocalSafeBrowsingDatabaseManager::MatchDownloadWhitelistString( | 450 bool LocalSafeBrowsingDatabaseManager::MatchDownloadWhitelistString( |
| 452 const std::string& str) { | 451 const std::string& str) { |
| 453 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 452 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 454 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { | 453 if (!enabled_ || !enable_download_whitelist_ || !MakeDatabaseAvailable()) { |
| 455 return true; | 454 return true; |
| 456 } | 455 } |
| 457 return database_->ContainsDownloadWhitelistedString(str); | 456 return database_->ContainsDownloadWhitelistedString(str); |
| 458 } | 457 } |
| 459 | 458 |
| 460 bool LocalSafeBrowsingDatabaseManager::MatchInclusionWhitelistUrl( | |
| 461 const GURL& url) { | |
| 462 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 463 if (!enabled_ || !MakeDatabaseAvailable()) | |
| 464 return true; | |
| 465 return database_->ContainsInclusionWhitelistedUrl(url); | |
| 466 } | |
| 467 | |
| 468 bool LocalSafeBrowsingDatabaseManager::MatchModuleWhitelistString( | 459 bool LocalSafeBrowsingDatabaseManager::MatchModuleWhitelistString( |
| 469 const std::string& str) { | 460 const std::string& str) { |
| 470 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 461 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 471 if (!enabled_ || !enable_module_whitelist_ || !MakeDatabaseAvailable()) { | 462 if (!enabled_ || !enable_module_whitelist_ || !MakeDatabaseAvailable()) { |
| 472 return true; | 463 return true; |
| 473 } | 464 } |
| 474 return database_->ContainsModuleWhitelistedString(str); | 465 return database_->ContainsModuleWhitelistedString(str); |
| 475 } | 466 } |
| 476 | 467 |
| 477 bool LocalSafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { | 468 bool LocalSafeBrowsingDatabaseManager::IsMalwareKillSwitchOn() { |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1252 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, | 1243 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, |
| 1253 check->weak_ptr_factory_->GetWeakPtr(), check), | 1244 check->weak_ptr_factory_->GetWeakPtr(), check), |
| 1254 check_timeout_); | 1245 check_timeout_); |
| 1255 } | 1246 } |
| 1256 | 1247 |
| 1257 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const { | 1248 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const { |
| 1258 return enable_download_protection_; | 1249 return enable_download_protection_; |
| 1259 } | 1250 } |
| 1260 | 1251 |
| 1261 } // namespace safe_browsing | 1252 } // namespace safe_browsing |
| OLD | NEW |