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