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 CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_
6 #define CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h"
11 namespace extensions
{
13 class EventFilteringInfo
;
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.
21 explicit EventMatcher(scoped_ptr
<base::DictionaryValue
> filter
);
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;
28 int GetURLFilterCount() const;
29 bool GetURLFilter(int i
, base::DictionaryValue
** url_filter_out
);
31 int HasURLFilters() const;
33 base::DictionaryValue
* value() const {
38 // Contains a dictionary that corresponds to a single event filter, eg:
40 // {url: [{hostSuffix: 'google.com'}]}
42 // The valid filter keys are event-specific.
43 scoped_ptr
<base::DictionaryValue
> filter_
;
45 DISALLOW_COPY_AND_ASSIGN(EventMatcher
);
48 } // namespace extensions
50 #endif // CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_