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..f081afcdd67bd92ae6f94aa0eabd434c52808fab 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,11 @@ 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, make |allow_wildcard_effective_tld| true. |
|
Devlin
2017/02/14 23:17:10
allow_wildcard_effective_tld doesn't exist. :)
nrpeter
2017/03/22 23:47:39
Done.
|
| ParseResult Parse(const std::string& pattern_str); |
| + ParseResult Parse(const std::string& pattern_str, |
| + const ParseOptions parse_options); |
|
Devlin
2017/02/14 23:17:10
no need to pass an enum as const
nrpeter
2017/03/22 23:47:39
Done.
|
| // Gets the bitmask of valid schemes. |
| int valid_schemes() const { return valid_schemes_; } |
| @@ -119,6 +128,15 @@ class URLPattern { |
| bool match_subdomains() const { return match_subdomains_; } |
| void SetMatchSubdomains(bool val); |
| + // Gets whether host() contains an effective TLD. If false, durring |
|
Devlin
2017/02/14 23:17:10
s/durring/during
nrpeter
2017/03/22 23:47:39
Done.
|
| + // 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 |
| + 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 +261,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 ".*" |
| + // (e.g. https://example.*/*). |
| + bool match_effective_tld_; |
| + |
| // The port. |
| std::string port_; |