blob: 4bb3e798940b3060c0ee8c6e77cafd437d8c99fb [file] [log] [blame]
[email protected]716c0162013-12-13 20:36:531// Copyright 2013 The Chromium Authors. All rights reserved.
[email protected]dc1e471422012-04-18 19:54:312// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]716c0162013-12-13 20:36:535#ifndef COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
6#define COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
[email protected]dc1e471422012-04-18 19:54:317
dcheng3f767dc32016-04-25 22:54:228#include <memory>
[email protected]dc1e471422012-04-18 19:54:319#include <string>
10
[email protected]716c0162013-12-13 20:36:5311#include "components/url_matcher/url_matcher.h"
12#include "components/url_matcher/url_matcher_export.h"
[email protected]dc1e471422012-04-18 19:54:3113
14namespace base {
15class DictionaryValue;
16class Value;
17}
18
[email protected]716c0162013-12-13 20:36:5319namespace url_matcher {
[email protected]dc1e471422012-04-18 19:54:3120
[email protected]716c0162013-12-13 20:36:5321class URL_MATCHER_EXPORT URLMatcherFactory {
[email protected]dc1e471422012-04-18 19:54:3122 public:
Peter Boström9f667c382021-10-01 20:09:3123 URLMatcherFactory() = delete;
24 URLMatcherFactory(const URLMatcherFactory&) = delete;
25 URLMatcherFactory& operator=(const URLMatcherFactory&) = delete;
26
[email protected]dc1e471422012-04-18 19:54:3127 // Creates a URLMatcherConditionSet from a UrlFilter dictionary as defined in
28 // the declarative API. |url_fetcher_dict| contains the dictionary passed
29 // by the extension, |id| is the identifier assigned to the created
30 // URLMatcherConditionSet. In case of an error, |error| is set to contain
31 // an error message.
[email protected]dc948982012-05-17 01:57:1532 //
33 // Note: In case this function fails or if you don't register the
34 // URLMatcherConditionSet to the URLMatcher, you need to call
35 // URLMatcher::ClearUnusedConditionSets() on the URLMatcher that owns this
36 // URLMatcherFactory. Otherwise you leak memory.
[email protected]dc1e471422012-04-18 19:54:3137 static scoped_refptr<URLMatcherConditionSet> CreateFromURLFilterDictionary(
38 URLMatcherConditionFactory* url_matcher_condition_factory,
39 const base::DictionaryValue* url_filter_dict,
40 URLMatcherConditionSet::ID id,
41 std::string* error);
42
43 private:
44 // Returns whether a condition attribute with name |condition_attribute_name|
45 // needs to be handled by the URLMatcher.
46 static bool IsURLMatcherConditionAttribute(
47 const std::string& condition_attribute_name);
48
49 // Factory method of for URLMatcherConditions.
50 static URLMatcherCondition CreateURLMatcherCondition(
51 URLMatcherConditionFactory* url_matcher_condition_factory,
52 const std::string& condition_attribute_name,
53 const base::Value* value,
54 std::string* error);
55
dcheng3f767dc32016-04-25 22:54:2256 static std::unique_ptr<URLMatcherSchemeFilter> CreateURLMatcherScheme(
57 const base::Value* value,
58 std::string* error);
[email protected]dc1e471422012-04-18 19:54:3159
dcheng3f767dc32016-04-25 22:54:2260 static std::unique_ptr<URLMatcherPortFilter> CreateURLMatcherPorts(
61 const base::Value* value,
62 std::string* error);
[email protected]dc1e471422012-04-18 19:54:3163};
64
[email protected]716c0162013-12-13 20:36:5365} // namespace url_matcher
[email protected]dc1e471422012-04-18 19:54:3166
[email protected]716c0162013-12-13 20:36:5367#endif // COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_