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