Index: chrome/common/extensions/url_pattern.cc |
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc |
index ac648114aaed54e93ec873b92dbd71afe384ae42..e7411a1c7a35d0f2661ff60f337f4ba849ec5793 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)) |
@@ -249,6 +252,10 @@ void URLPattern::SetMatchAllURLs(bool val) { |
} |
} |
+void URLPattern::set_partial_filesystem_support_hack(bool val) { |
Aaron Boodman
2012/03/23 21:48:32
Pure setters like this are typically in the .h fil
ericu
2012/03/23 22:47:15
Done.
|
+ partial_filesystem_support_hack_ = val; |
+} |
+ |
void URLPattern::SetMatchSubdomains(bool val) { |
spec_.clear(); |
match_subdomains_ = val; |
@@ -295,14 +302,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, has_inner_url); |
} |
bool URLPattern::MatchesSecurityOrigin(const GURL& test) const { |
@@ -361,7 +381,10 @@ bool URLPattern::MatchesHost(const GURL& test) const { |
return test.host()[test.host().length() - host_.length() - 1] == '.'; |
} |
-bool URLPattern::MatchesPath(const std::string& test) const { |
+bool URLPattern::MatchesPath(const std::string& test, bool nested_url) |
Aaron Boodman
2012/03/23 21:48:32
I don't understand why the nested_url param is nec
ericu
2012/03/23 22:47:15
The caller is telling us where he got the path. I
ericu
2012/03/23 23:48:46
Param removed.
|
+ const { |
+ if (nested_url != partial_filesystem_support_hack_) |
+ return false; |
if (!MatchPattern(test, path_escaped_)) |
return false; |
@@ -433,8 +456,14 @@ bool URLPattern::OverlapsWith(const URLPattern& other) const { |
DCHECK(path_.find('*') == path_.size() - 1); |
DCHECK(other.path().find('*') == other.path().size() - 1); |
- if (!MatchesPath(other.path().substr(0, other.path().size() - 1)) && |
- !other.MatchesPath(path_.substr(0, 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), |
+ partial_filesystem_support_hack_) && |
+ !other.MatchesPath(path_.substr(0, path_.size() - 1), |
+ partial_filesystem_support_hack_)) |
return false; |
return true; |