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

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

Issue 2727583004: [Extensions Bindings] Add a registerEventArgumentMassager (Closed)
Patch Set: . Created 3 years, 9 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/api_bindings_system.h ('k') | extensions/renderer/api_event_handler.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 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 26 matching lines...) Expand all
37 // Returns a new v8::Object for an event with the given |event_name|. 37 // Returns a new v8::Object for an event with the given |event_name|.
38 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name, 38 v8::Local<v8::Object> CreateEventInstance(const std::string& event_name,
39 v8::Local<v8::Context> context); 39 v8::Local<v8::Context> context);
40 40
41 // Notifies all listeners of the event with the given |event_name| in the 41 // Notifies all listeners of the event with the given |event_name| in the
42 // specified |context|, sending the included |arguments|. 42 // specified |context|, sending the included |arguments|.
43 void FireEventInContext(const std::string& event_name, 43 void FireEventInContext(const std::string& event_name,
44 v8::Local<v8::Context> context, 44 v8::Local<v8::Context> context,
45 const base::ListValue& arguments); 45 const base::ListValue& arguments);
46 46
47 // Registers a |function| to serve as an "argument massager" for the given
48 // |event_name|, mutating the original arguments.
49 // The function is called with two arguments: the array of original arguments
50 // being dispatched to the event, and the function to dispatch the event to
51 // listeners.
52 void RegisterArgumentMassager(v8::Local<v8::Context> context,
53 const std::string& event_name,
54 v8::Local<v8::Function> function);
55
47 // Returns the EventListeners for a given |event_name| and |context|. 56 // Returns the EventListeners for a given |event_name| and |context|.
48 size_t GetNumEventListenersForTesting(const std::string& event_name, 57 size_t GetNumEventListenersForTesting(const std::string& event_name,
49 v8::Local<v8::Context> context); 58 v8::Local<v8::Context> context);
50 59
51 private: 60 private:
52 // Method to run a given v8::Function. Curried in for testing. 61 // Method to run a given v8::Function. Curried in for testing.
53 binding::RunJSFunction call_js_; 62 binding::RunJSFunction call_js_;
54 63
55 EventListenersChangedMethod listeners_changed_; 64 EventListenersChangedMethod listeners_changed_;
56 65
57 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); 66 DISALLOW_COPY_AND_ASSIGN(APIEventHandler);
58 }; 67 };
59 68
60 } // namespace extensions 69 } // namespace extensions
61 70
62 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 71 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_bindings_system.h ('k') | extensions/renderer/api_event_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698