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" |
11 #include "extensions/common/constants.h" | 11 #include "extensions/common/constants.h" |
12 #include "extensions/common/event_filtering_info.h" | 12 #include "extensions/common/event_filtering_info.h" |
13 #include "extensions/common/extension_api.h" | 13 #include "extensions/common/extension_api.h" |
14 #include "extensions/common/extension_messages.h" | 14 #include "extensions/common/extension_messages.h" |
15 #include "extensions/common/features/feature_provider.h" | 15 #include "extensions/common/features/feature_provider.h" |
16 #include "extensions/renderer/api_binding_bridge.h" | 16 #include "extensions/renderer/api_binding_bridge.h" |
17 #include "extensions/renderer/api_binding_hooks.h" | 17 #include "extensions/renderer/api_binding_hooks.h" |
18 #include "extensions/renderer/api_binding_js_util.h" | 18 #include "extensions/renderer/api_binding_js_util.h" |
19 #include "extensions/renderer/chrome_setting.h" | 19 #include "extensions/renderer/chrome_setting.h" |
20 #include "extensions/renderer/console.h" | 20 #include "extensions/renderer/console.h" |
21 #include "extensions/renderer/content_setting.h" | 21 #include "extensions/renderer/content_setting.h" |
| 22 #include "extensions/renderer/declarative_content_hooks_delegate.h" |
22 #include "extensions/renderer/module_system.h" | 23 #include "extensions/renderer/module_system.h" |
23 #include "extensions/renderer/script_context.h" | 24 #include "extensions/renderer/script_context.h" |
24 #include "extensions/renderer/script_context_set.h" | 25 #include "extensions/renderer/script_context_set.h" |
25 #include "extensions/renderer/storage_area.h" | 26 #include "extensions/renderer/storage_area.h" |
26 #include "extensions/renderer/web_request_hooks.h" | 27 #include "extensions/renderer/web_request_hooks.h" |
27 #include "gin/converter.h" | 28 #include "gin/converter.h" |
28 #include "gin/handle.h" | 29 #include "gin/handle.h" |
29 #include "gin/per_context_data.h" | 30 #include "gin/per_context_data.h" |
30 #include "third_party/WebKit/public/web/WebDocument.h" | 31 #include "third_party/WebKit/public/web/WebDocument.h" |
31 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 weak_factory_(this) { | 350 weak_factory_(this) { |
350 api_system_.RegisterCustomType("storage.StorageArea", | 351 api_system_.RegisterCustomType("storage.StorageArea", |
351 base::Bind(&StorageArea::CreateStorageArea)); | 352 base::Bind(&StorageArea::CreateStorageArea)); |
352 api_system_.RegisterCustomType("types.ChromeSetting", | 353 api_system_.RegisterCustomType("types.ChromeSetting", |
353 base::Bind(&ChromeSetting::Create)); | 354 base::Bind(&ChromeSetting::Create)); |
354 api_system_.RegisterCustomType( | 355 api_system_.RegisterCustomType( |
355 "contentSettings.ContentSetting", | 356 "contentSettings.ContentSetting", |
356 base::Bind(&ContentSetting::Create, base::Bind(&CallJsFunction))); | 357 base::Bind(&ContentSetting::Create, base::Bind(&CallJsFunction))); |
357 api_system_.GetHooksForAPI("webRequest") | 358 api_system_.GetHooksForAPI("webRequest") |
358 ->SetDelegate(base::MakeUnique<WebRequestHooks>()); | 359 ->SetDelegate(base::MakeUnique<WebRequestHooks>()); |
| 360 api_system_.GetHooksForAPI("declarativeContent") |
| 361 ->SetDelegate(base::MakeUnique<DeclarativeContentHooksDelegate>()); |
359 } | 362 } |
360 | 363 |
361 NativeExtensionBindingsSystem::~NativeExtensionBindingsSystem() {} | 364 NativeExtensionBindingsSystem::~NativeExtensionBindingsSystem() {} |
362 | 365 |
363 void NativeExtensionBindingsSystem::DidCreateScriptContext( | 366 void NativeExtensionBindingsSystem::DidCreateScriptContext( |
364 ScriptContext* context) { | 367 ScriptContext* context) { |
365 v8::Isolate* isolate = context->isolate(); | 368 v8::Isolate* isolate = context->isolate(); |
366 v8::HandleScope handle_scope(isolate); | 369 v8::HandleScope handle_scope(isolate); |
367 v8::Local<v8::Context> v8_context = context->v8_context(); | 370 v8::Local<v8::Context> v8_context = context->v8_context(); |
368 gin::PerContextData* per_context_data = gin::PerContextData::From(v8_context); | 371 gin::PerContextData* per_context_data = gin::PerContextData::From(v8_context); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 v8::Local<v8::Value>* binding_util_out) { | 674 v8::Local<v8::Value>* binding_util_out) { |
672 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( | 675 gin::Handle<APIBindingJSUtil> handle = gin::CreateHandle( |
673 context->GetIsolate(), | 676 context->GetIsolate(), |
674 new APIBindingJSUtil( | 677 new APIBindingJSUtil( |
675 api_system_.type_reference_map(), api_system_.request_handler(), | 678 api_system_.type_reference_map(), api_system_.request_handler(), |
676 api_system_.event_handler(), base::Bind(&CallJsFunction))); | 679 api_system_.event_handler(), base::Bind(&CallJsFunction))); |
677 *binding_util_out = handle.ToV8(); | 680 *binding_util_out = handle.ToV8(); |
678 } | 681 } |
679 | 682 |
680 } // namespace extensions | 683 } // namespace extensions |
OLD | NEW |