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

Side by Side Diff: chrome/browser/extensions/api/declarative/url_matcher.h

Issue 10012004: Implemented proper support for checking schemes and requested resource types. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed 'scheme' to 'schemes' 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative/url_matcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 }; 172 };
173 // Set to ensure that we generate only one SubstringPattern for each content 173 // Set to ensure that we generate only one SubstringPattern for each content
174 // of SubstringPattern::pattern(). 174 // of SubstringPattern::pattern().
175 typedef std::set<SubstringPattern*, SubstringPatternPointerCompare> 175 typedef std::set<SubstringPattern*, SubstringPatternPointerCompare>
176 PatternSingletons; 176 PatternSingletons;
177 PatternSingletons pattern_singletons_; 177 PatternSingletons pattern_singletons_;
178 178
179 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionFactory); 179 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionFactory);
180 }; 180 };
181 181
182 // This class represents a filter for the URL scheme to be hooked up into a
183 // URLMatcherConditionSet.
184 class URLMatcherSchemeFilter {
185 public:
186 explicit URLMatcherSchemeFilter(const std::string& filter);
187 explicit URLMatcherSchemeFilter(const std::vector<std::string>& filters);
188 ~URLMatcherSchemeFilter();
189 bool IsMatch(const GURL& url) const;
190
191 private:
192 std::vector<std::string> filters_;
193
194 DISALLOW_COPY_AND_ASSIGN(URLMatcherSchemeFilter);
195 };
196
182 // This class represents a set of conditions that all need to match on a 197 // This class represents a set of conditions that all need to match on a
183 // given URL in order to be considered a match. 198 // given URL in order to be considered a match.
184 class URLMatcherConditionSet : public base::RefCounted<URLMatcherConditionSet> { 199 class URLMatcherConditionSet : public base::RefCounted<URLMatcherConditionSet> {
185 public: 200 public:
186 typedef int ID; 201 typedef int ID;
187 typedef std::set<URLMatcherCondition> Conditions; 202 typedef std::set<URLMatcherCondition> Conditions;
188 typedef std::vector<scoped_refptr<URLMatcherConditionSet> > Vector; 203 typedef std::vector<scoped_refptr<URLMatcherConditionSet> > Vector;
189 204
205 // Matches if all conditions in |conditions| are fulfilled.
190 URLMatcherConditionSet(ID id, const Conditions& conditions); 206 URLMatcherConditionSet(ID id, const Conditions& conditions);
191 207
208 // Matches if all conditions in |conditions| and |scheme_filter| are
209 // fulfilled. |scheme_filter| may be NULL, in which case, no restrictions
210 // are imposed on the scheme of a URL.
211 URLMatcherConditionSet(ID id, const Conditions& conditions,
212 scoped_ptr<URLMatcherSchemeFilter> scheme_filter);
213
192 ID id() const { return id_; } 214 ID id() const { return id_; }
193 const Conditions& conditions() const { return conditions_; } 215 const Conditions& conditions() const { return conditions_; }
194 216
195 bool IsMatch( 217 bool IsMatch(
196 const std::set<SubstringPattern::ID>& matching_substring_patterns, 218 const std::set<SubstringPattern::ID>& matching_substring_patterns,
197 const GURL& url) const; 219 const GURL& url) const;
198 220
199 private: 221 private:
200 friend class base::RefCounted<URLMatcherConditionSet>; 222 friend class base::RefCounted<URLMatcherConditionSet>;
201 ~URLMatcherConditionSet(); 223 ~URLMatcherConditionSet();
202 ID id_; 224 ID id_;
203 Conditions conditions_; 225 Conditions conditions_;
226 scoped_ptr<URLMatcherSchemeFilter> scheme_filter_;
204 227
205 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionSet); 228 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionSet);
206 }; 229 };
207 230
208 // This class allows matching one URL against a large set of 231 // This class allows matching one URL against a large set of
209 // URLMatcherConditionSets at the same time. 232 // URLMatcherConditionSets at the same time.
210 class URLMatcher { 233 class URLMatcher {
211 public: 234 public:
212 URLMatcher(); 235 URLMatcher();
213 ~URLMatcher(); 236 ~URLMatcher();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 SubstringSetMatcher url_component_matcher_; 287 SubstringSetMatcher url_component_matcher_;
265 std::set<const SubstringPattern*> registered_full_url_patterns_; 288 std::set<const SubstringPattern*> registered_full_url_patterns_;
266 std::set<const SubstringPattern*> registered_url_component_patterns_; 289 std::set<const SubstringPattern*> registered_url_component_patterns_;
267 290
268 DISALLOW_COPY_AND_ASSIGN(URLMatcher); 291 DISALLOW_COPY_AND_ASSIGN(URLMatcher);
269 }; 292 };
270 293
271 } // namespace extensions 294 } // namespace extensions
272 295
273 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_ 296 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_URL_MATCHER_H_
OLDNEW
« 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