Chromium Code Reviews| Index: chrome/common/extensions/matcher/url_matcher.cc |
| diff --git a/chrome/common/extensions/matcher/url_matcher.cc b/chrome/common/extensions/matcher/url_matcher.cc |
| index 722efd9c3c633e6898c7f4462cdc181fbd387dac..678983aa5e64ec533005096298bea1ae4eb9f81b 100644 |
| --- a/chrome/common/extensions/matcher/url_matcher.cc |
| +++ b/chrome/common/extensions/matcher/url_matcher.cc |
| @@ -8,6 +8,7 @@ |
| #include <iterator> |
| #include "base/logging.h" |
| +#include "content/public/common/url_constants.h" |
| #include "googleurl/src/gurl.h" |
| namespace extensions { |
| @@ -88,19 +89,18 @@ namespace extensions { |
| // Case 2: url_{prefix,suffix,equals,contains} searches. |
| // ===================================================== |
| // |
| -// Step 1: as above |
| +// Step 1: as above, except that the scheme is not removed. |
| // |
| // Step 2: |
| // Translate URL to String and add the following position markers: |
| // - BU = Beginning of URL |
| // - EU = End of URL |
| -// Furthermore, the hostname is canonicalized to start with a ".". |
| // |
| -// -> www.example.com/index.html?search=foo becomes |
| -// BU .www.example.com/index.html?search=foo EU |
| +// -> http://www.example.com:8080/index.html?search=foo#first_match becomes |
| +// BU http://www.example.com/index.html?search=foo EU |
| // |
| -// url_prefix(prefix) = BU add_missing_dot_prefix(prefix) |
| -// -> url_prefix("www.example") = BU .www.example |
| +// url_prefix(prefix) = BU prefix |
| +// -> url_prefix("http://www.example") = BU http://www.example |
| // |
| // url_contains(substring) = substring |
| // -> url_contains("index") = index |
| @@ -113,7 +113,7 @@ namespace extensions { |
| // by a combination of a url_contains() query followed by an explicit test: |
| // |
| // host_contains(str) = url_contains(str) followed by test whether str occurs |
| -// in host comonent of original URL. |
| +// in host component of original URL. |
| // -> host_contains("example.co") = example.co |
| // followed by gurl.host().find("example.co"); |
| // |
| @@ -160,7 +160,7 @@ bool URLMatcherCondition::operator<(const URLMatcherCondition& rhs) const { |
| bool URLMatcherCondition::IsFullURLCondition() const { |
| // For these criteria the SubstringMatcher needs to be executed on the |
| - // GURL that is canonlizaliced with |
| + // GURL that is canonicalized with |
| // URLMatcherConditionFactory::CanonicalizeURLForFullSearches. |
| switch (criterion_) { |
| case HOST_CONTAINS: |
| @@ -314,14 +314,15 @@ URLMatcherConditionFactory::CreateHostEqualsPathPrefixCondition( |
| std::string URLMatcherConditionFactory::CanonicalizeURLForFullSearches( |
| const GURL& url) { |
| - return kBeginningOfURL + CanonicalizeHostname(url.host()) + url.path() + |
| - (url.has_query() ? "?" + url.query() : "") + kEndOfURL; |
| + return kBeginningOfURL + url.scheme() + content::kStandardSchemeSeparator + |
|
Yoyo Zhou
2012/08/15 17:53:12
By the way, I just learned about GURL::Replacement
battre
2012/08/16 13:16:25
I was aware of this. I cannot use the GURL::Replac
|
| + url.host() + url.path() + (url.has_query() ? "?" + url.query() : "") + |
| + kEndOfURL; |
| } |
| URLMatcherCondition URLMatcherConditionFactory::CreateURLPrefixCondition( |
| const std::string& prefix) { |
| return CreateCondition(URLMatcherCondition::URL_PREFIX, |
| - kBeginningOfURL + CanonicalizeHostname(prefix)); |
| + kBeginningOfURL + prefix); |
| } |
| URLMatcherCondition URLMatcherConditionFactory::CreateURLSuffixCondition( |
| @@ -337,7 +338,7 @@ URLMatcherCondition URLMatcherConditionFactory::CreateURLContainsCondition( |
| URLMatcherCondition URLMatcherConditionFactory::CreateURLEqualsCondition( |
| const std::string& str) { |
| return CreateCondition(URLMatcherCondition::URL_EQUALS, |
| - kBeginningOfURL + CanonicalizeHostname(str) + kEndOfURL); |
| + kBeginningOfURL + str + kEndOfURL); |
| } |
| void URLMatcherConditionFactory::ForgetUnusedPatterns( |