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

Unified Diff: chrome/browser/managed_mode/managed_mode_url_filter.cc

Issue 63423003: Set ENABLE_MANAGED_USERS #ifdef on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 7 years, 1 month 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: chrome/browser/managed_mode/managed_mode_url_filter.cc
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter.cc b/chrome/browser/managed_mode/managed_mode_url_filter.cc
index 1a16694cbce4609ad0a89c4002530012d0128d62..174257d6850d50f38b6af370cd4ac0ad0cce2c73 100644
--- a/chrome/browser/managed_mode/managed_mode_url_filter.cc
+++ b/chrome/browser/managed_mode/managed_mode_url_filter.cc
@@ -208,6 +208,11 @@ bool ManagedModeURLFilter::HasStandardScheme(const GURL& url) {
return false;
}
+std::string GetHostnameHash(const GURL& url) {
+ std::string hash = base::SHA1HashString(url.host());
+ return base::HexEncode(hash.data(), hash.length());
+}
+
// static
bool ManagedModeURLFilter::HostMatchesPattern(const std::string& host,
const std::string& pattern) {
@@ -286,9 +291,7 @@ ManagedModeURLFilter::GetFilteringBehaviorForURL(const GURL& url) const {
return ALLOW;
// Check the list of hostname hashes.
- std::string hash = base::SHA1HashString(url.host());
- std::string hash_hex = base::HexEncode(hash.data(), hash.length());
- if (contents_->hash_site_map.count(hash_hex))
+ if (contents_->hash_site_map.count(GetHostnameHash(url)))
return ALLOW;
// Fall back to the default behavior.
@@ -311,10 +314,10 @@ void ManagedModeURLFilter::GetSites(
sites->push_back(&contents_->sites[entry->second]);
}
- typedef base::hash_map<std::string, int>::const_iterator
+ typedef base::hash_multimap<std::string, int>::const_iterator
hash_site_map_iterator;
std::pair<hash_site_map_iterator, hash_site_map_iterator> bounds =
- contents_->hash_site_map.equal_range(url.host());
+ contents_->hash_site_map.equal_range(GetHostnameHash(url));
for (hash_site_map_iterator hash_it = bounds.first;
hash_it != bounds.second; hash_it++) {
sites->push_back(&contents_->sites[hash_it->second]);
« no previous file with comments | « chrome/browser/managed_mode/managed_mode_navigation_observer.cc ('k') | chrome/browser/managed_mode/managed_user_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698