OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 COMPONENTS_URL_MATCHER_URL_MATCHER_H_ | 5 #ifndef COMPONENTS_URL_MATCHER_URL_MATCHER_H_ |
6 #define COMPONENTS_URL_MATCHER_URL_MATCHER_H_ | 6 #define COMPONENTS_URL_MATCHER_URL_MATCHER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <memory> |
10 #include <set> | 11 #include <set> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "components/url_matcher/regex_set_matcher.h" | 16 #include "components/url_matcher/regex_set_matcher.h" |
17 #include "components/url_matcher/substring_set_matcher.h" | 17 #include "components/url_matcher/substring_set_matcher.h" |
18 #include "components/url_matcher/url_matcher_export.h" | 18 #include "components/url_matcher/url_matcher_export.h" |
19 | 19 |
20 class GURL; | 20 class GURL; |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 class DictionaryValue; | 23 class DictionaryValue; |
24 } | 24 } |
25 | 25 |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 typedef std::set<URLMatcherCondition> Conditions; | 318 typedef std::set<URLMatcherCondition> Conditions; |
319 typedef std::set<URLQueryElementMatcherCondition> QueryConditions; | 319 typedef std::set<URLQueryElementMatcherCondition> QueryConditions; |
320 typedef std::vector<scoped_refptr<URLMatcherConditionSet> > Vector; | 320 typedef std::vector<scoped_refptr<URLMatcherConditionSet> > Vector; |
321 | 321 |
322 // Matches if all conditions in |conditions| are fulfilled. | 322 // Matches if all conditions in |conditions| are fulfilled. |
323 URLMatcherConditionSet(ID id, const Conditions& conditions); | 323 URLMatcherConditionSet(ID id, const Conditions& conditions); |
324 | 324 |
325 // Matches if all conditions in |conditions|, |scheme_filter| and | 325 // Matches if all conditions in |conditions|, |scheme_filter| and |
326 // |port_filter| are fulfilled. |scheme_filter| and |port_filter| may be NULL, | 326 // |port_filter| are fulfilled. |scheme_filter| and |port_filter| may be NULL, |
327 // in which case, no restrictions are imposed on the scheme/port of a URL. | 327 // in which case, no restrictions are imposed on the scheme/port of a URL. |
328 URLMatcherConditionSet(ID id, const Conditions& conditions, | 328 URLMatcherConditionSet(ID id, |
329 scoped_ptr<URLMatcherSchemeFilter> scheme_filter, | 329 const Conditions& conditions, |
330 scoped_ptr<URLMatcherPortFilter> port_filter); | 330 std::unique_ptr<URLMatcherSchemeFilter> scheme_filter, |
| 331 std::unique_ptr<URLMatcherPortFilter> port_filter); |
331 | 332 |
332 // Matches if all conditions in |conditions|, |query_conditions|, | 333 // Matches if all conditions in |conditions|, |query_conditions|, |
333 // |scheme_filter| and |port_filter| are fulfilled. |scheme_filter| and | 334 // |scheme_filter| and |port_filter| are fulfilled. |scheme_filter| and |
334 // |port_filter| may be NULL, in which case, no restrictions are imposed on | 335 // |port_filter| may be NULL, in which case, no restrictions are imposed on |
335 // the scheme/port of a URL. | 336 // the scheme/port of a URL. |
336 URLMatcherConditionSet(ID id, | 337 URLMatcherConditionSet(ID id, |
337 const Conditions& conditions, | 338 const Conditions& conditions, |
338 const QueryConditions& query_conditions, | 339 const QueryConditions& query_conditions, |
339 scoped_ptr<URLMatcherSchemeFilter> scheme_filter, | 340 std::unique_ptr<URLMatcherSchemeFilter> scheme_filter, |
340 scoped_ptr<URLMatcherPortFilter> port_filter); | 341 std::unique_ptr<URLMatcherPortFilter> port_filter); |
341 | 342 |
342 ID id() const { return id_; } | 343 ID id() const { return id_; } |
343 const Conditions& conditions() const { return conditions_; } | 344 const Conditions& conditions() const { return conditions_; } |
344 const QueryConditions& query_conditions() const { return query_conditions_; } | 345 const QueryConditions& query_conditions() const { return query_conditions_; } |
345 | 346 |
346 bool IsMatch(const std::set<StringPattern::ID>& matching_patterns, | 347 bool IsMatch(const std::set<StringPattern::ID>& matching_patterns, |
347 const GURL& url) const; | 348 const GURL& url) const; |
348 | 349 |
349 bool IsMatch(const std::set<StringPattern::ID>& matching_patterns, | 350 bool IsMatch(const std::set<StringPattern::ID>& matching_patterns, |
350 const GURL& url, | 351 const GURL& url, |
351 const std::string& url_for_component_searches) const; | 352 const std::string& url_for_component_searches) const; |
352 | 353 |
353 private: | 354 private: |
354 friend class base::RefCounted<URLMatcherConditionSet>; | 355 friend class base::RefCounted<URLMatcherConditionSet>; |
355 ~URLMatcherConditionSet(); | 356 ~URLMatcherConditionSet(); |
356 ID id_; | 357 ID id_; |
357 Conditions conditions_; | 358 Conditions conditions_; |
358 QueryConditions query_conditions_; | 359 QueryConditions query_conditions_; |
359 scoped_ptr<URLMatcherSchemeFilter> scheme_filter_; | 360 std::unique_ptr<URLMatcherSchemeFilter> scheme_filter_; |
360 scoped_ptr<URLMatcherPortFilter> port_filter_; | 361 std::unique_ptr<URLMatcherPortFilter> port_filter_; |
361 | 362 |
362 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionSet); | 363 DISALLOW_COPY_AND_ASSIGN(URLMatcherConditionSet); |
363 }; | 364 }; |
364 | 365 |
365 // This class allows matching one URL against a large set of | 366 // This class allows matching one URL against a large set of |
366 // URLMatcherConditionSets at the same time. | 367 // URLMatcherConditionSets at the same time. |
367 class URL_MATCHER_EXPORT URLMatcher { | 368 class URL_MATCHER_EXPORT URLMatcher { |
368 public: | 369 public: |
369 URLMatcher(); | 370 URLMatcher(); |
370 ~URLMatcher(); | 371 ~URLMatcher(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 RegexSetMatcher origin_and_path_regex_set_matcher_; | 426 RegexSetMatcher origin_and_path_regex_set_matcher_; |
426 std::set<const StringPattern*> registered_full_url_patterns_; | 427 std::set<const StringPattern*> registered_full_url_patterns_; |
427 std::set<const StringPattern*> registered_url_component_patterns_; | 428 std::set<const StringPattern*> registered_url_component_patterns_; |
428 | 429 |
429 DISALLOW_COPY_AND_ASSIGN(URLMatcher); | 430 DISALLOW_COPY_AND_ASSIGN(URLMatcher); |
430 }; | 431 }; |
431 | 432 |
432 } // namespace url_matcher | 433 } // namespace url_matcher |
433 | 434 |
434 #endif // COMPONENTS_URL_MATCHER_URL_MATCHER_H_ | 435 #endif // COMPONENTS_URL_MATCHER_URL_MATCHER_H_ |
OLD | NEW |