Chromium Code Reviews| Index: chrome/common/content_settings_pattern.cc |
| diff --git a/chrome/common/content_settings_pattern.cc b/chrome/common/content_settings_pattern.cc |
| index bf008020b00d1b67e802225cde82a769a9ca0c12..d33c453e612bc56642f77cce3724a07ff0e42104 100644 |
| --- a/chrome/common/content_settings_pattern.cc |
| +++ b/chrome/common/content_settings_pattern.cc |
| @@ -315,28 +315,33 @@ ContentSettingsPattern ContentSettingsPattern::FromURL( |
| scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( |
| ContentSettingsPattern::CreateBuilder(false)); |
| - if (url.SchemeIsFile()) { |
| - builder->WithScheme(url.scheme())->WithPath(url.path()); |
| + const GURL* local_url = &url; |
| + if (url.SchemeIsFileSystem() && url.inner_url()) { |
| + local_url = url.inner_url(); |
| + } |
| + if (local_url->SchemeIsFile()) { |
| + builder->WithScheme(local_url->scheme())->WithPath(local_url->path()); |
| } else { |
| // Please keep the order of the ifs below as URLs with an IP as host can |
| // also have a "http" scheme. |
| - if (url.HostIsIPAddress()) { |
| - builder->WithScheme(url.scheme())->WithHost(url.host()); |
| - } else if (url.SchemeIs(chrome::kHttpScheme)) { |
| - builder->WithSchemeWildcard()->WithDomainWildcard()->WithHost(url.host()); |
| - } else if (url.SchemeIs(chrome::kHttpsScheme)) { |
| - builder->WithScheme(url.scheme())->WithDomainWildcard()->WithHost( |
| - url.host()); |
| + if (local_url->HostIsIPAddress()) { |
| + builder->WithScheme(local_url->scheme())->WithHost(local_url->host()); |
| + } else if (local_url->SchemeIs(chrome::kHttpScheme)) { |
| + builder->WithSchemeWildcard()->WithDomainWildcard()->WithHost( |
| + local_url->host()); |
| + } else if (local_url->SchemeIs(chrome::kHttpsScheme)) { |
| + builder->WithScheme(local_url->scheme())->WithDomainWildcard()->WithHost( |
| + local_url->host()); |
| } else { |
| // Unsupported scheme |
| } |
| - if (url.port().empty()) { |
| - if (url.SchemeIs(chrome::kHttpsScheme)) |
| + if (local_url->port().empty()) { |
| + if (local_url->SchemeIs(chrome::kHttpsScheme)) |
| builder->WithPort(GetDefaultPort(chrome::kHttpsScheme)); |
| else |
| builder->WithPortWildcard(); |
| } else { |
| - builder->WithPort(url.port()); |
| + builder->WithPort(local_url->port()); |
| } |
| } |
| return builder->Build(); |
| @@ -348,14 +353,18 @@ ContentSettingsPattern ContentSettingsPattern::FromURLNoWildcard( |
| scoped_ptr<ContentSettingsPattern::BuilderInterface> builder( |
| ContentSettingsPattern::CreateBuilder(false)); |
| - if (url.SchemeIsFile()) { |
| - builder->WithScheme(url.scheme())->WithPath(url.path()); |
| + const GURL* local_url = &url; |
| + if (url.SchemeIsFileSystem() && url.inner_url()) { |
| + local_url = url.inner_url(); |
| + } |
| + if (local_url->SchemeIsFile()) { |
| + builder->WithScheme(local_url->scheme())->WithPath(local_url->path()); |
| } else { |
| - builder->WithScheme(url.scheme())->WithHost(url.host()); |
| - if (url.port().empty()) { |
| - builder->WithPort(GetDefaultPort(url.scheme())); |
| + builder->WithScheme(local_url->scheme())->WithHost(local_url->host()); |
| + if (local_url->port().empty()) { |
| + builder->WithPort(GetDefaultPort(local_url->scheme())); |
| } else { |
| - builder->WithPort(url.port()); |
| + builder->WithPort(local_url->port()); |
| } |
| } |
| return builder->Build(); |
| @@ -416,8 +425,13 @@ bool ContentSettingsPattern::Matches( |
| if (!is_valid_) |
| return false; |
| + const GURL* local_url = &url; |
| + if (url.SchemeIsFileSystem() && url.inner_url()) { |
| + local_url = url.inner_url(); |
| + } |
| + |
| // Match the scheme part. |
| - const std::string scheme(url.scheme()); |
| + const std::string scheme(local_url->scheme()); |
| if (!parts_.is_scheme_wildcard && |
| parts_.scheme != scheme) { |
| return false; |
| @@ -425,11 +439,14 @@ bool ContentSettingsPattern::Matches( |
| // File URLs have no host. Matches if the pattern has the path wildcard set, |
| // or if the path in the URL is identical to the one in the pattern. |
| + // For filesystem:file URLs, the path used is the filesystem type, so all |
| + // filesystem:file:///temporary/... are equivalent. |
|
markusheintz_
2012/02/28 23:20:09
Please add a TODO for me here:
TODO(markusheintz):
ericu
2012/02/28 23:27:15
Done, thanks.
|
| if (!parts_.is_scheme_wildcard && scheme == chrome::kFileScheme) |
| - return parts_.is_path_wildcard || parts_.path == std::string(url.path()); |
| + return parts_.is_path_wildcard || |
| + parts_.path == std::string(local_url->path()); |
| // Match the host part. |
| - const std::string host(net::TrimEndingDot(url.host())); |
| + const std::string host(net::TrimEndingDot(local_url->host())); |
| if (!parts_.has_domain_wildcard) { |
| if (parts_.host != host) |
| return false; |
| @@ -443,7 +460,7 @@ bool ContentSettingsPattern::Matches( |
| return true; |
| // Match the port part. |
| - std::string port(url.port()); |
| + std::string port(local_url->port()); |
| // Use the default port if the port string is empty. GURL returns an empty |
| // string if no port at all was specified or if the default port was |