summaryrefslogtreecommitdiffstats
path: root/extensions/common/event_matcher.cc
diff options
context:
space:
mode:
authorMHX348@motorola.com <MHX348@motorola.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 04:45:58 +0000
committerMHX348@motorola.com <MHX348@motorola.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-12 04:45:58 +0000
commit4b3e1928facf6e98d4a386601c6a568bcab69372 (patch)
treefe2f8f5e5a0beec65e60f161905d7d246debfaa8 /extensions/common/event_matcher.cc
parent071d96b541fbc0370354a9fae78e5e87fdbe542d (diff)
downloadchromium_src-4b3e1928facf6e98d4a386601c6a568bcab69372.zip
chromium_src-4b3e1928facf6e98d4a386601c6a568bcab69372.tar.gz
chromium_src-4b3e1928facf6e98d4a386601c6a568bcab69372.tar.bz2
Move EventFilter, EventFilteringInfo and EventMatcher
classes to extensions/common/ TBR=ben@chromium.org BUG=162530 Review URL: https://chromiumcodereview.appspot.com/12208078 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/event_matcher.cc')
-rw-r--r--extensions/common/event_matcher.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/extensions/common/event_matcher.cc b/extensions/common/event_matcher.cc
new file mode 100644
index 0000000..c982937
--- /dev/null
+++ b/extensions/common/event_matcher.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 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.
+
+#include "extensions/common/event_matcher.h"
+
+#include "extensions/common/event_filtering_info.h"
+
+namespace {
+const char kUrlFiltersKey[] = "url";
+}
+
+namespace extensions {
+
+EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter)
+ : filter_(filter.Pass()) {
+}
+
+EventMatcher::~EventMatcher() {
+}
+
+bool EventMatcher::MatchNonURLCriteria(
+ const EventFilteringInfo& event_info) const {
+ // There is currently no criteria apart from URL criteria.
+ return true;
+}
+
+int EventMatcher::GetURLFilterCount() const {
+ base::ListValue* url_filters = NULL;
+ if (filter_->GetList(kUrlFiltersKey, &url_filters))
+ return url_filters->GetSize();
+ return 0;
+}
+
+bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) {
+ base::ListValue* url_filters = NULL;
+ if (filter_->GetList(kUrlFiltersKey, &url_filters)) {
+ return url_filters->GetDictionary(i, url_filter_out);
+ }
+ return false;
+}
+
+int EventMatcher::HasURLFilters() const {
+ return GetURLFilterCount() != 0;
+}
+
+} // namespace extensions