OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ | |
6 #define CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/values.h" | |
10 | |
11 namespace extensions { | |
12 | |
13 class EventFilteringInfo; | |
14 | |
15 // Matches EventFilteringInfos against a set of criteria. This is intended to | |
16 // be used by EventFilter which performs efficient URL matching across | |
17 // potentially many EventMatchers itself. This is why this class only exposes | |
18 // MatchNonURLCriteria() - URL matching is handled by EventFilter. | |
19 class EventMatcher { | |
20 public: | |
21 explicit EventMatcher(scoped_ptr<base::DictionaryValue> filter); | |
22 ~EventMatcher(); | |
23 | |
24 // Returns true if |event_info| satisfies this matcher's criteria, not taking | |
25 // into consideration any URL criteria. | |
26 bool MatchNonURLCriteria(const EventFilteringInfo& event_info) const; | |
27 | |
28 int GetURLFilterCount() const; | |
29 bool GetURLFilter(int i, base::DictionaryValue** url_filter_out); | |
30 | |
31 int HasURLFilters() const; | |
32 | |
33 base::DictionaryValue* value() const { | |
34 return filter_.get(); | |
35 } | |
36 | |
37 private: | |
38 // Contains a dictionary that corresponds to a single event filter, eg: | |
39 // | |
40 // {url: [{hostSuffix: 'google.com'}]} | |
41 // | |
42 // The valid filter keys are event-specific. | |
43 scoped_ptr<base::DictionaryValue> filter_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(EventMatcher); | |
46 }; | |
47 | |
48 } // namespace extensions | |
49 | |
50 #endif // CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ | |
OLD | NEW |