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