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

Unified Diff: chrome/browser/safe_browsing/safe_browsing_util.cc

Issue 7792004: Parse the whitelist expressions from the phishing verdict response if (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Brian's comments Created 9 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_util.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index 9fe10edfad790e2a8430e7768c7d912558cbc29b..bb13a0077f3c2d6d1fbb31dc6f46926935831d47 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -417,6 +417,17 @@ void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths) {
paths->push_back(path + "?" + query);
}
+void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls) {
+ std::vector<std::string> hosts, paths;
+ GenerateHostsToCheck(url, &hosts);
+ GeneratePathsToCheck(url, &paths);
+ for (size_t h = 0; h < hosts.size(); ++h) {
+ for (size_t p = 0; p < paths.size(); ++p) {
+ urls->push_back(hosts[h] + paths[p]);
+ }
+ }
+}
+
int GetHashIndex(const SBFullHash& hash,
const std::vector<SBFullHashResult>& full_hashes) {
for (size_t i = 0; i < full_hashes.size(); ++i) {
@@ -431,21 +442,16 @@ int GetUrlHashIndex(const GURL& url,
if (full_hashes.empty())
return -1;
- std::vector<std::string> hosts, paths;
- GenerateHostsToCheck(url, &hosts);
- GeneratePathsToCheck(url, &paths);
+ std::vector<std::string> patterns;
+ GeneratePatternsToCheck(url, &patterns);
- for (size_t h = 0; h < hosts.size(); ++h) {
- for (size_t p = 0; p < paths.size(); ++p) {
- SBFullHash key;
- crypto::SHA256HashString(hosts[h] + paths[p],
- key.full_hash,
- sizeof(SBFullHash));
- int index = GetHashIndex(key, full_hashes);
- if (index != -1) return index;
- }
+ for (size_t i = 0; i < patterns.size(); ++i) {
+ SBFullHash key;
+ crypto::SHA256HashString(patterns[i], key.full_hash, sizeof(SBFullHash));
+ int index = GetHashIndex(key, full_hashes);
+ if (index != -1)
+ return index;
}
-
return -1;
}
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_util.h ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698