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

Unified Diff: components/safe_browsing_db/v4_local_database_manager.cc

Issue 2225613002: V4LDM: Add check for HashPrefix match and some tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move declaration of stores_to_look close to site of use. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/safe_browsing_db/v4_local_database_manager.cc
diff --git a/components/safe_browsing_db/v4_local_database_manager.cc b/components/safe_browsing_db/v4_local_database_manager.cc
index 5f555cfdd7333dc436696c4ac30767de7c779eb8..b5eb1b9afc0acfe461fe5b79eeb7d1e9df2636e3 100644
--- a/components/safe_browsing_db/v4_local_database_manager.cc
+++ b/components/safe_browsing_db/v4_local_database_manager.cc
@@ -42,8 +42,8 @@ bool V4LocalDatabaseManager::IsSupported() const {
return true;
}
-safe_browsing::ThreatSource V4LocalDatabaseManager::GetThreatSource() const {
- return safe_browsing::ThreatSource::LOCAL_PVER4;
+ThreatSource V4LocalDatabaseManager::GetThreatSource() const {
+ return ThreatSource::LOCAL_PVER4;
}
bool V4LocalDatabaseManager::ChecksAreAlwaysAsync() const {
@@ -140,8 +140,34 @@ bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) {
return true;
}
- // Don't defer the resource load.
- return true;
+ if (v4_database_) {
+ base::hash_set<FullHash> full_hashes;
+ V4ProtocolManagerUtil::UrlToFullHashes(url, &full_hashes);
+
+ base::hash_set<UpdateListIdentifier> stores_to_look(
+ {GetUrlMalwareId(), GetUrlSocEngId()});
+ base::hash_set<HashPrefix> matched_hash_prefixes;
+ base::hash_set<UpdateListIdentifier> matched_stores;
+ MatchedHashPrefixMap matched_hash_prefix_map;
+ for (const auto& full_hash : full_hashes) {
+ v4_database_->GetStoresMatchingFullHash(full_hash, stores_to_look,
+ &matched_hash_prefix_map);
+ for (const auto& matched_pair : matched_hash_prefix_map) {
+ matched_stores.insert(matched_pair.first);
+ matched_hash_prefixes.insert(matched_pair.second);
+ }
+ }
+
+ DCHECK_EQ(matched_stores.empty(), matched_hash_prefixes.empty());
+
+ // TODO(vakh): Return false and fetch full hashes for the matching hash
+ // prefixes.
+ return matched_hash_prefixes.empty();
+ } else {
+ // TODO(vakh): Queue the check and process it when the database becomes
+ // ready.
+ return false;
+ }
}
void V4LocalDatabaseManager::CancelCheck(Client* client) {

Powered by Google App Engine
This is Rietveld 408576698