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

Side by Side Diff: chrome/browser/safe_browsing/local_database_manager.cc

Issue 2890293004: Add the ability to check the CSD Whitelist asynchronously, for PhishGuard. (Closed)
Patch Set: Respond to vakhs review, fix up tests Created 3 years, 6 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) 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 bool LocalSafeBrowsingDatabaseManager::MatchMalwareIP( 421 bool LocalSafeBrowsingDatabaseManager::MatchMalwareIP(
422 const std::string& ip_address) { 422 const std::string& ip_address) {
423 DCHECK_CURRENTLY_ON(BrowserThread::IO); 423 DCHECK_CURRENTLY_ON(BrowserThread::IO);
424 if (!enabled_ || !enable_ip_blacklist_ || !MakeDatabaseAvailable()) { 424 if (!enabled_ || !enable_ip_blacklist_ || !MakeDatabaseAvailable()) {
425 return false; // Fail open. 425 return false; // Fail open.
426 } 426 }
427 return database_->ContainsMalwareIP(ip_address); 427 return database_->ContainsMalwareIP(ip_address);
428 } 428 }
429 429
430 AsyncMatch LocalSafeBrowsingDatabaseManager::CheckCsdWhitelistUrl(
431 const GURL& url,
432 Client* Client) {
433 // Pver3 DB does not support actual partial-hash whitelists, so we emulate
434 // it. All this code will go away soon (~M62).
435 return (MatchCsdWhitelistUrl(url) ? AsyncMatch::MATCH : AsyncMatch::NO_MATCH);
436 }
437
430 bool LocalSafeBrowsingDatabaseManager::MatchCsdWhitelistUrl(const GURL& url) { 438 bool LocalSafeBrowsingDatabaseManager::MatchCsdWhitelistUrl(const GURL& url) {
431 DCHECK_CURRENTLY_ON(BrowserThread::IO); 439 DCHECK_CURRENTLY_ON(BrowserThread::IO);
432 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) { 440 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) {
433 // There is something funky going on here -- for example, perhaps the user 441 // There is something funky going on here -- for example, perhaps the user
434 // has not restarted since enabling metrics reporting, so we haven't 442 // has not restarted since enabling metrics reporting, so we haven't
435 // enabled the csd whitelist yet. Just to be safe we return true in this 443 // enabled the csd whitelist yet. Just to be safe we return true in this
436 // case. 444 // case.
437 return true; 445 return true;
438 } 446 }
439 return database_->ContainsCsdWhitelistedUrl(url); 447 return database_->ContainsCsdWhitelistedUrl(url);
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 base::BindOnce(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, 1262 base::BindOnce(&LocalSafeBrowsingDatabaseManager::TimeoutCallback,
1255 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr), 1263 check_ptr->weak_ptr_factory_->GetWeakPtr(), check_ptr),
1256 check_timeout_); 1264 check_timeout_);
1257 } 1265 }
1258 1266
1259 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const { 1267 bool LocalSafeBrowsingDatabaseManager::IsDownloadProtectionEnabled() const {
1260 return enable_download_protection_; 1268 return enable_download_protection_;
1261 } 1269 }
1262 1270
1263 } // namespace safe_browsing 1271 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698