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