OLD | NEW |
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 #include "extensions/renderer/native_extension_bindings_system.h" | 5 #include "extensions/renderer/native_extension_bindings_system.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "content/public/common/console_message_level.h" | 9 #include "content/public/common/console_message_level.h" |
10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 // Instantiates the binding object for the given |name|. |name| must specify a | 193 // Instantiates the binding object for the given |name|. |name| must specify a |
194 // specific feature. | 194 // specific feature. |
195 v8::Local<v8::Object> CreateRootBinding(v8::Local<v8::Context> context, | 195 v8::Local<v8::Object> CreateRootBinding(v8::Local<v8::Context> context, |
196 ScriptContext* script_context, | 196 ScriptContext* script_context, |
197 const std::string& name, | 197 const std::string& name, |
198 APIBindingsSystem* bindings_system) { | 198 APIBindingsSystem* bindings_system) { |
199 APIBindingHooks* hooks = nullptr; | 199 APIBindingHooks* hooks = nullptr; |
200 v8::Local<v8::Object> binding_object = bindings_system->CreateAPIInstance( | 200 v8::Local<v8::Object> binding_object = bindings_system->CreateAPIInstance( |
201 name, context, context->GetIsolate(), | 201 name, context, base::Bind(&IsAPIMethodAvailable, script_context), &hooks); |
202 base::Bind(&IsAPIMethodAvailable, script_context), &hooks); | |
203 | 202 |
204 gin::Handle<APIBindingBridge> bridge_handle = gin::CreateHandle( | 203 gin::Handle<APIBindingBridge> bridge_handle = gin::CreateHandle( |
205 context->GetIsolate(), | 204 context->GetIsolate(), |
206 new APIBindingBridge(hooks, context, binding_object, | 205 new APIBindingBridge(hooks, context, binding_object, |
207 script_context->GetExtensionID(), | 206 script_context->GetExtensionID(), |
208 script_context->GetContextTypeDescription(), | 207 script_context->GetContextTypeDescription(), |
209 base::Bind(&CallJsFunction))); | 208 base::Bind(&CallJsFunction))); |
210 v8::Local<v8::Value> native_api_bridge = bridge_handle.ToV8(); | 209 v8::Local<v8::Value> native_api_bridge = bridge_handle.ToV8(); |
211 script_context->module_system()->OnNativeBindingCreated(name, | 210 script_context->module_system()->OnNativeBindingCreated(name, |
212 native_api_bridge); | 211 native_api_bridge); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 v8::Local<v8::Value>* binding_util_out) { | 671 v8::Local<v8::Value>* binding_util_out) { |
673 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( | 672 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( |
674 context->GetIsolate(), | 673 context->GetIsolate(), |
675 new APIBindingJSUtil( | 674 new APIBindingJSUtil( |
676 api_system_.type_reference_map(), api_system_.request_handler(), | 675 api_system_.type_reference_map(), api_system_.request_handler(), |
677 api_system_.event_handler(), base::Bind(&CallJsFunction))); | 676 api_system_.event_handler(), base::Bind(&CallJsFunction))); |
678 *binding_util_out = handle.ToV8(); | 677 *binding_util_out = handle.ToV8(); |
679 } | 678 } |
680 | 679 |
681 } // namespace extensions | 680 } // namespace extensions |
OLD | NEW |