| Index: chrome/browser/safe_browsing/safe_browsing_database.cc
|
| diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
|
| index 80c16f7bbd5e236f6cc5ebb5bbe0045c3c5a68a8..81948a60ddfce3b4ed8504acbf709664ae9ecce9 100644
|
| --- a/chrome/browser/safe_browsing/safe_browsing_database.cc
|
| +++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
|
| @@ -107,7 +107,7 @@
|
| return encoded_chunk_id >> 1;
|
| }
|
| int EncodeChunkId(const int chunk, const int list_id) {
|
| - DCHECK_NE(list_id, safe_browsing::INVALID);
|
| + DCHECK_NE(list_id, safe_browsing_util::INVALID);
|
| return chunk << 1 | list_id % 2;
|
| }
|
|
|
| @@ -128,17 +128,16 @@
|
| if (url.HostIsIPAddress()) {
|
| hosts.push_back(url.host());
|
| } else {
|
| - safe_browsing::GenerateHostsToCheck(url, &hosts);
|
| + safe_browsing_util::GenerateHostsToCheck(url, &hosts);
|
| }
|
|
|
| std::vector<std::string> paths;
|
| - safe_browsing::GeneratePathsToCheck(url, &paths);
|
| + safe_browsing_util::GeneratePathsToCheck(url, &paths);
|
|
|
| for (size_t i = 0; i < hosts.size(); ++i) {
|
| for (size_t j = 0; j < paths.size(); ++j) {
|
| const std::string& path = paths[j];
|
| - full_hashes->push_back(safe_browsing::SBFullHashForString(
|
| - hosts[i] + path));
|
| + full_hashes->push_back(SBFullHashForString(hosts[i] + path));
|
|
|
| // We may have /foo as path-prefix in the whitelist which should
|
| // also match with /foo/bar and /foo?bar. Hence, for every path
|
| @@ -147,8 +146,7 @@
|
| path.size() > 1 &&
|
| path[path.size() - 1] == '/') {
|
| full_hashes->push_back(
|
| - safe_browsing::SBFullHashForString(
|
| - hosts[i] + path.substr(0, path.size() - 1)));
|
| + SBFullHashForString(hosts[i] + path.substr(0, path.size() - 1)));
|
| }
|
| }
|
| }
|
| @@ -232,10 +230,10 @@
|
|
|
| for (size_t i = 0; i < listnames.size(); ++i) {
|
| const std::string& listname = listnames[i];
|
| - DCHECK_EQ(safe_browsing::GetListId(listname) % 2,
|
| + DCHECK_EQ(safe_browsing_util::GetListId(listname) % 2,
|
| static_cast<int>(i % 2));
|
| - DCHECK_NE(safe_browsing::GetListId(listname),
|
| - safe_browsing::INVALID);
|
| + DCHECK_NE(safe_browsing_util::GetListId(listname),
|
| + safe_browsing_util::INVALID);
|
| lists->push_back(SBListChunkRanges(listname));
|
| lists->back().adds.swap(adds[i]);
|
| lists->back().subs.swap(subs[i]);
|
| @@ -291,7 +289,7 @@
|
| // Find full-hash matches.
|
| std::vector<SBFullHashResult>& cached_hashes = cached_result.full_hashes;
|
| for (size_t i = 0; i < cached_hashes.size(); ++i) {
|
| - if (safe_browsing::SBFullHashEqual(full_hash, cached_hashes[i].hash))
|
| + if (SBFullHashEqual(full_hash, cached_hashes[i].hash))
|
| results->push_back(cached_hashes[i]);
|
| }
|
|
|
| @@ -447,22 +445,22 @@
|
| // Stores are not thread safe.
|
| DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
|
|
|
| - if (list_id == safe_browsing::PHISH ||
|
| - list_id == safe_browsing::MALWARE) {
|
| + if (list_id == safe_browsing_util::PHISH ||
|
| + list_id == safe_browsing_util::MALWARE) {
|
| return browse_store_.get();
|
| - } else if (list_id == safe_browsing::BINURL) {
|
| + } else if (list_id == safe_browsing_util::BINURL) {
|
| return download_store_.get();
|
| - } else if (list_id == safe_browsing::CSDWHITELIST) {
|
| + } else if (list_id == safe_browsing_util::CSDWHITELIST) {
|
| return csd_whitelist_store_.get();
|
| - } else if (list_id == safe_browsing::DOWNLOADWHITELIST) {
|
| + } else if (list_id == safe_browsing_util::DOWNLOADWHITELIST) {
|
| return download_whitelist_store_.get();
|
| - } else if (list_id == safe_browsing::INCLUSIONWHITELIST) {
|
| + } else if (list_id == safe_browsing_util::INCLUSIONWHITELIST) {
|
| return inclusion_whitelist_store_.get();
|
| - } else if (list_id == safe_browsing::EXTENSIONBLACKLIST) {
|
| + } else if (list_id == safe_browsing_util::EXTENSIONBLACKLIST) {
|
| return extension_blacklist_store_.get();
|
| - } else if (list_id == safe_browsing::IPBLACKLIST) {
|
| + } else if (list_id == safe_browsing_util::IPBLACKLIST) {
|
| return ip_blacklist_store_.get();
|
| - } else if (list_id == safe_browsing::UNWANTEDURL) {
|
| + } else if (list_id == safe_browsing_util::UNWANTEDURL) {
|
| return unwanted_software_store_.get();
|
| }
|
| return NULL;
|
| @@ -917,7 +915,7 @@
|
| return false;
|
|
|
| return MatchAddPrefixes(download_store_.get(),
|
| - safe_browsing::BINURL % 2,
|
| + safe_browsing_util::BINURL % 2,
|
| prefixes,
|
| prefix_hits);
|
| }
|
| @@ -949,7 +947,7 @@
|
| return false;
|
|
|
| return MatchAddPrefixes(extension_blacklist_store_.get(),
|
| - safe_browsing::EXTENSIONBLACKLIST % 2,
|
| + safe_browsing_util::EXTENSIONBLACKLIST % 2,
|
| prefixes,
|
| prefix_hits);
|
| }
|
| @@ -989,7 +987,7 @@
|
| bool SafeBrowsingDatabaseNew::ContainsDownloadWhitelistedString(
|
| const std::string& str) {
|
| std::vector<SBFullHash> hashes;
|
| - hashes.push_back(safe_browsing::SBFullHashForString(str));
|
| + hashes.push_back(SBFullHashForString(str));
|
| return ContainsWhitelistedHashes(SBWhitelistId::DOWNLOAD, hashes);
|
| }
|
|
|
| @@ -1003,7 +1001,7 @@
|
| for (std::vector<SBFullHash>::const_iterator it = hashes.begin();
|
| it != hashes.end(); ++it) {
|
| if (std::binary_search(whitelist->first.begin(), whitelist->first.end(),
|
| - *it, safe_browsing::SBFullHashLess)) {
|
| + *it, SBFullHashLess)) {
|
| return true;
|
| }
|
| }
|
| @@ -1013,7 +1011,7 @@
|
| // Helper to insert add-chunk entries.
|
| void SafeBrowsingDatabaseNew::InsertAddChunk(
|
| SafeBrowsingStore* store,
|
| - const safe_browsing::ListType list_id,
|
| + const safe_browsing_util::ListType list_id,
|
| const SBChunkData& chunk_data) {
|
| DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
|
| DCHECK(store);
|
| @@ -1042,7 +1040,7 @@
|
| // Helper to insert sub-chunk entries.
|
| void SafeBrowsingDatabaseNew::InsertSubChunk(
|
| SafeBrowsingStore* store,
|
| - const safe_browsing::ListType list_id,
|
| + const safe_browsing_util::ListType list_id,
|
| const SBChunkData& chunk_data) {
|
| DCHECK(db_task_runner_->RunsTasksOnCurrentThread());
|
| DCHECK(store);
|
| @@ -1085,8 +1083,8 @@
|
| const base::TimeTicks before = base::TimeTicks::Now();
|
|
|
| // TODO(shess): The caller should just pass list_id.
|
| - const safe_browsing::ListType list_id =
|
| - safe_browsing::GetListId(list_name);
|
| + const safe_browsing_util::ListType list_id =
|
| + safe_browsing_util::GetListId(list_name);
|
|
|
| SafeBrowsingStore* store = GetStore(list_id);
|
| if (!store) return;
|
| @@ -1118,8 +1116,8 @@
|
| return;
|
|
|
| const std::string& list_name = chunk_deletes.front().list_name;
|
| - const safe_browsing::ListType list_id =
|
| - safe_browsing::GetListId(list_name);
|
| + const safe_browsing_util::ListType list_id =
|
| + safe_browsing_util::GetListId(list_name);
|
|
|
| SafeBrowsingStore* store = GetStore(list_id);
|
| if (!store) return;
|
| @@ -1223,8 +1221,8 @@
|
| state_manager_.BeginWriteTransaction()->clear_prefix_gethash_cache();
|
|
|
| UpdateChunkRangesForLists(browse_store_.get(),
|
| - safe_browsing::kMalwareList,
|
| - safe_browsing::kPhishingList,
|
| + safe_browsing_util::kMalwareList,
|
| + safe_browsing_util::kPhishingList,
|
| lists);
|
|
|
| // NOTE(shess): |download_store_| used to contain kBinHashList, which has been
|
| @@ -1232,25 +1230,25 @@
|
| // of Feb 2014, so it has been removed. Everything _should_ be resilient to
|
| // extra data of that sort.
|
| UpdateChunkRangesForList(download_store_.get(),
|
| - safe_browsing::kBinUrlList, lists);
|
| + safe_browsing_util::kBinUrlList, lists);
|
|
|
| UpdateChunkRangesForList(csd_whitelist_store_.get(),
|
| - safe_browsing::kCsdWhiteList, lists);
|
| + safe_browsing_util::kCsdWhiteList, lists);
|
|
|
| UpdateChunkRangesForList(download_whitelist_store_.get(),
|
| - safe_browsing::kDownloadWhiteList, lists);
|
| + safe_browsing_util::kDownloadWhiteList, lists);
|
|
|
| UpdateChunkRangesForList(inclusion_whitelist_store_.get(),
|
| - safe_browsing::kInclusionWhitelist, lists);
|
| + safe_browsing_util::kInclusionWhitelist, lists);
|
|
|
| UpdateChunkRangesForList(extension_blacklist_store_.get(),
|
| - safe_browsing::kExtensionBlacklist, lists);
|
| + safe_browsing_util::kExtensionBlacklist, lists);
|
|
|
| UpdateChunkRangesForList(ip_blacklist_store_.get(),
|
| - safe_browsing::kIPBlacklist, lists);
|
| + safe_browsing_util::kIPBlacklist, lists);
|
|
|
| UpdateChunkRangesForList(unwanted_software_store_.get(),
|
| - safe_browsing::kUnwantedUrlList,
|
| + safe_browsing_util::kUnwantedUrlList,
|
| lists);
|
|
|
| db_state_manager_.reset_corruption_detected();
|
| @@ -1704,13 +1702,11 @@
|
| it != full_hashes.end(); ++it) {
|
| new_whitelist.push_back(it->full_hash);
|
| }
|
| - std::sort(new_whitelist.begin(), new_whitelist.end(),
|
| - safe_browsing::SBFullHashLess);
|
| -
|
| - SBFullHash kill_switch = safe_browsing::SBFullHashForString(
|
| - kWhitelistKillSwitchUrl);
|
| + std::sort(new_whitelist.begin(), new_whitelist.end(), SBFullHashLess);
|
| +
|
| + SBFullHash kill_switch = SBFullHashForString(kWhitelistKillSwitchUrl);
|
| if (std::binary_search(new_whitelist.begin(), new_whitelist.end(),
|
| - kill_switch, safe_browsing::SBFullHashLess)) {
|
| + kill_switch, SBFullHashLess)) {
|
| // The kill switch is whitelisted hence we whitelist all URLs.
|
| state_manager_.BeginWriteTransaction()->WhitelistEverything(whitelist_id);
|
| } else {
|
| @@ -1760,8 +1756,7 @@
|
| }
|
|
|
| bool SafeBrowsingDatabaseNew::IsMalwareIPMatchKillSwitchOn() {
|
| - SBFullHash malware_kill_switch = safe_browsing::SBFullHashForString(
|
| - kMalwareIPKillSwitchUrl);
|
| + SBFullHash malware_kill_switch = SBFullHashForString(kMalwareIPKillSwitchUrl);
|
| std::vector<SBFullHash> full_hashes;
|
| full_hashes.push_back(malware_kill_switch);
|
| return ContainsWhitelistedHashes(SBWhitelistId::CSD, full_hashes);
|
|
|