Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/common/extensions/event_matcher.h

Issue 10534125: Extend EventFilter to handle the case where EventMatchers from event X get (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_
6 #define CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ 6 #define CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 class EventFilteringInfo; 14 class EventFilteringInfo;
15 15
16 // Matches EventFilteringInfos against a set of criteria. This is intended to 16 // Matches EventFilteringInfos against a set of criteria. This is intended to
17 // be used by EventFilter which performs efficient URL matching across 17 // be used by EventFilter which performs efficient URL matching across
18 // potentially many EventMatchers itself. This is why this class only exposes 18 // potentially many EventMatchers itself. This is why this class only exposes
19 // MatchNonURLCriteria() - URL matching is handled by EventFilter. 19 // MatchNonURLCriteria() - URL matching is handled by EventFilter.
20 class EventMatcher { 20 class EventMatcher {
21 public: 21 public:
22 EventMatcher(); 22 explicit EventMatcher(scoped_ptr<base::DictionaryValue> filter);
23 ~EventMatcher(); 23 ~EventMatcher();
24 24
25 // 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
26 // into consideration any URL criteria. 26 // into consideration any URL criteria.
27 bool MatchNonURLCriteria(const EventFilteringInfo& event_info) const; 27 bool MatchNonURLCriteria(const EventFilteringInfo& event_info) const;
28 28
29 void set_url_filters(scoped_ptr<base::ListValue> url_filters) { 29 int GetURLFilterCount() const;
30 url_filters_ = url_filters.Pass(); 30 bool GetURLFilter(int i, base::DictionaryValue** url_filter_out);
31 }
32 31
33 // Returns NULL if no url_filters have been specified. 32 int HasURLFilters() const;
34 base::ListValue* url_filters() const {
35 return url_filters_.get();
36 }
37 33
38 bool has_url_filters() const { 34 base::DictionaryValue* value() const {
39 return url_filters_.get() && !url_filters_->empty(); 35 return filter_.get();
40 } 36 }
41 37
42 private: 38 private:
43 scoped_ptr<base::ListValue> url_filters_; 39 // Contains a dictionary that corresponds to a single event filter, eg:
40 //
41 // {url: [{hostSuffix: 'google.com'}]}
42 //
43 // The valid filter keys are event-specific.
44 scoped_ptr<base::DictionaryValue> filter_;
44 45
45 DISALLOW_COPY_AND_ASSIGN(EventMatcher); 46 DISALLOW_COPY_AND_ASSIGN(EventMatcher);
46 }; 47 };
47 48
48 } // namespace extensions 49 } // namespace extensions
49 50
50 #endif // CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_ 51 #endif // CHROME_COMMON_EXTENSIONS_EVENT_MATCHER_H_
OLDNEW
« no previous file with comments | « chrome/common/extensions/event_filtering_info.cc ('k') | chrome/common/extensions/event_matcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698