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

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

Issue 2909673003: [Extensions Bindings] Request JS execution from messaging bindings (Closed)
Patch Set: lazyboy's Created 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_API_EVENT_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 // Registers a |function| to serve as an "argument massager" for the given 71 // Registers a |function| to serve as an "argument massager" for the given
72 // |event_name|, mutating the original arguments. 72 // |event_name|, mutating the original arguments.
73 // The function is called with two arguments: the array of original arguments 73 // The function is called with two arguments: the array of original arguments
74 // being dispatched to the event, and the function to dispatch the event to 74 // being dispatched to the event, and the function to dispatch the event to
75 // listeners. 75 // listeners.
76 void RegisterArgumentMassager(v8::Local<v8::Context> context, 76 void RegisterArgumentMassager(v8::Local<v8::Context> context,
77 const std::string& event_name, 77 const std::string& event_name,
78 v8::Local<v8::Function> function); 78 v8::Local<v8::Function> function);
79 79
80 // Returns the EventListeners for a given |event_name| and |context|. 80 // Returns true if there is a listener for the given |event_name| in the
81 size_t GetNumEventListenersForTesting(const std::string& event_name, 81 // given |context|.
82 v8::Local<v8::Context> context); 82 bool HasListenerForEvent(const std::string& event_name,
83 v8::Local<v8::Context> context);
83 84
84 // Invalidates listeners for the given |context|. It's a shame we have to 85 // Invalidates listeners for the given |context|. It's a shame we have to
85 // have this separately (as opposed to hooking into e.g. a PerContextData 86 // have this separately (as opposed to hooking into e.g. a PerContextData
86 // destructor), but we need to do this before the context is fully removed 87 // destructor), but we need to do this before the context is fully removed
87 // (because the associated extension ScriptContext needs to be valid). 88 // (because the associated extension ScriptContext needs to be valid).
88 void InvalidateContext(v8::Local<v8::Context> context); 89 void InvalidateContext(v8::Local<v8::Context> context);
89 90
91 // Returns the number of event listeners for a given |event_name| and
92 // |context|.
93 size_t GetNumEventListenersForTesting(const std::string& event_name,
94 v8::Local<v8::Context> context);
95
90 private: 96 private:
91 // Method to run a given v8::Function. Curried in for testing. 97 // Method to run a given v8::Function. Curried in for testing.
92 binding::RunJSFunction call_js_; 98 binding::RunJSFunction call_js_;
93 99
94 EventListenersChangedMethod listeners_changed_; 100 EventListenersChangedMethod listeners_changed_;
95 101
96 // The associated EventFilter; shared across all contexts and events. 102 // The associated EventFilter; shared across all contexts and events.
97 EventFilter event_filter_; 103 EventFilter event_filter_;
98 104
99 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); 105 DISALLOW_COPY_AND_ASSIGN(APIEventHandler);
100 }; 106 };
101 107
102 } // namespace extensions 108 } // namespace extensions
103 109
104 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 110 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/chrome_extensions_renderer_client.cc ('k') | extensions/renderer/api_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698