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

Unified Diff: chrome/common/extensions/url_pattern.cc

Issue 8312005: Ignore paths when matching patterns for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix silly typo. Created 9 years, 2 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
Index: chrome/common/extensions/url_pattern.cc
diff --git a/chrome/common/extensions/url_pattern.cc b/chrome/common/extensions/url_pattern.cc
index d854be49731263b71d08e9f4693e72d35d32303a..91664f5dbebc8d52e5b614b76a1cbf7414048f22 100644
--- a/chrome/common/extensions/url_pattern.cc
+++ b/chrome/common/extensions/url_pattern.cc
@@ -307,24 +307,25 @@ bool URLPattern::SetPort(const std::string& port) {
return false;
}
-bool URLPattern::MatchesURL(const GURL &test) const {
+bool URLPattern::MatchesURL(const GURL& test) const {
if (!MatchesScheme(test.scheme()))
Aaron Boodman 2011/10/31 23:57:11 Can't testing the scheme and match_all_urls_ also
dcheng 2011/11/01 18:18:02 It won't have quite the same meaning if I move it
Aaron Boodman 2011/11/01 19:20:57 Sorry, I still don't see it. Coffee has not kicked
return false;
if (match_all_urls_)
return true;
- // Ignore hostname if scheme is file://.
- if (scheme_ != chrome::kFileScheme && !MatchesHost(test))
- return false;
+ return MatchesSecurityOriginHelper(test) &&
+ MatchesPath(test.PathForRequest());
+}
- if (!MatchesPath(test.PathForRequest()))
+bool URLPattern::MatchesSecurityOrigin(const GURL& test) const {
+ if (!MatchesScheme(test.scheme()))
return false;
- if (!MatchesPort(test.EffectiveIntPort()))
- return false;
+ if (match_all_urls_)
+ return true;
- return true;
+ return MatchesSecurityOriginHelper(test);
}
bool URLPattern::MatchesScheme(const std::string& test) const {
@@ -463,6 +464,17 @@ bool URLPattern::MatchesAnyScheme(
return false;
}
+bool URLPattern::MatchesSecurityOriginHelper(const GURL& test) const {
+ // Ignore hostname if scheme is file://.
+ if (scheme_ != chrome::kFileScheme && !MatchesHost(test))
+ return false;
+
+ if (!MatchesPort(test.EffectiveIntPort()))
+ return false;
+
+ return true;
+}
+
std::vector<std::string> URLPattern::GetExplicitSchemes() const {
std::vector<std::string> result;

Powered by Google App Engine
This is Rietveld 408576698