Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/extensions/matcher/url_matcher.h" | 5 #include "chrome/common/extensions/matcher/url_matcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 } | 252 } |
| 253 | 253 |
| 254 URLMatcherCondition URLMatcherConditionFactory::CreatePathPrefixCondition( | 254 URLMatcherCondition URLMatcherConditionFactory::CreatePathPrefixCondition( |
| 255 const std::string& prefix) { | 255 const std::string& prefix) { |
| 256 return CreateCondition(URLMatcherCondition::PATH_PREFIX, | 256 return CreateCondition(URLMatcherCondition::PATH_PREFIX, |
| 257 kEndOfDomain + prefix); | 257 kEndOfDomain + prefix); |
| 258 } | 258 } |
| 259 | 259 |
| 260 URLMatcherCondition URLMatcherConditionFactory::CreatePathSuffixCondition( | 260 URLMatcherCondition URLMatcherConditionFactory::CreatePathSuffixCondition( |
| 261 const std::string& suffix) { | 261 const std::string& suffix) { |
| 262 return CreateCondition(URLMatcherCondition::HOST_SUFFIX, suffix + kEndOfPath); | 262 return CreateCondition(URLMatcherCondition::HOST_SUFFIX, suffix + kEndOfPath); |
|
Joao da Silva
2012/07/13 12:43:13
Hmm PATH_SUFFIX?
If you fix this, do you mind add
Bernhard Bauer
2012/07/13 14:21:07
It looks like using PATH_SUFFIX vs. HOST_SUFFIX do
battre
2012/07/13 15:28:54
I have a slight tendency towards sticking to the c
Joao da Silva
2012/07/13 15:37:12
The Criterion enum has the PATH_SUFFIX constant, b
Bernhard Bauer
2012/07/13 16:40:39
How about:
enum MatchAgainst {
MATCH_AGAINST_HO
battre
2012/07/16 09:17:00
I think that line 262 should contain PATH_SUFFIX
battre
2012/07/16 09:17:00
Frankly, I am not such a big fan of this, because
| |
| 263 } | 263 } |
| 264 | 264 |
| 265 URLMatcherCondition URLMatcherConditionFactory::CreatePathContainsCondition( | 265 URLMatcherCondition URLMatcherConditionFactory::CreatePathContainsCondition( |
| 266 const std::string& str) { | 266 const std::string& str) { |
| 267 return CreateCondition(URLMatcherCondition::PATH_CONTAINS, str); | 267 return CreateCondition(URLMatcherCondition::PATH_CONTAINS, str); |
| 268 } | 268 } |
| 269 | 269 |
| 270 URLMatcherCondition URLMatcherConditionFactory::CreatePathEqualsCondition( | 270 URLMatcherCondition URLMatcherConditionFactory::CreatePathEqualsCondition( |
| 271 const std::string& str) { | 271 const std::string& str) { |
| 272 return CreateCondition(URLMatcherCondition::PATH_EQUALS, | 272 return CreateCondition(URLMatcherCondition::PATH_EQUALS, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 296 } | 296 } |
| 297 | 297 |
| 298 URLMatcherCondition | 298 URLMatcherCondition |
| 299 URLMatcherConditionFactory::CreateHostSuffixPathPrefixCondition( | 299 URLMatcherConditionFactory::CreateHostSuffixPathPrefixCondition( |
| 300 const std::string& host_suffix, | 300 const std::string& host_suffix, |
| 301 const std::string& path_prefix) { | 301 const std::string& path_prefix) { |
| 302 return CreateCondition(URLMatcherCondition::HOST_SUFFIX_PATH_PREFIX, | 302 return CreateCondition(URLMatcherCondition::HOST_SUFFIX_PATH_PREFIX, |
| 303 host_suffix + kEndOfDomain + path_prefix); | 303 host_suffix + kEndOfDomain + path_prefix); |
| 304 } | 304 } |
| 305 | 305 |
| 306 URLMatcherCondition | |
| 307 URLMatcherConditionFactory::CreateHostEqualsPathPrefixCondition( | |
| 308 const std::string& host, | |
| 309 const std::string& path_prefix) { | |
| 310 return CreateCondition(URLMatcherCondition::HOST_EQUALS_PATH_PREFIX, | |
| 311 kBeginningOfURL + CanonicalizeHostname(host) + kEndOfDomain + | |
| 312 path_prefix); | |
| 313 } | |
| 314 | |
| 306 std::string URLMatcherConditionFactory::CanonicalizeURLForFullSearches( | 315 std::string URLMatcherConditionFactory::CanonicalizeURLForFullSearches( |
| 307 const GURL& url) { | 316 const GURL& url) { |
| 308 return kBeginningOfURL + CanonicalizeHostname(url.host()) + url.path() + | 317 return kBeginningOfURL + CanonicalizeHostname(url.host()) + url.path() + |
| 309 (url.has_query() ? "?" + url.query() : "") + kEndOfURL; | 318 (url.has_query() ? "?" + url.query() : "") + kEndOfURL; |
| 310 } | 319 } |
| 311 | 320 |
| 312 URLMatcherCondition URLMatcherConditionFactory::CreateURLPrefixCondition( | 321 URLMatcherCondition URLMatcherConditionFactory::CreateURLPrefixCondition( |
| 313 const std::string& prefix) { | 322 const std::string& prefix) { |
| 314 return CreateCondition(URLMatcherCondition::URL_PREFIX, | 323 return CreateCondition(URLMatcherCondition::URL_PREFIX, |
| 315 kBeginningOfURL + CanonicalizeHostname(prefix)); | 324 kBeginningOfURL + CanonicalizeHostname(prefix)); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 670 } | 679 } |
| 671 | 680 |
| 672 void URLMatcher::UpdateInternalDatastructures() { | 681 void URLMatcher::UpdateInternalDatastructures() { |
| 673 UpdateSubstringSetMatcher(false); | 682 UpdateSubstringSetMatcher(false); |
| 674 UpdateSubstringSetMatcher(true); | 683 UpdateSubstringSetMatcher(true); |
| 675 UpdateTriggers(); | 684 UpdateTriggers(); |
| 676 UpdateConditionFactory(); | 685 UpdateConditionFactory(); |
| 677 } | 686 } |
| 678 | 687 |
| 679 } // namespace extensions | 688 } // namespace extensions |
| OLD | NEW |