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

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

Issue 2575173002: [Extensions Bindings] Add a bridge to use current custom bindings (Closed)
Patch Set: . Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
6 #define EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
7
8 #include <string>
9
10 #include "base/macros.h"
11 #include "extensions/renderer/api_binding_types.h"
12 #include "gin/wrappable.h"
13 #include "v8/include/v8.h"
14
15 namespace extensions {
16
17 // An object that serves as a bridge between the current JS-centric bindings and
18 // the new native bindings system. This basically needs to conform to the public
19 // methods of the Binding prototype in binding.js.
20 class APIBindingBridge final : public gin::Wrappable<APIBindingBridge> {
21 public:
22 APIBindingBridge(v8::Global<v8::Value> api_object,
23 v8::Global<v8::Value> js_hooks_interface,
24 const std::string& extension_id,
25 const std::string& context_type,
26 const binding::RunJSFunction& run_js);
27 ~APIBindingBridge() override;
28
29 static gin::WrapperInfo kWrapperInfo;
30
31 // gin::Wrappable:
32 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
33 v8::Isolate* isolate) final;
34
35 private:
36 // Runs the given function and registers custom hooks.
37 void RegisterCustomHook(v8::Isolate* isolate,
38 v8::Local<v8::Function> function);
39
40 // The API object itself.
41 v8::Global<v8::Value> api_object_;
jbroman 2016/12/16 19:00:49 I'm not confident about the lifetime of this and t
Devlin 2016/12/16 20:31:17 Thanks for catching this! I definitely still have
42
43 // The JS interface to register hooks.
44 v8::Global<v8::Value> js_hooks_interface_;
45
46 // The id of the extension that owns the context this belongs to.
47 std::string extension_id_;
48
49 // The type of context this belongs to.
50 std::string context_type_;
51
52 // A function to run JS safely.
53 binding::RunJSFunction run_js_;
54
55 DISALLOW_COPY_AND_ASSIGN(APIBindingBridge);
56 };
57
58 } // namespace extensions
59
60 #endif // EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698