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"
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.
28 int EventMatcher::GetURLFilterCount() const {
29 base::ListValue
* url_filters
= NULL
;
30 if (filter_
->GetList(kUrlFiltersKey
, &url_filters
))
31 return url_filters
->GetSize();
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
);
43 int EventMatcher::HasURLFilters() const {
44 return GetURLFilterCount() != 0;
47 } // namespace extensions