OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_RENDERER_EVENT_BINDINGS_H_ | 5 #ifndef EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
6 #define EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ | 6 #define EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
7 | 7 |
| 8 #include "extensions/renderer/object_backed_native_handler.h" |
8 #include "v8/include/v8.h" | 9 #include "v8/include/v8.h" |
9 | 10 |
| 11 namespace base { |
| 12 class DictionaryValue; |
| 13 } |
| 14 |
10 namespace extensions { | 15 namespace extensions { |
| 16 class ChromeV8Context; |
11 class Dispatcher; | 17 class Dispatcher; |
12 class ObjectBackedNativeHandler; | 18 class EventFilter; |
13 class ScriptContext; | 19 class EventFilteringInfo; |
| 20 class EventMatcher; |
14 | 21 |
15 // This class deals with the javascript bindings related to Event objects. | 22 // This class deals with the javascript bindings related to Event objects. |
16 class EventBindings { | 23 class EventBindings : public ObjectBackedNativeHandler { |
17 public: | 24 public: |
18 static ObjectBackedNativeHandler* Create(Dispatcher* dispatcher, | 25 EventBindings(Dispatcher* dispatcher, ScriptContext* context); |
19 ScriptContext* context); | 26 virtual ~EventBindings(); |
| 27 |
| 28 private: |
| 29 // Attach an event name to an object. |
| 30 // |event_name| The name of the event to attach. |
| 31 void AttachEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 32 |
| 33 // Detach an event name from an object. |
| 34 // |event_name| The name of the event to stop listening to. |
| 35 // |is_manual| True if this detach was done by the user via removeListener() |
| 36 // as opposed to automatically during shutdown, in which case we should inform |
| 37 // the browser we are no longer interested in that event. |
| 38 void DetachEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 39 |
| 40 // MatcherID AttachFilteredEvent(string event_name, object filter) |
| 41 // |event_name| Name of the event to attach. |
| 42 // |filter| Which instances of the named event are we interested in. |
| 43 // returns the id assigned to the listener, which will be returned from calls |
| 44 // to MatchAgainstEventFilter where this listener matches. |
| 45 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 46 |
| 47 // void DetachFilteredEvent(int id, bool manual) |
| 48 // id - Id of the event to detach. |
| 49 // manual - false if this is part of the extension unload process where all |
| 50 // listeners are automatically detached. |
| 51 void DetachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 52 |
| 53 void MatchAgainstEventFilter(const v8::FunctionCallbackInfo<v8::Value>& args); |
| 54 |
| 55 Dispatcher* dispatcher_; |
| 56 scoped_ptr<EventMatcher> ParseEventMatcher( |
| 57 base::DictionaryValue* filter_dict); |
20 }; | 58 }; |
21 | 59 |
22 } // namespace extensions | 60 } // namespace extensions |
23 | 61 |
24 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ | 62 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
OLD | NEW |