Chromium Code Reviews| Index: extensions/common/url_pattern.h |
| diff --git a/extensions/common/url_pattern.h b/extensions/common/url_pattern.h |
| index ef118e4fd8406747c07a64f87e6285647b3a4683..48f83c05d19dd638798ec176f59f45cac1539985 100644 |
| --- a/extensions/common/url_pattern.h |
| +++ b/extensions/common/url_pattern.h |
| @@ -77,6 +77,12 @@ class URLPattern { |
| NUM_PARSE_RESULTS |
| }; |
| + // Types of URLPattern that Parse() considers valid. |
| + enum ParseOptions { |
| + DENY_WILDCARD_FOR_EFFECTIVE_TLD, |
| + ALLOW_WILDCARD_FOR_EFFECTIVE_TLD, |
| + }; |
| + |
| // The <all_urls> string pattern. |
| static const char kAllUrlsPattern[]; |
| @@ -103,8 +109,10 @@ class URLPattern { |
| // Initializes this instance by parsing the provided string. Returns |
| // URLPattern::PARSE_SUCCESS on success, or an error code otherwise. On |
| // failure, this instance will have some intermediate values and is in an |
| - // invalid state. |
| + // invalid state. If you want to allow the match pattern to specify a wildcard |
| + // for the effective TLD, specify in |parse_options|. |
| ParseResult Parse(const std::string& pattern_str); |
| + ParseResult Parse(const std::string& pattern_str, ParseOptions parse_options); |
| // Gets the bitmask of valid schemes. |
| int valid_schemes() const { return valid_schemes_; } |
| @@ -119,6 +127,15 @@ class URLPattern { |
| bool match_subdomains() const { return match_subdomains_; } |
| void SetMatchSubdomains(bool val); |
| + // Gets whether host() contains an effective TLD. If false, during |
| + // a match, the URL you're comparing must have its TLD removed |
| + // prior to comparison. |
| + // e.g. For the match pattern https://google.com/* |
| + // If this is true: host() would be google.com |
| + // If this is false host() would be google |
|
Devlin
2017/04/07 00:40:27
nitty nit: my orderly persona requires a ':' after
nrpeter
2017/04/12 23:35:45
Done.
|
| + bool match_effective_tld() const { return match_effective_tld_; } |
| + void SetMatchEffectiveTld(bool val); |
| + |
| // Gets the path the pattern matches with the leading slash. This can have |
| // embedded asterisks which are interpreted using glob rules. |
| const std::string& path() const { return path_; } |
| @@ -243,6 +260,11 @@ class URLPattern { |
| // component of the pattern's host was "*". |
| bool match_subdomains_; |
| + // Whether we should match the effective TLD of the host. This is true by |
| + // default and only false if the the pattern's host ends with ".*" |
|
Devlin
2017/04/07 00:40:27
nit: This isn't false if the patterns host ends wi
nrpeter
2017/04/12 23:35:45
Done.
|
| + // (e.g. https://example.*/*). |
| + bool match_effective_tld_; |
| + |
| // The port. |
| std::string port_; |