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 <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 const EventFilteringInfo* filtering_info, | 42 const EventFilteringInfo* filtering_info, |
43 ScriptContext* context); | 43 ScriptContext* context); |
44 | 44 |
45 private: | 45 private: |
46 // JavaScript handler which forwards to AttachEvent(). | 46 // JavaScript handler which forwards to AttachEvent(). |
47 // args[0] forwards to |event_name|. | 47 // args[0] forwards to |event_name|. |
48 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); | 48 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); |
49 | 49 |
50 // Attach an event name to an object. | 50 // Attach an event name to an object. |
51 // |event_name| The name of the event to attach. | 51 // |event_name| The name of the event to attach. |
52 void AttachEvent(const std::string& event_name); | 52 void AttachEvent(const std::string& event_name, bool supports_lazy_listeners); |
53 | 53 |
54 // JavaScript handler which forwards to DetachEvent(). | 54 // JavaScript handler which forwards to DetachEvent(). |
55 // args[0] forwards to |event_name|. | 55 // args[0] forwards to |event_name|. |
56 // args[1] forwards to |is_manual|. | 56 // args[1] forwards to |is_manual|. |
57 void DetachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); | 57 void DetachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); |
58 | 58 |
59 // Detaches an event name from an object. | 59 // Detaches an event name from an object. |
60 // |event_name| The name of the event to stop listening to. | 60 // |event_name| The name of the event to stop listening to. |
61 // |is_manual| True if this detach was done by the user via removeListener() | 61 // |is_manual| True if this detach was done by the user via removeListener() |
62 // as opposed to automatically during shutdown, in which case we should inform | 62 // as opposed to automatically during shutdown, in which case we should inform |
63 // the browser we are no longer interested in that event. | 63 // the browser we are no longer interested in that event. |
64 void DetachEvent(const std::string& event_name, bool is_manual); | 64 void DetachEvent(const std::string& event_name, bool remove_lazy_listener); |
65 | 65 |
66 // MatcherID AttachFilteredEvent(string event_name, object filter) | 66 // MatcherID AttachFilteredEvent(string event_name, object filter) |
67 // |event_name| Name of the event to attach. | 67 // |event_name| Name of the event to attach. |
68 // |filter| Which instances of the named event are we interested in. | 68 // |filter| Which instances of the named event are we interested in. |
69 // returns the id assigned to the listener, which will be returned from calls | 69 // returns the id assigned to the listener, which will be returned from calls |
70 // to MatchAgainstEventFilter where this listener matches. | 70 // to MatchAgainstEventFilter where this listener matches. |
71 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 71 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
72 | 72 |
73 // JavaScript handler which forwards to DetachFilteredEvent. | 73 // JavaScript handler which forwards to DetachFilteredEvent. |
74 // void DetachFilteredEvent(int id, bool manual) | 74 // void DetachFilteredEvent(int id, bool manual) |
75 // args[0] forwards to |matcher_id| | 75 // args[0] forwards to |matcher_id| |
76 // args[1] forwards to |is_manual| | 76 // args[1] forwards to |is_manual| |
77 void DetachFilteredEventHandler( | 77 void DetachFilteredEventHandler( |
78 const v8::FunctionCallbackInfo<v8::Value>& args); | 78 const v8::FunctionCallbackInfo<v8::Value>& args); |
79 | 79 |
80 // Detaches a filtered event. Unlike a normal event, a filtered event is | 80 // Detaches a filtered event. Unlike a normal event, a filtered event is |
81 // identified by a unique ID per filter, not its name. | 81 // identified by a unique ID per filter, not its name. |
82 // |matcher_id| The ID of the filtered event. | 82 // |matcher_id| The ID of the filtered event. |
83 // |is_manual| false if this is part of the extension unload process where all | 83 // |is_manual| false if this is part of the extension unload process where all |
84 // listeners are automatically detached. | 84 // listeners are automatically detached. |
85 void DetachFilteredEvent(int matcher_id, bool is_manual); | 85 void DetachFilteredEvent(int matcher_id, bool remove_lazy_listener); |
86 | 86 |
87 void AttachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 87 void AttachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
88 void DetachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); | 88 void DetachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); |
89 | 89 |
90 IPC::Sender* GetIPCSender(); | 90 IPC::Sender* GetIPCSender(); |
91 | 91 |
92 // Called when our context, and therefore us, is invalidated. Run any cleanup. | 92 // Called when our context, and therefore us, is invalidated. Run any cleanup. |
93 void OnInvalidated(); | 93 void OnInvalidated(); |
94 | 94 |
95 // The set of attached events and filtered events. Maintain these so that we | 95 // The set of attached events and filtered events. Maintain these so that we |
96 // can detch them on unload. | 96 // can detch them on unload. |
97 std::set<std::string> attached_event_names_; | 97 std::set<std::string> attached_event_names_; |
98 std::set<int> attached_matcher_ids_; | 98 std::set<int> attached_matcher_ids_; |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(EventBindings); | 100 DISALLOW_COPY_AND_ASSIGN(EventBindings); |
101 }; | 101 }; |
102 | 102 |
103 } // namespace extensions | 103 } // namespace extensions |
104 | 104 |
105 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ | 105 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ |
OLD | NEW |