summaryrefslogtreecommitdiffstats
path: root/components/url_matcher/url_matcher_factory.h
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 20:36:53 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-13 20:36:53 +0000
commit716c016d95025a8f4d42baab6639b9dc90498f2d (patch)
tree9efb703e070ecbfb1b73bfac9b350a3b81af14f6 /components/url_matcher/url_matcher_factory.h
parent32c90a98f03fa68da4ba3d97a8e56ca70e92a07d (diff)
downloadchromium_src-716c016d95025a8f4d42baab6639b9dc90498f2d.zip
chromium_src-716c016d95025a8f4d42baab6639b9dc90498f2d.tar.gz
chromium_src-716c016d95025a8f4d42baab6639b9dc90498f2d.tar.bz2
Move extensions/common/matcher into components/url_matcher.
This allows using that code in builds that don't include extensions without having to introduce layering exceptions. This is meant for inclusion on the iOS build. BUG=271392 TBR=brettw@chromium.org Review URL: https://codereview.chromium.org/113903002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/url_matcher/url_matcher_factory.h')
-rw-r--r--components/url_matcher/url_matcher_factory.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/components/url_matcher/url_matcher_factory.h b/components/url_matcher/url_matcher_factory.h
new file mode 100644
index 0000000..93ff202
--- /dev/null
+++ b/components/url_matcher/url_matcher_factory.h
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
+#define COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "components/url_matcher/url_matcher.h"
+#include "components/url_matcher/url_matcher_export.h"
+
+namespace base {
+class DictionaryValue;
+class Value;
+}
+
+namespace url_matcher {
+
+class URL_MATCHER_EXPORT URLMatcherFactory {
+ public:
+ // Creates a URLMatcherConditionSet from a UrlFilter dictionary as defined in
+ // the declarative API. |url_fetcher_dict| contains the dictionary passed
+ // by the extension, |id| is the identifier assigned to the created
+ // URLMatcherConditionSet. In case of an error, |error| is set to contain
+ // an error message.
+ //
+ // Note: In case this function fails or if you don't register the
+ // URLMatcherConditionSet to the URLMatcher, you need to call
+ // URLMatcher::ClearUnusedConditionSets() on the URLMatcher that owns this
+ // URLMatcherFactory. Otherwise you leak memory.
+ static scoped_refptr<URLMatcherConditionSet> CreateFromURLFilterDictionary(
+ URLMatcherConditionFactory* url_matcher_condition_factory,
+ const base::DictionaryValue* url_filter_dict,
+ URLMatcherConditionSet::ID id,
+ std::string* error);
+
+ private:
+ // Returns whether a condition attribute with name |condition_attribute_name|
+ // needs to be handled by the URLMatcher.
+ static bool IsURLMatcherConditionAttribute(
+ const std::string& condition_attribute_name);
+
+ // Factory method of for URLMatcherConditions.
+ static URLMatcherCondition CreateURLMatcherCondition(
+ URLMatcherConditionFactory* url_matcher_condition_factory,
+ const std::string& condition_attribute_name,
+ const base::Value* value,
+ std::string* error);
+
+ static scoped_ptr<URLMatcherSchemeFilter> CreateURLMatcherScheme(
+ const base::Value* value, std::string* error);
+
+ static scoped_ptr<URLMatcherPortFilter> CreateURLMatcherPorts(
+ const base::Value* value, std::string* error);
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(URLMatcherFactory);
+};
+
+} // namespace url_matcher
+
+#endif // COMPONENTS_URL_MATCHER_URL_MATCHER_FACTORY_H_