Chromium Code Reviews| 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; |