Revert 200220 "Make ExtensionPrefs a ProfileKeyedService."
[chromium-blink-merge.git] / extensions / common / event_matcher.cc
blobc9829373c9102a16a331066f346c19fb0e8d2eef
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 #include "extensions/common/event_matcher.h"
7 #include "extensions/common/event_filtering_info.h"
9 namespace {
10 const char kUrlFiltersKey[] = "url";
13 namespace extensions {
15 EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter)
16 : filter_(filter.Pass()) {
19 EventMatcher::~EventMatcher() {
22 bool EventMatcher::MatchNonURLCriteria(
23 const EventFilteringInfo& event_info) const {
24 // There is currently no criteria apart from URL criteria.
25 return true;
28 int EventMatcher::GetURLFilterCount() const {
29 base::ListValue* url_filters = NULL;
30 if (filter_->GetList(kUrlFiltersKey, &url_filters))
31 return url_filters->GetSize();
32 return 0;
35 bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) {
36 base::ListValue* url_filters = NULL;
37 if (filter_->GetList(kUrlFiltersKey, &url_filters)) {
38 return url_filters->GetDictionary(i, url_filter_out);
40 return false;
43 int EventMatcher::HasURLFilters() const {
44 return GetURLFilterCount() != 0;
47 } // namespace extensions