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

Unified Diff: chrome/browser/extensions/api/declarative/url_matcher.h

Issue 10052035: Implemented port filter for URLMatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment Created 8 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative/url_matcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/declarative/url_matcher.h
diff --git a/chrome/browser/extensions/api/declarative/url_matcher.h b/chrome/browser/extensions/api/declarative/url_matcher.h
index 5fdacb256a582a9d71f197d3c0424732d9c26a32..9bec45b32c3d675e7d93151b627bd015c415eef9 100644
--- a/chrome/browser/extensions/api/declarative/url_matcher.h
+++ b/chrome/browser/extensions/api/declarative/url_matcher.h
@@ -194,6 +194,27 @@ class URLMatcherSchemeFilter {
DISALLOW_COPY_AND_ASSIGN(URLMatcherSchemeFilter);
};
+// This class represents a filter for port numbers to be hooked up into a
+// URLMatcherConditionSet.
+class URLMatcherPortFilter {
+ public:
+ // Boundaries of a port range (both ends are included).
+ typedef std::pair<int, int> Range;
+ explicit URLMatcherPortFilter(const std::vector<Range>& ranges);
+ ~URLMatcherPortFilter();
+ bool IsMatch(const GURL& url) const;
+
+ // Creates a port range [from, to]; both ends are included.
+ static Range CreateRange(int from, int to);
+ // Creates a port range containing a single port.
+ static Range CreateRange(int port);
+
+ private:
+ std::vector<Range> ranges_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLMatcherPortFilter);
+};
+
// This class represents a set of conditions that all need to match on a
// given URL in order to be considered a match.
class URLMatcherConditionSet : public base::RefCounted<URLMatcherConditionSet> {
@@ -205,11 +226,12 @@ class URLMatcherConditionSet : public base::RefCounted<URLMatcherConditionSet> {
// Matches if all conditions in |conditions| are fulfilled.
URLMatcherConditionSet(ID id, const Conditions& conditions);
- // Matches if all conditions in |conditions| and |scheme_filter| are
- // fulfilled. |scheme_filter| may be NULL, in which case, no restrictions
- // are imposed on the scheme of a URL.
+ // Matches if all conditions in |conditions|, |scheme_filter| and
+ // |port_filter| are fulfilled. |scheme_filter| and |port_filter| may be NULL,
+ // in which case, no restrictions are imposed on the scheme/port of a URL.
URLMatcherConditionSet(ID id, const Conditions& conditions,
- scoped_ptr<URLMatcherSchemeFilter> scheme_filter);
+ scoped_ptr<URLMatcherSchemeFilter> scheme_filter,
+ scoped_ptr<URLMatcherPortFilter> port_filter);
ID id() const { return id_; }
const Conditions& conditions() const { return conditions_; }
@@ -224,6 +246,7 @@ class URLMatcherConditionSet : public base::RefCounted<URLMatcherConditionSet> {
ID id_;
Conditions conditions_;
scoped_ptr<URLMatcherSchemeFilter> scheme_filter_;
+ scoped_ptr<URLMatcherPortFilter> port_filter_;
DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionSet);
};
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative/url_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698