Chromium Code Reviews| OLD | NEW |
|---|---|
| (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::Local<v8::Context> context, | |
| 23 v8::Local<v8::Value> api_object, | |
| 24 v8::Local<v8::Value> js_hook_interface, | |
| 25 const std::string& extension_id, | |
| 26 const std::string& context_type, | |
| 27 const binding::RunJSFunction& run_js); | |
| 28 ~APIBindingBridge() override; | |
| 29 | |
| 30 static gin::WrapperInfo kWrapperInfo; | |
| 31 | |
| 32 // gin::Wrappable: | |
| 33 gin::ObjectTemplateBuilder GetObjectTemplateBuilder( | |
| 34 v8::Isolate* isolate) final; | |
| 35 | |
| 36 private: | |
| 37 // Runs the given function and registers custom hooks. | |
| 38 void RegisterCustomHook(v8::Isolate* isolate, | |
| 39 v8::Local<v8::Function> function); | |
|
jbroman
2016/12/20 20:51:35
I assume it's documented elsewhere what parameters
Devlin
2016/12/20 22:20:19
Added more of a comment.
| |
| 40 | |
| 41 // The id of the extension that owns the context this belongs to. | |
| 42 std::string extension_id_; | |
| 43 | |
| 44 // The type of context this belongs to. | |
| 45 std::string context_type_; | |
| 46 | |
| 47 // A function to run JS safely. | |
| 48 binding::RunJSFunction run_js_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(APIBindingBridge); | |
| 51 }; | |
| 52 | |
| 53 } // namespace extensions | |
| 54 | |
| 55 #endif // EXTENSIONS_RENDERER_API_BINDING_BRIDGE_H_ | |
| OLD | NEW |