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