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 #pragma once |
| 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/values.h" |
| 11 |
| 12 namespace extensions { |
| 13 |
| 14 class EventFilteringInfo; |
| 15 |
| 16 // Matches EventFilteringInfos against a set of criteria. This is intended to |
| 17 // be used by EventFilter which performs efficient URL matching across |
| 18 // potentially many EventMatchers itself. This is why this class only exposes |
| 19 // MatchNonURLCriteria() - URL matching is handled by EventFilter. |
| 20 class EventMatcher { |
| 21 public: |
| 22 EventMatcher(); |
| 23 ~EventMatcher(); |
| 24 |
| 25 // Returns true if |event_info| satisfies this matcher's criteria, not taking |
| 26 // into consideration any URL criteria. |
| 27 bool MatchNonURLCriteria(const EventFilteringInfo& event_info) const; |
| 28 |
| 29 void set_url_filters(scoped_ptr<base::ListValue> url_filters) { |
| 30 url_filters_ = url_filters.Pass(); |
| 31 } |
| 32 |
| 33 // Returns NULL if no url_filters have been specified. |
| 34 base::ListValue* url_filters() const { |
| 35 return url_filters_.get(); |
| 36 } |
| 37 |
| 38 bool has_url_filters() const { |
| 39 return url_filters_.get() && !url_filters_->empty(); |
| 40 } |
| 41 |
| 42 private: |
| 43 scoped_ptr<base::ListValue> url_filters_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(EventMatcher); |
| 46 }; |
| 47 |
| 48 } // namespace extensions |
| 49 |
| 50 #endif // CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ |
OLD | NEW |