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

Unified Diff: chrome/browser/host_content_settings_map.cc

Issue 1744003: Send content settings based on the URL to the renderer instead of just the host. (Closed)
Patch Set: nits Created 10 years, 8 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 | « no previous file | chrome/browser/host_zoom_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/host_content_settings_map.cc
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc
index dfcdfad9a15b9282bc323b17bb663ac209bb7260..11a080e72575be0e3ba6422ac5737ae31a193199 100644
--- a/chrome/browser/host_content_settings_map.cc
+++ b/chrome/browser/host_content_settings_map.cc
@@ -28,6 +28,7 @@ namespace {
// - host (matches an exact hostname)
// - a.b.c.d (matches an exact IPv4 ip)
// - [a:b:c:d:e:f:g:h] (matches an exact IPv6 ip)
+// - file:///tmp/test.html (a complete URL without a host)
const int kContentSettingsPatternVersion = 1;
// The format of a domain wildcard.
@@ -36,17 +37,14 @@ const char kDomainWildcard[] = "[*.]";
// The length of kDomainWildcard (without the trailing '\0')
const size_t kDomainWildcardLength = arraysize(kDomainWildcard) - 1;
-// Returns the host part of an URL, or the spec, if no host is present.
-std::string HostFromURL(const GURL& url) {
- return url.has_host() ? net::TrimEndingDot(url.host()) : url.spec();
-}
} // namespace
// static
HostContentSettingsMap::Pattern HostContentSettingsMap::Pattern::FromURL(
const GURL& url) {
return Pattern(!url.has_host() || url.HostIsIPAddress() ?
- HostFromURL(url) : std::string(kDomainWildcard) + url.host());
+ net::GetHostOrSpecFromURL(url) :
+ std::string(kDomainWildcard) + url.host());
}
bool HostContentSettingsMap::Pattern::IsValid() const {
@@ -66,7 +64,7 @@ bool HostContentSettingsMap::Pattern::Matches(const GURL& url) const {
if (!IsValid())
return false;
- const std::string host(HostFromURL(url));
+ const std::string host(net::GetHostOrSpecFromURL(url));
if (pattern_.length() < kDomainWildcardLength ||
!StartsWithASCII(pattern_, kDomainWildcard, false))
return pattern_ == host;
@@ -227,7 +225,7 @@ ContentSettings HostContentSettingsMap::GetContentSettings(
AutoLock auto_lock(lock_);
- const std::string host(HostFromURL(url));
+ const std::string host(net::GetHostOrSpecFromURL(url));
// Check for exact matches first.
HostContentSettings::const_iterator i(host_content_settings_.find(host));
« no previous file with comments | « no previous file | chrome/browser/host_zoom_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698