diff options
author | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 16:56:58 +0000 |
---|---|---|
committer | ericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-24 16:56:58 +0000 |
commit | 932df839a6562730cd741f24fc469606d9d9ffb7 (patch) | |
tree | 2c244f93639d2c0f50e6e917cc01ea33fd637a43 /chrome/common/extensions/url_pattern.cc | |
parent | 3bfc16cf47deae24f43b3967edf769112a674482 (diff) | |
download | chromium_src-932df839a6562730cd741f24fc469606d9d9ffb7.zip chromium_src-932df839a6562730cd741f24fc469606d9d9ffb7.tar.gz chromium_src-932df839a6562730cd741f24fc469606d9d9ffb7.tar.bz2 |
Add full support for filesystem URLs.
BUG=114484
TEST=existing filesystem tests don't break
Review URL: https://chromiumcodereview.appspot.com/7811006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/url_pattern.cc')
-rw-r--r-- | chrome/common/extensions/url_pattern.cc | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc index ac64811..c0b04b7 100644 --- a/chrome/common/extensions/url_pattern.cc +++ b/chrome/common/extensions/url_pattern.cc @@ -97,12 +97,14 @@ bool IsValidPortForScheme(const std::string scheme, const std::string& port) { URLPattern::URLPattern() : valid_schemes_(SCHEME_NONE), match_all_urls_(false), + partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") {} URLPattern::URLPattern(int valid_schemes) : valid_schemes_(valid_schemes), match_all_urls_(false), + partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") {} @@ -111,6 +113,7 @@ URLPattern::URLPattern(int valid_schemes, const std::string& pattern) // appropriate when we know |pattern| is valid. : valid_schemes_(valid_schemes), match_all_urls_(false), + partial_filesystem_support_hack_(false), match_subdomains_(false), port_("*") { if (PARSE_SUCCESS != Parse(pattern)) @@ -295,14 +298,27 @@ bool URLPattern::SetPort(const std::string& port) { } bool URLPattern::MatchesURL(const GURL& test) const { - if (!MatchesScheme(test.scheme())) + const GURL* test_url = &test; + bool has_inner_url = test.inner_url() != NULL; + + if (partial_filesystem_support_hack_ != has_inner_url) + return false; + + if (has_inner_url) + test_url = test.inner_url(); + + if (!MatchesScheme(test_url->scheme())) return false; if (match_all_urls_) return true; - return MatchesSecurityOriginHelper(test) && - MatchesPath(test.PathForRequest()); + std::string path_for_request = test.PathForRequest(); + if (has_inner_url) + path_for_request = test_url->path() + path_for_request; + + return MatchesSecurityOriginHelper(*test_url) && + MatchesPath(path_for_request); } bool URLPattern::MatchesSecurityOrigin(const GURL& test) const { @@ -433,6 +449,10 @@ bool URLPattern::OverlapsWith(const URLPattern& other) const { DCHECK(path_.find('*') == path_.size() - 1); DCHECK(other.path().find('*') == other.path().size() - 1); + if (partial_filesystem_support_hack_ != + other.partial_filesystem_support_hack()) + return false; + if (!MatchesPath(other.path().substr(0, other.path().size() - 1)) && !other.MatchesPath(path_.substr(0, path_.size() - 1))) return false; |