 Chromium Code Reviews
 Chromium Code Reviews Issue 7229012:
  Use extension match pattern syntax in content settings extension API  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 7229012:
  Use extension match pattern syntax in content settings extension API  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/common/extensions/url_pattern.h | 
| diff --git a/chrome/common/extensions/url_pattern.h b/chrome/common/extensions/url_pattern.h | 
| index 264da1fb24b36154a59c46f7c0b07f366327bc31..197669dede15a61bc647c73f711a20f0c383335b 100644 | 
| --- a/chrome/common/extensions/url_pattern.h | 
| +++ b/chrome/common/extensions/url_pattern.h | 
| @@ -14,12 +14,16 @@ class GURL; | 
| // A pattern that can be used to match URLs. A URLPattern is a very restricted | 
| // subset of URL syntax: | 
| // | 
| -// <url-pattern> := <scheme>://<host><path> | '<all_urls>' | 
| +// <url-pattern> := <scheme>://<host><port><path> | '<all_urls>' | 
| // <scheme> := '*' | 'http' | 'https' | 'file' | 'ftp' | 'chrome' | 
| // <host> := '*' | '*.' <anychar except '/' and '*'>+ | 
| +// <port> := [':' ('*' | <port number between 0 and 65535>)] | 
| // <path> := '/' <any chars> | 
| // | 
| // * Host is not used when the scheme is 'file'. | 
| +// * The port is only allowed when the pattern is parsed with the PARSE_LENIENT | 
| 
Sam Kerner (Chrome)
2011/06/27 17:58:25
The idea of lenient vs. strict parsing made sense
 | 
| +// option. If the |port_allowed| flag is not set, the port will be ignored | 
| +// regardless. | 
| // * The path can have embedded '*' characters which act as glob wildcards. | 
| // * '<all_urls>' is a special pattern that matches any URL that contains a | 
| // valid scheme (as specified by valid_schemes_). | 
| @@ -108,6 +112,7 @@ class URLPattern { | 
| PARSE_ERROR_INVALID_HOST_WILDCARD, | 
| PARSE_ERROR_EMPTY_PATH, | 
| PARSE_ERROR_HAS_COLON, // Only checked when strict checks are enabled. | 
| + PARSE_ERROR_INVALID_PORT, | 
| NUM_PARSE_RESULTS | 
| }; | 
| @@ -155,6 +160,9 @@ class URLPattern { | 
| bool match_all_urls() const { return match_all_urls_; } | 
| void set_match_all_urls(bool val) { match_all_urls_ = val; } | 
| + bool ignore_ports() const { return ignore_ports_; } | 
| + void set_ignore_ports(bool val) { ignore_ports_ = val; } | 
| + | 
| // 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 | 
| @@ -194,6 +202,13 @@ class URLPattern { | 
| // Returns true if |test| matches our path. | 
| bool MatchesPath(const std::string& test) const; | 
| + // Returns true if |test| matches our port. | 
| + bool MatchesPort(const std::string& test) const; | 
| + | 
| + // Sets the port. Returns false if the port is invalid. | 
| + bool SetPort(const std::string& port); | 
| + const std::string& port() const { return port_; } | 
| + | 
| // Returns a string representing this instance. | 
| std::string GetAsString() const; | 
| @@ -260,6 +275,13 @@ class URLPattern { | 
| // component of the pattern's host was "*". | 
| bool match_subdomains_; | 
| + // Whether we silently ignore ports when testing for matches or overlaps. | 
| + bool ignore_ports_; | 
| + | 
| + // The port. URL patterns only support ports if they are parsed with the | 
| + // |PARSE_LENIENT| option. | 
| + std::string port_; | 
| + | 
| // The path to match. This is everything after the host of the URL, or | 
| // everything after the scheme in the case of file:// URLs. | 
| std::string path_; |