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

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

Issue 2947463002: [Extensions Bindings] Add a bindings/ subdirectory under renderer (Closed)
Patch Set: . 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
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | 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
(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 class APIBindingHooks;
17
18 // An object that serves as a bridge between the current JS-centric bindings and
19 // the new native bindings system. This basically needs to conform to the public
20 // methods of the Binding prototype in binding.js.
21 class APIBindingBridge final : public gin::Wrappable<APIBindingBridge> {
22 public:
23 APIBindingBridge(APIBindingHooks* hooks,
24 v8::Local<v8::Context> context,
25 v8::Local<v8::Value> api_object,
26 const std::string& extension_id,
27 const std::string& context_type,
28 const binding::RunJSFunction& run_js);
29 ~APIBindingBridge() override;
30
31 static gin::WrapperInfo kWrapperInfo;
32
33 // gin::Wrappable:
34 gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
35 v8::Isolate* isolate) final;
36
37 private:
38 // Runs the given function and registers custom hooks.
39 // The function takes three arguments: an object,
40 // {
41 // apiFunctions: <JSHookInterface> (see api_bindings_hooks.cc),
42 // compiledApi: <the API object>
43 // }
44 // as well as a string for the extension ID and a string for the context type.
45 // This should register any hooks that the JS needs for the given API.
46 void RegisterCustomHook(v8::Isolate* isolate,
47 v8::Local<v8::Function> function);
48
49 // The id of the extension that owns the context this belongs to.
50 std::string extension_id_;
51
52 // The type of context this belongs to.
53 std::string context_type_;
54
55 // A function to run JS safely.
56 binding::RunJSFunction run_js_;
57
58 DISALLOW_COPY_AND_ASSIGN(APIBindingBridge);
59 };
60
61 } // namespace extensions
62
63 #endif // EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_
OLDNEW
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/api_binding_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698