| 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/js_extension_bindings_system.h" | 5 #include "extensions/renderer/js_extension_bindings_system.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "content/public/child/v8_value_converter.h" | 9 #include "content/public/child/v8_value_converter.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "extensions/common/extension.h" | 11 #include "extensions/common/extension.h" |
| 12 #include "extensions/common/extension_api.h" | 12 #include "extensions/common/extension_api.h" |
| 13 #include "extensions/common/extension_urls.h" | 13 #include "extensions/common/extension_urls.h" |
| 14 #include "extensions/common/extensions_client.h" | 14 #include "extensions/common/extensions_client.h" |
| 15 #include "extensions/common/features/feature.h" | 15 #include "extensions/common/features/feature.h" |
| 16 #include "extensions/common/features/feature_provider.h" | 16 #include "extensions/common/features/feature_provider.h" |
| 17 #include "extensions/common/manifest_constants.h" | 17 #include "extensions/common/manifest_constants.h" |
| 18 #include "extensions/common/manifest_handlers/externally_connectable.h" | 18 #include "extensions/common/manifest_handlers/externally_connectable.h" |
| 19 #include "extensions/renderer/binding_generating_native_handler.h" | 19 #include "extensions/renderer/binding_generating_native_handler.h" |
| 20 #include "extensions/renderer/event_bindings.h" |
| 20 #include "extensions/renderer/renderer_extension_registry.h" | 21 #include "extensions/renderer/renderer_extension_registry.h" |
| 21 #include "extensions/renderer/resource_bundle_source_map.h" | 22 #include "extensions/renderer/resource_bundle_source_map.h" |
| 22 #include "extensions/renderer/script_context.h" | 23 #include "extensions/renderer/script_context.h" |
| 23 #include "gin/converter.h" | 24 #include "gin/converter.h" |
| 24 #include "v8/include/v8.h" | 25 #include "v8/include/v8.h" |
| 25 | 26 |
| 26 namespace extensions { | 27 namespace extensions { |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 arguments.push_back( | 266 arguments.push_back( |
| 266 converter->ToV8Value(filtering_info, context->v8_context())); | 267 converter->ToV8Value(filtering_info, context->v8_context())); |
| 267 } | 268 } |
| 268 } | 269 } |
| 269 | 270 |
| 270 context->module_system()->CallModuleMethodSafe( | 271 context->module_system()->CallModuleMethodSafe( |
| 271 kEventBindings, kEventDispatchFunction, arguments.size(), | 272 kEventBindings, kEventDispatchFunction, arguments.size(), |
| 272 arguments.data()); | 273 arguments.data()); |
| 273 } | 274 } |
| 274 | 275 |
| 276 bool JsExtensionBindingsSystem::HasEventListenerInContext( |
| 277 const std::string& event_name, |
| 278 ScriptContext* context) { |
| 279 return EventBindings::HasListener(context, event_name); |
| 280 } |
| 281 |
| 275 void JsExtensionBindingsSystem::RegisterBinding( | 282 void JsExtensionBindingsSystem::RegisterBinding( |
| 276 const std::string& api_name, | 283 const std::string& api_name, |
| 277 const std::string& api_bind_name, | 284 const std::string& api_bind_name, |
| 278 ScriptContext* context) { | 285 ScriptContext* context) { |
| 279 std::string bind_name; | 286 std::string bind_name; |
| 280 v8::Local<v8::Object> bind_object = | 287 v8::Local<v8::Object> bind_object = |
| 281 GetOrCreateBindObjectIfAvailable(api_bind_name, &bind_name, context); | 288 GetOrCreateBindObjectIfAvailable(api_bind_name, &bind_name, context); |
| 282 | 289 |
| 283 // Empty if the bind object failed to be created, probably because the | 290 // Empty if the bind object failed to be created, probably because the |
| 284 // extension overrode chrome with a non-object, e.g. window.chrome = true. | 291 // extension overrode chrome with a non-object, e.g. window.chrome = true. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 310 std::unique_ptr<NativeHandler>( | 317 std::unique_ptr<NativeHandler>( |
| 311 new BindingGeneratingNativeHandler(context, api_name, "binding"))); | 318 new BindingGeneratingNativeHandler(context, api_name, "binding"))); |
| 312 module_system->SetNativeLazyField(bind_object, bind_name, api_bind_name, | 319 module_system->SetNativeLazyField(bind_object, bind_name, api_bind_name, |
| 313 "binding"); | 320 "binding"); |
| 314 } else { | 321 } else { |
| 315 module_system->SetLazyField(bind_object, bind_name, api_name, "binding"); | 322 module_system->SetLazyField(bind_object, bind_name, api_name, "binding"); |
| 316 } | 323 } |
| 317 } | 324 } |
| 318 | 325 |
| 319 } // namespace extensions | 326 } // namespace extensions |
| OLD | NEW |