Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10144)

Unified Diff: chrome/common/extensions/url_pattern.h

Issue 7229012: Use extension match pattern syntax in content settings extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..78f12a50a16296f3f7ae2cff60829f1bb36325ab 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 IGNORE_PORTS
+// option. Unless the |ignore_ports| flag is set to false, the port will be
+// ignored for |MatchesURL| and |OverlapsWith| regardless.
Sam Kerner (Chrome) 2011/06/28 18:12:39 Comment out of date?
Bernhard Bauer 2011/06/29 13:53:18 Done.
// * 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_).
@@ -94,8 +98,9 @@ class URLPattern {
// Options for URLPattern::Parse().
enum ParseOption {
- PARSE_LENIENT,
- PARSE_STRICT
+ ERROR_ON_PORTS,
Sam Kerner (Chrome) 2011/06/28 18:12:39 Does IGNORE_PORTS mean http://foo.com:1234/* match
bauerb at google 2011/06/28 22:36:52 Yes, just like it did with PARSE_LENIENT.
+ IGNORE_PORTS,
+ USE_PORTS,
};
// Error codes returned from Parse().
@@ -108,6 +113,7 @@ class URLPattern {
PARSE_ERROR_INVALID_HOST_WILDCARD,
PARSE_ERROR_EMPTY_PATH,
PARSE_ERROR_HAS_COLON, // Only checked when strict checks are enabled.
Sam Kerner (Chrome) 2011/06/28 18:12:39 This comment needs an update: "strict checks" is n
Bernhard Bauer 2011/06/29 13:53:18 Done.
+ PARSE_ERROR_INVALID_PORT,
NUM_PARSE_RESULTS
};
@@ -194,6 +200,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 +273,10 @@ class URLPattern {
// component of the pattern's host was "*".
bool match_subdomains_;
+ // The port. URL patterns only support ports if they are parsed with the
+ // |USE_PORTS| 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_;

Powered by Google App Engine
This is Rietveld 408576698