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

Side by Side Diff: extensions/renderer/api_binding_bridge.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 | « no previous file | extensions/renderer/api_binding_bridge.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_BINDING_BRIDGE_H_ 5 #ifndef EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
6 #define EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_ 6 #define EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "extensions/renderer/api_binding_types.h" 11 #include "extensions/renderer/api_binding_types.h"
12 #include "gin/wrappable.h" 12 #include "gin/wrappable.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 14
15 namespace gin { 15 namespace gin {
16 class Arguments; 16 class Arguments;
17 } 17 }
18 18
19 namespace extensions { 19 namespace extensions {
20 class APIBindingHooks; 20 class APIBindingHooks;
21 class APIEventHandler;
21 class APIRequestHandler; 22 class APIRequestHandler;
22 class APITypeReferenceMap; 23 class APITypeReferenceMap;
23 24
24 // An object that serves as a bridge between the current JS-centric bindings and 25 // An object that serves as a bridge between the current JS-centric bindings and
25 // the new native bindings system. This basically needs to conform to the public 26 // the new native bindings system. This basically needs to conform to the public
26 // methods of the Binding prototype in binding.js. 27 // methods of the Binding prototype in binding.js.
27 class APIBindingBridge final : public gin::Wrappable<APIBindingBridge> { 28 class APIBindingBridge final : public gin::Wrappable<APIBindingBridge> {
28 public: 29 public:
29 APIBindingBridge(const APITypeReferenceMap* type_refs, 30 APIBindingBridge(const APITypeReferenceMap* type_refs,
30 APIRequestHandler* request_handler, 31 APIRequestHandler* request_handler,
32 APIEventHandler* event_handler,
31 APIBindingHooks* hooks, 33 APIBindingHooks* hooks,
32 v8::Local<v8::Context> context, 34 v8::Local<v8::Context> context,
33 v8::Local<v8::Value> api_object, 35 v8::Local<v8::Value> api_object,
34 const std::string& extension_id, 36 const std::string& extension_id,
35 const std::string& context_type, 37 const std::string& context_type,
36 const binding::RunJSFunction& run_js); 38 const binding::RunJSFunction& run_js);
37 ~APIBindingBridge() override; 39 ~APIBindingBridge() override;
38 40
39 static gin::WrapperInfo kWrapperInfo; 41 static gin::WrapperInfo kWrapperInfo;
40 42
(...skipping 12 matching lines...) Expand all
53 // This should register any hooks that the JS needs for the given API. 55 // This should register any hooks that the JS needs for the given API.
54 void RegisterCustomHook(v8::Isolate* isolate, 56 void RegisterCustomHook(v8::Isolate* isolate,
55 v8::Local<v8::Function> function); 57 v8::Local<v8::Function> function);
56 58
57 // A handler to initiate an API request through the APIRequestHandler. A 59 // A handler to initiate an API request through the APIRequestHandler. A
58 // replacement for custom bindings that utilize require('sendRequest'). 60 // replacement for custom bindings that utilize require('sendRequest').
59 void SendRequest(gin::Arguments* arguments, 61 void SendRequest(gin::Arguments* arguments,
60 const std::string& name, 62 const std::string& name,
61 const std::vector<v8::Local<v8::Value>>& request_args); 63 const std::vector<v8::Local<v8::Value>>& request_args);
62 64
65 // A handler to register an argument massager for a specific event.
66 // Replacement for event_bindings.registerArgumentMassager.
67 void RegisterEventArgumentMassager(gin::Arguments* arguments,
68 const std::string& event_name,
69 v8::Local<v8::Function> massager);
70
63 // Type references. Guaranteed to outlive this object. 71 // Type references. Guaranteed to outlive this object.
64 const APITypeReferenceMap* type_refs_; 72 const APITypeReferenceMap* type_refs_;
65 73
66 // The request handler. Guaranteed to outlive this object. 74 // The request handler. Guaranteed to outlive this object.
67 APIRequestHandler* request_handler_; 75 APIRequestHandler* request_handler_;
68 76
77 // The event handler. Guaranteed to outlive this object.
78 APIEventHandler* event_handler_;
79
69 // The hooks associated with this API. Guaranteed to outlive this object. 80 // The hooks associated with this API. Guaranteed to outlive this object.
70 APIBindingHooks* hooks_; 81 APIBindingHooks* hooks_;
71 82
72 // The id of the extension that owns the context this belongs to. 83 // The id of the extension that owns the context this belongs to.
73 std::string extension_id_; 84 std::string extension_id_;
74 85
75 // The type of context this belongs to. 86 // The type of context this belongs to.
76 std::string context_type_; 87 std::string context_type_;
77 88
78 // A function to run JS safely. 89 // A function to run JS safely.
79 binding::RunJSFunction run_js_; 90 binding::RunJSFunction run_js_;
80 91
81 DISALLOW_COPY_AND_ASSIGN(APIBindingBridge); 92 DISALLOW_COPY_AND_ASSIGN(APIBindingBridge);
82 }; 93 };
83 94
84 } // namespace extensions 95 } // namespace extensions
85 96
86 #endif // EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_ 97 #endif // EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/renderer/api_binding_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698