| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/dispatcher.h" | 5 #include "extensions/renderer/dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // Enable natives in startup. | 338 // Enable natives in startup. |
| 339 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); | 339 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); |
| 340 | 340 |
| 341 RegisterNativeHandlers(module_system, context, | 341 RegisterNativeHandlers(module_system, context, |
| 342 bindings_system_->GetRequestSender(), | 342 bindings_system_->GetRequestSender(), |
| 343 v8_schema_registry_.get()); | 343 v8_schema_registry_.get()); |
| 344 | 344 |
| 345 bindings_system_->DidCreateScriptContext(context); | 345 bindings_system_->DidCreateScriptContext(context); |
| 346 UpdateBindingsForContext(context); | 346 UpdateBindingsForContext(context); |
| 347 | 347 |
| 348 bool is_within_platform_app = IsWithinPlatformApp(); | |
| 349 // Inject custom JS into the platform app context. | 348 // Inject custom JS into the platform app context. |
| 350 if (is_within_platform_app) { | 349 if (IsWithinPlatformApp()) { |
| 351 module_system->Require("platformApp"); | 350 module_system->Require("platformApp"); |
| 352 } | 351 } |
| 353 | 352 |
| 354 RequireGuestViewModules(context); | 353 RequireGuestViewModules(context); |
| 355 delegate_->RequireAdditionalModules(context, is_within_platform_app); | 354 delegate_->RequireAdditionalModules(context); |
| 356 | 355 |
| 357 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; | 356 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; |
| 358 switch (context->context_type()) { | 357 switch (context->context_type()) { |
| 359 case Feature::UNSPECIFIED_CONTEXT: | 358 case Feature::UNSPECIFIED_CONTEXT: |
| 360 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified", | 359 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified", |
| 361 elapsed); | 360 elapsed); |
| 362 break; | 361 break; |
| 363 case Feature::BLESSED_EXTENSION_CONTEXT: | 362 case Feature::BLESSED_EXTENSION_CONTEXT: |
| 364 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed); | 363 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed); |
| 365 break; | 364 break; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 RegisterNativeHandlers(module_system, context, | 452 RegisterNativeHandlers(module_system, context, |
| 454 worker_bindings_system->GetRequestSender(), | 453 worker_bindings_system->GetRequestSender(), |
| 455 WorkerThreadDispatcher::GetV8SchemaRegistry()); | 454 WorkerThreadDispatcher::GetV8SchemaRegistry()); |
| 456 | 455 |
| 457 worker_bindings_system->DidCreateScriptContext(context); | 456 worker_bindings_system->DidCreateScriptContext(context); |
| 458 worker_bindings_system->UpdateBindingsForContext(context); | 457 worker_bindings_system->UpdateBindingsForContext(context); |
| 459 | 458 |
| 460 // TODO(lazyboy): Get rid of RequireGuestViewModules() as this doesn't seem | 459 // TODO(lazyboy): Get rid of RequireGuestViewModules() as this doesn't seem |
| 461 // necessary for Extension SW. | 460 // necessary for Extension SW. |
| 462 RequireGuestViewModules(context); | 461 RequireGuestViewModules(context); |
| 463 delegate_->RequireAdditionalModules(context, | 462 delegate_->RequireAdditionalModules(context); |
| 464 false /* is_within_platform_app */); | |
| 465 } | 463 } |
| 466 | 464 |
| 467 g_worker_script_context_set.Get().Insert(base::WrapUnique(context)); | 465 g_worker_script_context_set.Get().Insert(base::WrapUnique(context)); |
| 468 | 466 |
| 469 v8::Isolate* isolate = context->isolate(); | 467 v8::Isolate* isolate = context->isolate(); |
| 470 | 468 |
| 471 // Fetch the source code for service_worker_bindings.js. | 469 // Fetch the source code for service_worker_bindings.js. |
| 472 base::StringPiece script_resource = | 470 base::StringPiece script_resource = |
| 473 ResourceBundle::GetSharedInstance().GetRawDataResource( | 471 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 474 IDR_SERVICE_WORKER_BINDINGS_JS); | 472 IDR_SERVICE_WORKER_BINDINGS_JS); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 resources.push_back(std::make_pair("extensions/common/api/mime_handler.mojom", | 775 resources.push_back(std::make_pair("extensions/common/api/mime_handler.mojom", |
| 778 IDR_MIME_HANDLER_MOJOM_JS)); | 776 IDR_MIME_HANDLER_MOJOM_JS)); |
| 779 resources.push_back( | 777 resources.push_back( |
| 780 std::make_pair("mojoPrivate", IDR_MOJO_PRIVATE_CUSTOM_BINDINGS_JS)); | 778 std::make_pair("mojoPrivate", IDR_MOJO_PRIVATE_CUSTOM_BINDINGS_JS)); |
| 781 resources.push_back( | 779 resources.push_back( |
| 782 std::make_pair("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS)); | 780 std::make_pair("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS)); |
| 783 resources.push_back(std::make_pair("printerProvider", | 781 resources.push_back(std::make_pair("printerProvider", |
| 784 IDR_PRINTER_PROVIDER_CUSTOM_BINDINGS_JS)); | 782 IDR_PRINTER_PROVIDER_CUSTOM_BINDINGS_JS)); |
| 785 resources.push_back( | 783 resources.push_back( |
| 786 std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS)); | 784 std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS)); |
| 787 resources.push_back(std::make_pair("windowControls", IDR_WINDOW_CONTROLS_JS)); | |
| 788 resources.push_back( | 785 resources.push_back( |
| 789 std::make_pair("webViewRequest", | 786 std::make_pair("webViewRequest", |
| 790 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS)); | 787 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS)); |
| 791 resources.push_back(std::make_pair("binding", IDR_BINDING_JS)); | 788 resources.push_back(std::make_pair("binding", IDR_BINDING_JS)); |
| 792 | 789 |
| 793 // Custom types sources. | 790 // Custom types sources. |
| 794 resources.push_back(std::make_pair("StorageArea", IDR_STORAGE_AREA_JS)); | 791 resources.push_back(std::make_pair("StorageArea", IDR_STORAGE_AREA_JS)); |
| 795 | 792 |
| 796 // Platform app sources that are not API-specific.. | 793 // Platform app sources that are not API-specific.. |
| 797 resources.push_back(std::make_pair("platformApp", IDR_PLATFORM_APP_JS)); | 794 resources.push_back(std::make_pair("platformApp", IDR_PLATFORM_APP_JS)); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 // The "guestViewDeny" module must always be loaded last. It registers | 1458 // The "guestViewDeny" module must always be loaded last. It registers |
| 1462 // error-providing custom elements for the GuestView types that are not | 1459 // error-providing custom elements for the GuestView types that are not |
| 1463 // available, and thus all of those types must have been checked and loaded | 1460 // available, and thus all of those types must have been checked and loaded |
| 1464 // (or not loaded) beforehand. | 1461 // (or not loaded) beforehand. |
| 1465 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 1462 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 1466 module_system->Require("guestViewDeny"); | 1463 module_system->Require("guestViewDeny"); |
| 1467 } | 1464 } |
| 1468 } | 1465 } |
| 1469 | 1466 |
| 1470 } // namespace extensions | 1467 } // namespace extensions |
| OLD | NEW |