diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 07:17:54 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-23 07:17:54 +0000 |
commit | 9d797f394f319b754ed91a981dab566d764d2c2e (patch) | |
tree | aee695b1c2af9d540e3fe99d834de015f70665cf /chrome/browser/host_content_settings_map.cc | |
parent | 97c9e77b34099c518f85571f6d36e178d7695b23 (diff) | |
download | chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.zip chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.gz chromium_src-9d797f394f319b754ed91a981dab566d764d2c2e.tar.bz2 |
Send content settings based on the URL to the renderer instead of just the host.
BUG=36025
TEST=manual
Review URL: http://codereview.chromium.org/1744003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/host_content_settings_map.cc')
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index dfcdfad..11a080e 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)); |