OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/event_matcher.h" | 5 #include "chrome/common/extensions/event_matcher.h" |
6 #include "chrome/common/extensions/event_filtering_info.h" | 6 #include "chrome/common/extensions/event_filtering_info.h" |
7 | 7 |
| 8 namespace { |
| 9 const char kUrlFiltersKey[] = "url"; |
| 10 } |
| 11 |
8 namespace extensions { | 12 namespace extensions { |
9 | 13 |
10 EventMatcher::EventMatcher() { | 14 EventMatcher::EventMatcher(scoped_ptr<base::DictionaryValue> filter) |
| 15 : filter_(filter.Pass()) { |
11 } | 16 } |
12 | 17 |
13 EventMatcher::~EventMatcher() { | 18 EventMatcher::~EventMatcher() { |
14 } | 19 } |
15 | 20 |
16 bool EventMatcher::MatchNonURLCriteria( | 21 bool EventMatcher::MatchNonURLCriteria( |
17 const EventFilteringInfo& event_info) const { | 22 const EventFilteringInfo& event_info) const { |
18 // There is currently no criteria apart from URL criteria. | 23 // There is currently no criteria apart from URL criteria. |
19 return true; | 24 return true; |
20 } | 25 } |
21 | 26 |
| 27 int EventMatcher::GetURLFilterCount() const { |
| 28 base::ListValue* url_filters = NULL; |
| 29 if (filter_->GetList(kUrlFiltersKey, &url_filters)) |
| 30 return url_filters->GetSize(); |
| 31 return 0; |
| 32 } |
| 33 |
| 34 bool EventMatcher::GetURLFilter(int i, base::DictionaryValue** url_filter_out) { |
| 35 base::ListValue* url_filters = NULL; |
| 36 if (filter_->GetList(kUrlFiltersKey, &url_filters)) { |
| 37 return url_filters->GetDictionary(i, url_filter_out); |
| 38 } |
| 39 return false; |
| 40 } |
| 41 |
| 42 int EventMatcher::HasURLFilters() const { |
| 43 return GetURLFilterCount() != 0; |
| 44 } |
| 45 |
22 } // namespace extensions | 46 } // namespace extensions |
OLD | NEW |