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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
6 #define COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
10 #include "base/basictypes.h"
11 #include "components/url_matcher/url_matcher.h"
12 #include "components/url_matcher/url_matcher_export.h"
15 class DictionaryValue
;
19 namespace url_matcher
{
21 class URL_MATCHER_EXPORT URLMatcherFactory
{
23 // Creates a URLMatcherConditionSet from a UrlFilter dictionary as defined in
24 // the declarative API. |url_fetcher_dict| contains the dictionary passed
25 // by the extension, |id| is the identifier assigned to the created
26 // URLMatcherConditionSet. In case of an error, |error| is set to contain
29 // Note: In case this function fails or if you don't register the
30 // URLMatcherConditionSet to the URLMatcher, you need to call
31 // URLMatcher::ClearUnusedConditionSets() on the URLMatcher that owns this
32 // URLMatcherFactory. Otherwise you leak memory.
33 static scoped_refptr
<URLMatcherConditionSet
> CreateFromURLFilterDictionary(
34 URLMatcherConditionFactory
* url_matcher_condition_factory
,
35 const base::DictionaryValue
* url_filter_dict
,
36 URLMatcherConditionSet::ID id
,
40 // Returns whether a condition attribute with name |condition_attribute_name|
41 // needs to be handled by the URLMatcher.
42 static bool IsURLMatcherConditionAttribute(
43 const std::string
& condition_attribute_name
);
45 // Factory method of for URLMatcherConditions.
46 static URLMatcherCondition
CreateURLMatcherCondition(
47 URLMatcherConditionFactory
* url_matcher_condition_factory
,
48 const std::string
& condition_attribute_name
,
49 const base::Value
* value
,
52 static scoped_ptr
<URLMatcherSchemeFilter
> CreateURLMatcherScheme(
53 const base::Value
* value
, std::string
* error
);
55 static scoped_ptr
<URLMatcherPortFilter
> CreateURLMatcherPorts(
56 const base::Value
* value
, std::string
* error
);
58 DISALLOW_IMPLICIT_CONSTRUCTORS(URLMatcherFactory
);
61 } // namespace url_matcher
63 #endif // COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_