Index: extensions/common/url_pattern.h |
diff --git a/extensions/common/url_pattern.h b/extensions/common/url_pattern.h |
index 23f0687845ccb6c895bc2b9a0b4a7f401171f205..efb93faf36e74babae8bce40cff22ac67444cb7a 100644 |
--- a/extensions/common/url_pattern.h |
+++ b/extensions/common/url_pattern.h |
@@ -81,6 +81,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[]; |
@@ -107,8 +113,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(base::StringPiece pattern_str); |
+ ParseResult Parse(base::StringPiece pattern_str, ParseOptions parse_options); |
// Gets the bitmask of valid schemes. |
int valid_schemes() const { return valid_schemes_; } |
@@ -123,6 +131,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 |
+ 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_; } |
@@ -247,6 +264,12 @@ 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 ParseOptions is ALLOW_WILDCARD_FOR_EFFECTIVE_TLD |
+ // and is only applicable when the the pattern's host ends with ".*" |
+ // (e.g. https://example.*/*). |
+ bool match_effective_tld_; |
+ |
// The port. |
std::string port_; |