Index: chrome/browser/safe_browsing/local_database_manager.cc |
diff --git a/chrome/browser/safe_browsing/local_database_manager.cc b/chrome/browser/safe_browsing/local_database_manager.cc |
index f50e09893a8de26a7d976af89651a1768050ec06..9f23af35b679809ce3e82ce7d2c24d95752670a9 100644 |
--- a/chrome/browser/safe_browsing/local_database_manager.cc |
+++ b/chrome/browser/safe_browsing/local_database_manager.cc |
@@ -32,6 +32,7 @@ |
#include "chrome/common/chrome_paths.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
+#include "components/safe_browsing_db/util.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
#include "url/url_constants.h" |
@@ -47,7 +48,7 @@ const int kCheckTimeoutMs = 10000; |
// |true| if there were any prefix hits in |full_hashes|. |
void RecordGetHashCheckStatus( |
bool hit, |
- safe_browsing_util::ListType check_type, |
+ safe_browsing::ListType check_type, |
const std::vector<SBFullHashResult>& full_hashes) { |
SafeBrowsingProtocolManager::ResultType result; |
if (full_hashes.empty()) { |
@@ -57,7 +58,7 @@ void RecordGetHashCheckStatus( |
} else { |
result = SafeBrowsingProtocolManager::GET_HASH_FULL_HASH_MISS; |
} |
- bool is_download = check_type == safe_browsing_util::BINURL; |
+ bool is_download = check_type == safe_browsing::BINURL; |
SafeBrowsingProtocolManager::RecordGetHashResult(is_download, result); |
} |
@@ -71,32 +72,32 @@ bool IsExpectedThreat( |
// Return the severest list id from the results in |full_hashes| which matches |
// |hash|, or INVALID if none match. |
-safe_browsing_util::ListType GetHashSeverestThreatListType( |
+safe_browsing::ListType GetHashSeverestThreatListType( |
const SBFullHash& hash, |
const std::vector<SBFullHashResult>& full_hashes, |
size_t* index) { |
- safe_browsing_util::ListType pending_threat = safe_browsing_util::INVALID; |
+ safe_browsing::ListType pending_threat = safe_browsing::INVALID; |
for (size_t i = 0; i < full_hashes.size(); ++i) { |
- if (SBFullHashEqual(hash, full_hashes[i].hash)) { |
- const safe_browsing_util::ListType threat = |
- static_cast<safe_browsing_util::ListType>(full_hashes[i].list_id); |
+ if (safe_browsing::SBFullHashEqual(hash, full_hashes[i].hash)) { |
+ const safe_browsing::ListType threat = |
+ static_cast<safe_browsing::ListType>(full_hashes[i].list_id); |
switch (threat) { |
- case safe_browsing_util::INVALID: |
+ case safe_browsing::INVALID: |
// |full_hashes| should never contain INVALID as a |list_id|. |
NOTREACHED(); |
break; |
- case safe_browsing_util::MALWARE: // Falls through. |
- case safe_browsing_util::PHISH: // Falls through. |
- case safe_browsing_util::BINURL: // Falls through. |
- case safe_browsing_util::CSDWHITELIST: // Falls through. |
- case safe_browsing_util::DOWNLOADWHITELIST: // Falls through. |
- case safe_browsing_util::INCLUSIONWHITELIST: // Falls through. |
- case safe_browsing_util::EXTENSIONBLACKLIST: // Falls through. |
- case safe_browsing_util::IPBLACKLIST: |
+ case safe_browsing::MALWARE: // Falls through. |
+ case safe_browsing::PHISH: // Falls through. |
+ case safe_browsing::BINURL: // Falls through. |
+ case safe_browsing::CSDWHITELIST: // Falls through. |
+ case safe_browsing::DOWNLOADWHITELIST: // Falls through. |
+ case safe_browsing::INCLUSIONWHITELIST: // Falls through. |
+ case safe_browsing::EXTENSIONBLACKLIST: // Falls through. |
+ case safe_browsing::IPBLACKLIST: |
if (index) |
*index = i; |
return threat; |
- case safe_browsing_util::UNWANTEDURL: |
+ case safe_browsing::UNWANTEDURL: |
// UNWANTEDURL is considered less severe than other threats, keep |
// looking. |
pending_threat = threat; |
@@ -112,34 +113,34 @@ safe_browsing_util::ListType GetHashSeverestThreatListType( |
// Given a URL, compare all the possible host + path full hashes to the set of |
// provided full hashes. Returns the list id of the severest matching result |
// from |full_hashes|, or INVALID if none match. |
-safe_browsing_util::ListType GetUrlSeverestThreatListType( |
+safe_browsing::ListType GetUrlSeverestThreatListType( |
const GURL& url, |
const std::vector<SBFullHashResult>& full_hashes, |
size_t* index) { |
if (full_hashes.empty()) |
- return safe_browsing_util::INVALID; |
+ return safe_browsing::INVALID; |
std::vector<std::string> patterns; |
- safe_browsing_util::GeneratePatternsToCheck(url, &patterns); |
+ safe_browsing::GeneratePatternsToCheck(url, &patterns); |
- safe_browsing_util::ListType pending_threat = safe_browsing_util::INVALID; |
+ safe_browsing::ListType pending_threat = safe_browsing::INVALID; |
for (size_t i = 0; i < patterns.size(); ++i) { |
- safe_browsing_util::ListType threat = GetHashSeverestThreatListType( |
- SBFullHashForString(patterns[i]), full_hashes, index); |
+ safe_browsing::ListType threat = GetHashSeverestThreatListType( |
+ safe_browsing::SBFullHashForString(patterns[i]), full_hashes, index); |
switch (threat) { |
- case safe_browsing_util::INVALID: |
+ case safe_browsing::INVALID: |
// Ignore patterns with no matching threat. |
break; |
- case safe_browsing_util::MALWARE: // Falls through. |
- case safe_browsing_util::PHISH: // Falls through. |
- case safe_browsing_util::BINURL: // Falls through. |
- case safe_browsing_util::CSDWHITELIST: // Falls through. |
- case safe_browsing_util::DOWNLOADWHITELIST: // Falls through. |
- case safe_browsing_util::INCLUSIONWHITELIST: // Falls through. |
- case safe_browsing_util::EXTENSIONBLACKLIST: // Falls through. |
- case safe_browsing_util::IPBLACKLIST: |
+ case safe_browsing::MALWARE: // Falls through. |
+ case safe_browsing::PHISH: // Falls through. |
+ case safe_browsing::BINURL: // Falls through. |
+ case safe_browsing::CSDWHITELIST: // Falls through. |
+ case safe_browsing::DOWNLOADWHITELIST: // Falls through. |
+ case safe_browsing::INCLUSIONWHITELIST: // Falls through. |
+ case safe_browsing::EXTENSIONBLACKLIST: // Falls through. |
+ case safe_browsing::IPBLACKLIST: |
return threat; |
- case safe_browsing_util::UNWANTEDURL: |
+ case safe_browsing::UNWANTEDURL: |
// UNWANTEDURL is considered less severe than other threats, keep |
// looking. |
pending_threat = threat; |
@@ -149,17 +150,17 @@ safe_browsing_util::ListType GetUrlSeverestThreatListType( |
return pending_threat; |
} |
-SBThreatType GetThreatTypeFromListType(safe_browsing_util::ListType list_type) { |
+SBThreatType GetThreatTypeFromListType(safe_browsing::ListType list_type) { |
switch (list_type) { |
- case safe_browsing_util::PHISH: |
+ case safe_browsing::PHISH: |
return SB_THREAT_TYPE_URL_PHISHING; |
- case safe_browsing_util::MALWARE: |
+ case safe_browsing::MALWARE: |
return SB_THREAT_TYPE_URL_MALWARE; |
- case safe_browsing_util::UNWANTEDURL: |
+ case safe_browsing::UNWANTEDURL: |
return SB_THREAT_TYPE_URL_UNWANTED; |
- case safe_browsing_util::BINURL: |
+ case safe_browsing::BINURL: |
return SB_THREAT_TYPE_BINARY_MALWARE_URL; |
- case safe_browsing_util::EXTENSIONBLACKLIST: |
+ case safe_browsing::EXTENSIONBLACKLIST: |
return SB_THREAT_TYPE_EXTENSION; |
default: |
DVLOG(1) << "Unknown safe browsing list id " << list_type; |
@@ -190,7 +191,7 @@ LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck::SafeBrowsingCheck( |
const std::vector<GURL>& urls, |
const std::vector<SBFullHash>& full_hashes, |
Client* client, |
- safe_browsing_util::ListType check_type, |
+ safe_browsing::ListType check_type, |
const std::vector<SBThreatType>& expected_threats) |
: urls(urls), |
url_results(urls.size(), SB_THREAT_TYPE_SAFE), |
@@ -218,14 +219,14 @@ void LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck:: |
if (!urls.empty()) { |
DCHECK(full_hashes.empty()); |
switch (check_type) { |
- case safe_browsing_util::MALWARE: |
- case safe_browsing_util::PHISH: |
- case safe_browsing_util::UNWANTEDURL: |
+ case safe_browsing::MALWARE: |
+ case safe_browsing::PHISH: |
+ case safe_browsing::UNWANTEDURL: |
DCHECK_EQ(1u, urls.size()); |
client->OnCheckBrowseUrlResult(urls[0], url_results[0], |
url_metadata[0]); |
break; |
- case safe_browsing_util::BINURL: |
+ case safe_browsing::BINURL: |
DCHECK_EQ(urls.size(), url_results.size()); |
client->OnCheckDownloadUrlResult( |
urls, *std::max_element(url_results.begin(), url_results.end())); |
@@ -235,11 +236,11 @@ void LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck:: |
} |
} else if (!full_hashes.empty()) { |
switch (check_type) { |
- case safe_browsing_util::EXTENSIONBLACKLIST: { |
+ case safe_browsing::EXTENSIONBLACKLIST: { |
std::set<std::string> unsafe_extension_ids; |
for (size_t i = 0; i < full_hashes.size(); ++i) { |
std::string extension_id = |
- safe_browsing_util::SBFullHashToString(full_hashes[i]); |
+ safe_browsing::SBFullHashToString(full_hashes[i]); |
if (full_hash_results[i] == SB_THREAT_TYPE_EXTENSION) |
unsafe_extension_ids.insert(extension_id); |
} |
@@ -338,7 +339,7 @@ bool LocalSafeBrowsingDatabaseManager::CheckDownloadUrl( |
new SafeBrowsingCheck(url_chain, |
std::vector<SBFullHash>(), |
client, |
- safe_browsing_util::BINURL, |
+ safe_browsing::BINURL, |
std::vector<SBThreatType>(1, |
SB_THREAT_TYPE_BINARY_MALWARE_URL)); |
std::vector<SBPrefix> prefixes; |
@@ -361,7 +362,7 @@ bool LocalSafeBrowsingDatabaseManager::CheckExtensionIDs( |
std::vector<SBFullHash> extension_id_hashes; |
std::transform(extension_ids.begin(), extension_ids.end(), |
std::back_inserter(extension_id_hashes), |
- safe_browsing_util::StringToSBFullHash); |
+ safe_browsing::StringToSBFullHash); |
std::vector<SBPrefix> prefixes; |
for (const SBFullHash& hash : extension_id_hashes) |
prefixes.push_back(hash.prefix); |
@@ -370,7 +371,7 @@ bool LocalSafeBrowsingDatabaseManager::CheckExtensionIDs( |
std::vector<GURL>(), |
extension_id_hashes, |
client, |
- safe_browsing_util::EXTENSIONBLACKLIST, |
+ safe_browsing::EXTENSIONBLACKLIST, |
std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION)); |
StartSafeBrowsingCheck( |
check, |
@@ -458,7 +459,7 @@ bool LocalSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, |
const base::TimeTicks start = base::TimeTicks::Now(); |
if (!MakeDatabaseAvailable()) { |
- QueuedCheck queued_check(safe_browsing_util::MALWARE, // or PHISH |
+ QueuedCheck queued_check(safe_browsing::MALWARE, // or PHISH |
client, |
url, |
expected_threats, |
@@ -509,7 +510,7 @@ bool LocalSafeBrowsingDatabaseManager::CheckBrowseUrl(const GURL& url, |
SafeBrowsingCheck* check = new SafeBrowsingCheck(std::vector<GURL>(1, url), |
std::vector<SBFullHash>(), |
client, |
- safe_browsing_util::MALWARE, |
+ safe_browsing::MALWARE, |
expected_threats); |
check->need_get_hash = cache_hits.empty(); |
check->prefix_hits.swap(prefix_hits); |
@@ -671,7 +672,7 @@ void LocalSafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( |
} |
LocalSafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( |
- const safe_browsing_util::ListType check_type, |
+ const safe_browsing::ListType check_type, |
Client* client, |
const GURL& url, |
const std::vector<SBThreatType>& expected_threats, |
@@ -871,7 +872,7 @@ void LocalSafeBrowsingDatabaseManager::RequestFullHash( |
if (!enabled_) |
return; |
- bool is_download = check->check_type == safe_browsing_util::BINURL; |
+ bool is_download = check->check_type == safe_browsing::BINURL; |
sb_service_->protocol_manager()->GetFullHash( |
check->prefix_hits, |
base::Bind(&LocalSafeBrowsingDatabaseManager::HandleGetHashResults, |
@@ -1024,7 +1025,7 @@ void LocalSafeBrowsingDatabaseManager::OnHandleGetHashResults( |
SafeBrowsingCheck* check, |
const std::vector<SBFullHashResult>& full_hashes) { |
DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- safe_browsing_util::ListType check_type = check->check_type; |
+ safe_browsing::ListType check_type = check->check_type; |
SBPrefix prefix = check->prefix_hits[0]; |
GetHashRequests::iterator it = gethash_requests_.find(prefix); |
if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) { |