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

Side by Side Diff: extensions/renderer/event_bindings.h

Issue 2973903002: [Extensions Bindings] Introduce a supportsLazyListeners property (Closed)
Patch Set: onMessage event fix Created 3 years, 5 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
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 28 matching lines...) Expand all
39 const EventFilteringInfo* filtering_info, 39 const EventFilteringInfo* filtering_info,
40 ScriptContext* context); 40 ScriptContext* context);
41 41
42 private: 42 private:
43 // JavaScript handler which forwards to AttachEvent(). 43 // JavaScript handler which forwards to AttachEvent().
44 // args[0] forwards to |event_name|. 44 // args[0] forwards to |event_name|.
45 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); 45 void AttachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
46 46
47 // Attach an event name to an object. 47 // Attach an event name to an object.
48 // |event_name| The name of the event to attach. 48 // |event_name| The name of the event to attach.
49 void AttachEvent(const std::string& event_name); 49 void AttachEvent(const std::string& event_name, bool supports_lazy_listeners);
50 50
51 // JavaScript handler which forwards to DetachEvent(). 51 // JavaScript handler which forwards to DetachEvent().
52 // args[0] forwards to |event_name|. 52 // args[0] forwards to |event_name|.
53 // args[1] forwards to |is_manual|. 53 // args[1] forwards to |is_manual|.
54 void DetachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args); 54 void DetachEventHandler(const v8::FunctionCallbackInfo<v8::Value>& args);
55 55
56 // Detaches an event name from an object. 56 // Detaches an event name from an object.
57 // |event_name| The name of the event to stop listening to. 57 // |event_name| The name of the event to stop listening to.
58 // |is_manual| True if this detach was done by the user via removeListener() 58 // |is_manual| True if this detach was done by the user via removeListener()
59 // as opposed to automatically during shutdown, in which case we should inform 59 // as opposed to automatically during shutdown, in which case we should inform
60 // the browser we are no longer interested in that event. 60 // the browser we are no longer interested in that event.
61 void DetachEvent(const std::string& event_name, bool is_manual); 61 void DetachEvent(const std::string& event_name, bool remove_lazy_listener);
62 62
63 // MatcherID AttachFilteredEvent(string event_name, object filter) 63 // MatcherID AttachFilteredEvent(string event_name, object filter)
64 // |event_name| Name of the event to attach. 64 // |event_name| Name of the event to attach.
65 // |filter| Which instances of the named event are we interested in. 65 // |filter| Which instances of the named event are we interested in.
66 // returns the id assigned to the listener, which will be returned from calls 66 // returns the id assigned to the listener, which will be returned from calls
67 // to MatchAgainstEventFilter where this listener matches. 67 // to MatchAgainstEventFilter where this listener matches.
68 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args); 68 void AttachFilteredEvent(const v8::FunctionCallbackInfo<v8::Value>& args);
69 69
70 // JavaScript handler which forwards to DetachFilteredEvent. 70 // JavaScript handler which forwards to DetachFilteredEvent.
71 // void DetachFilteredEvent(int id, bool manual) 71 // void DetachFilteredEvent(int id, bool manual)
72 // args[0] forwards to |matcher_id| 72 // args[0] forwards to |matcher_id|
73 // args[1] forwards to |is_manual| 73 // args[1] forwards to |is_manual|
74 void DetachFilteredEventHandler( 74 void DetachFilteredEventHandler(
75 const v8::FunctionCallbackInfo<v8::Value>& args); 75 const v8::FunctionCallbackInfo<v8::Value>& args);
76 76
77 // Detaches a filtered event. Unlike a normal event, a filtered event is 77 // Detaches a filtered event. Unlike a normal event, a filtered event is
78 // identified by a unique ID per filter, not its name. 78 // identified by a unique ID per filter, not its name.
79 // |matcher_id| The ID of the filtered event. 79 // |matcher_id| The ID of the filtered event.
80 // |is_manual| false if this is part of the extension unload process where all 80 // |is_manual| false if this is part of the extension unload process where all
81 // listeners are automatically detached. 81 // listeners are automatically detached.
82 void DetachFilteredEvent(int matcher_id, bool is_manual); 82 void DetachFilteredEvent(int matcher_id, bool remove_lazy_listener);
83 83
84 void AttachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); 84 void AttachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args);
85 void DetachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args); 85 void DetachUnmanagedEvent(const v8::FunctionCallbackInfo<v8::Value>& args);
86 86
87 // Called when our context, and therefore us, is invalidated. Run any cleanup. 87 // Called when our context, and therefore us, is invalidated. Run any cleanup.
88 void OnInvalidated(); 88 void OnInvalidated();
89 89
90 // The associated message sender. Guaranteed to outlive this object. 90 // The associated message sender. Guaranteed to outlive this object.
91 IPCMessageSender* const ipc_message_sender_; 91 IPCMessageSender* const ipc_message_sender_;
92 92
93 // The set of attached events and filtered events. Maintain these so that we 93 // The set of attached events and filtered events. Maintain these so that we
94 // can detch them on unload. 94 // can detch them on unload.
95 std::set<std::string> attached_event_names_; 95 std::set<std::string> attached_event_names_;
96 std::set<int> attached_matcher_ids_; 96 std::set<int> attached_matcher_ids_;
97 97
98 DISALLOW_COPY_AND_ASSIGN(EventBindings); 98 DISALLOW_COPY_AND_ASSIGN(EventBindings);
99 }; 99 };
100 100
101 } // namespace extensions 101 } // namespace extensions
102 102
103 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_ 103 #endif // EXTENSIONS_RENDERER_EVENT_BINDINGS_H_
OLDNEW
« no previous file with comments | « extensions/renderer/chrome_setting.cc ('k') | extensions/renderer/event_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698