| 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 // Enable natives in startup. | 342 // Enable natives in startup. |
| 343 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); | 343 ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system); |
| 344 | 344 |
| 345 RegisterNativeHandlers(module_system, context, | 345 RegisterNativeHandlers(module_system, context, |
| 346 bindings_system_->GetRequestSender(), | 346 bindings_system_->GetRequestSender(), |
| 347 v8_schema_registry_.get()); | 347 v8_schema_registry_.get()); |
| 348 | 348 |
| 349 bindings_system_->DidCreateScriptContext(context); | 349 bindings_system_->DidCreateScriptContext(context); |
| 350 UpdateBindingsForContext(context); | 350 UpdateBindingsForContext(context); |
| 351 | 351 |
| 352 bool is_within_platform_app = IsWithinPlatformApp(); | |
| 353 // Inject custom JS into the platform app context. | 352 // Inject custom JS into the platform app context. |
| 354 if (is_within_platform_app) { | 353 if (IsWithinPlatformApp()) { |
| 355 module_system->Require("platformApp"); | 354 module_system->Require("platformApp"); |
| 356 } | 355 } |
| 357 | 356 |
| 358 RequireGuestViewModules(context); | 357 RequireGuestViewModules(context); |
| 359 delegate_->RequireAdditionalModules(context, is_within_platform_app); | 358 delegate_->RequireAdditionalModules(context); |
| 360 | 359 |
| 361 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; | 360 const base::TimeDelta elapsed = base::TimeTicks::Now() - start_time; |
| 362 switch (context->context_type()) { | 361 switch (context->context_type()) { |
| 363 case Feature::UNSPECIFIED_CONTEXT: | 362 case Feature::UNSPECIFIED_CONTEXT: |
| 364 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified", | 363 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Unspecified", |
| 365 elapsed); | 364 elapsed); |
| 366 break; | 365 break; |
| 367 case Feature::BLESSED_EXTENSION_CONTEXT: | 366 case Feature::BLESSED_EXTENSION_CONTEXT: |
| 368 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed); | 367 UMA_HISTOGRAM_TIMES("Extensions.DidCreateScriptContext_Blessed", elapsed); |
| 369 break; | 368 break; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 RegisterNativeHandlers(module_system, context, | 457 RegisterNativeHandlers(module_system, context, |
| 459 worker_bindings_system->GetRequestSender(), | 458 worker_bindings_system->GetRequestSender(), |
| 460 WorkerThreadDispatcher::GetV8SchemaRegistry()); | 459 WorkerThreadDispatcher::GetV8SchemaRegistry()); |
| 461 | 460 |
| 462 worker_bindings_system->DidCreateScriptContext(context); | 461 worker_bindings_system->DidCreateScriptContext(context); |
| 463 worker_bindings_system->UpdateBindingsForContext(context); | 462 worker_bindings_system->UpdateBindingsForContext(context); |
| 464 | 463 |
| 465 // TODO(lazyboy): Get rid of RequireGuestViewModules() as this doesn't seem | 464 // TODO(lazyboy): Get rid of RequireGuestViewModules() as this doesn't seem |
| 466 // necessary for Extension SW. | 465 // necessary for Extension SW. |
| 467 RequireGuestViewModules(context); | 466 RequireGuestViewModules(context); |
| 468 delegate_->RequireAdditionalModules(context, | 467 delegate_->RequireAdditionalModules(context); |
| 469 false /* is_within_platform_app */); | |
| 470 } | 468 } |
| 471 | 469 |
| 472 g_worker_script_context_set.Get().Insert(base::WrapUnique(context)); | 470 g_worker_script_context_set.Get().Insert(base::WrapUnique(context)); |
| 473 | 471 |
| 474 v8::Isolate* isolate = context->isolate(); | 472 v8::Isolate* isolate = context->isolate(); |
| 475 | 473 |
| 476 // Fetch the source code for service_worker_bindings.js. | 474 // Fetch the source code for service_worker_bindings.js. |
| 477 base::StringPiece script_resource = | 475 base::StringPiece script_resource = |
| 478 ResourceBundle::GetSharedInstance().GetRawDataResource( | 476 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 479 IDR_SERVICE_WORKER_BINDINGS_JS); | 477 IDR_SERVICE_WORKER_BINDINGS_JS); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 resources.push_back(std::make_pair("extensions/common/api/mime_handler.mojom", | 781 resources.push_back(std::make_pair("extensions/common/api/mime_handler.mojom", |
| 784 IDR_MIME_HANDLER_MOJOM_JS)); | 782 IDR_MIME_HANDLER_MOJOM_JS)); |
| 785 resources.push_back( | 783 resources.push_back( |
| 786 std::make_pair("mojoPrivate", IDR_MOJO_PRIVATE_CUSTOM_BINDINGS_JS)); | 784 std::make_pair("mojoPrivate", IDR_MOJO_PRIVATE_CUSTOM_BINDINGS_JS)); |
| 787 resources.push_back( | 785 resources.push_back( |
| 788 std::make_pair("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS)); | 786 std::make_pair("permissions", IDR_PERMISSIONS_CUSTOM_BINDINGS_JS)); |
| 789 resources.push_back(std::make_pair("printerProvider", | 787 resources.push_back(std::make_pair("printerProvider", |
| 790 IDR_PRINTER_PROVIDER_CUSTOM_BINDINGS_JS)); | 788 IDR_PRINTER_PROVIDER_CUSTOM_BINDINGS_JS)); |
| 791 resources.push_back( | 789 resources.push_back( |
| 792 std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS)); | 790 std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS)); |
| 793 resources.push_back(std::make_pair("windowControls", IDR_WINDOW_CONTROLS_JS)); | |
| 794 resources.push_back( | 791 resources.push_back( |
| 795 std::make_pair("webViewRequest", | 792 std::make_pair("webViewRequest", |
| 796 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS)); | 793 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS)); |
| 797 resources.push_back(std::make_pair("binding", IDR_BINDING_JS)); | 794 resources.push_back(std::make_pair("binding", IDR_BINDING_JS)); |
| 798 | 795 |
| 799 // Custom types sources. | 796 // Custom types sources. |
| 800 resources.push_back(std::make_pair("StorageArea", IDR_STORAGE_AREA_JS)); | 797 resources.push_back(std::make_pair("StorageArea", IDR_STORAGE_AREA_JS)); |
| 801 | 798 |
| 802 // Platform app sources that are not API-specific.. | 799 // Platform app sources that are not API-specific.. |
| 803 resources.push_back(std::make_pair("platformApp", IDR_PLATFORM_APP_JS)); | 800 resources.push_back(std::make_pair("platformApp", IDR_PLATFORM_APP_JS)); |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1467 // The "guestViewDeny" module must always be loaded last. It registers | 1464 // The "guestViewDeny" module must always be loaded last. It registers |
| 1468 // error-providing custom elements for the GuestView types that are not | 1465 // error-providing custom elements for the GuestView types that are not |
| 1469 // available, and thus all of those types must have been checked and loaded | 1466 // available, and thus all of those types must have been checked and loaded |
| 1470 // (or not loaded) beforehand. | 1467 // (or not loaded) beforehand. |
| 1471 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 1468 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 1472 module_system->Require("guestViewDeny"); | 1469 module_system->Require("guestViewDeny"); |
| 1473 } | 1470 } |
| 1474 } | 1471 } |
| 1475 | 1472 |
| 1476 } // namespace extensions | 1473 } // namespace extensions |
| OLD | NEW |