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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 resources.push_back(std::make_pair("imageUtil", IDR_IMAGE_UTIL_JS)); | 480 resources.push_back(std::make_pair("imageUtil", IDR_IMAGE_UTIL_JS)); |
481 resources.push_back(std::make_pair("json_schema", IDR_JSON_SCHEMA_JS)); | 481 resources.push_back(std::make_pair("json_schema", IDR_JSON_SCHEMA_JS)); |
482 resources.push_back(std::make_pair("lastError", IDR_LAST_ERROR_JS)); | 482 resources.push_back(std::make_pair("lastError", IDR_LAST_ERROR_JS)); |
483 resources.push_back(std::make_pair("messaging", IDR_MESSAGING_JS)); | 483 resources.push_back(std::make_pair("messaging", IDR_MESSAGING_JS)); |
484 resources.push_back(std::make_pair("messaging_utils", | 484 resources.push_back(std::make_pair("messaging_utils", |
485 IDR_MESSAGING_UTILS_JS)); | 485 IDR_MESSAGING_UTILS_JS)); |
486 resources.push_back(std::make_pair(kSchemaUtils, IDR_SCHEMA_UTILS_JS)); | 486 resources.push_back(std::make_pair(kSchemaUtils, IDR_SCHEMA_UTILS_JS)); |
487 resources.push_back(std::make_pair("sendRequest", IDR_SEND_REQUEST_JS)); | 487 resources.push_back(std::make_pair("sendRequest", IDR_SEND_REQUEST_JS)); |
488 resources.push_back(std::make_pair("setIcon", IDR_SET_ICON_JS)); | 488 resources.push_back(std::make_pair("setIcon", IDR_SET_ICON_JS)); |
489 resources.push_back(std::make_pair("surfaceWorker", IDR_SURFACE_VIEW_JS)); | |
490 resources.push_back(std::make_pair("test", IDR_TEST_CUSTOM_BINDINGS_JS)); | 489 resources.push_back(std::make_pair("test", IDR_TEST_CUSTOM_BINDINGS_JS)); |
491 resources.push_back( | 490 resources.push_back( |
492 std::make_pair("test_environment_specific_bindings", | 491 std::make_pair("test_environment_specific_bindings", |
493 IDR_BROWSER_TEST_ENVIRONMENT_SPECIFIC_BINDINGS_JS)); | 492 IDR_BROWSER_TEST_ENVIRONMENT_SPECIFIC_BINDINGS_JS)); |
494 resources.push_back(std::make_pair("uncaught_exception_handler", | 493 resources.push_back(std::make_pair("uncaught_exception_handler", |
495 IDR_UNCAUGHT_EXCEPTION_HANDLER_JS)); | 494 IDR_UNCAUGHT_EXCEPTION_HANDLER_JS)); |
496 resources.push_back(std::make_pair("unload_event", IDR_UNLOAD_EVENT_JS)); | 495 resources.push_back(std::make_pair("unload_event", IDR_UNLOAD_EVENT_JS)); |
497 resources.push_back(std::make_pair("utils", IDR_UTILS_JS)); | 496 resources.push_back(std::make_pair("utils", IDR_UTILS_JS)); |
498 resources.push_back(std::make_pair("webRequest", | 497 resources.push_back(std::make_pair("webRequest", |
499 IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS)); | 498 IDR_WEB_REQUEST_CUSTOM_BINDINGS_JS)); |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 blink::WebCustomElement::addEmbedderCustomElementName("appview"); | 1122 blink::WebCustomElement::addEmbedderCustomElementName("appview"); |
1124 blink::WebCustomElement::addEmbedderCustomElementName("appviewbrowserplugin"); | 1123 blink::WebCustomElement::addEmbedderCustomElementName("appviewbrowserplugin"); |
1125 blink::WebCustomElement::addEmbedderCustomElementName("extensionoptions"); | 1124 blink::WebCustomElement::addEmbedderCustomElementName("extensionoptions"); |
1126 blink::WebCustomElement::addEmbedderCustomElementName( | 1125 blink::WebCustomElement::addEmbedderCustomElementName( |
1127 "extensionoptionsbrowserplugin"); | 1126 "extensionoptionsbrowserplugin"); |
1128 blink::WebCustomElement::addEmbedderCustomElementName("extensionview"); | 1127 blink::WebCustomElement::addEmbedderCustomElementName("extensionview"); |
1129 blink::WebCustomElement::addEmbedderCustomElementName( | 1128 blink::WebCustomElement::addEmbedderCustomElementName( |
1130 "extensionviewbrowserplugin"); | 1129 "extensionviewbrowserplugin"); |
1131 blink::WebCustomElement::addEmbedderCustomElementName("webview"); | 1130 blink::WebCustomElement::addEmbedderCustomElementName("webview"); |
1132 blink::WebCustomElement::addEmbedderCustomElementName("webviewbrowserplugin"); | 1131 blink::WebCustomElement::addEmbedderCustomElementName("webviewbrowserplugin"); |
1133 blink::WebCustomElement::addEmbedderCustomElementName("surfaceview"); | |
1134 blink::WebCustomElement::addEmbedderCustomElementName( | |
1135 "surfaceviewbrowserplugin"); | |
1136 } | 1132 } |
1137 | 1133 |
1138 void Dispatcher::UpdateBindings(const std::string& extension_id) { | 1134 void Dispatcher::UpdateBindings(const std::string& extension_id) { |
1139 script_context_set().ForEach(extension_id, | 1135 script_context_set().ForEach(extension_id, |
1140 base::Bind(&Dispatcher::UpdateBindingsForContext, | 1136 base::Bind(&Dispatcher::UpdateBindingsForContext, |
1141 base::Unretained(this))); | 1137 base::Unretained(this))); |
1142 } | 1138 } |
1143 | 1139 |
1144 void Dispatcher::UpdateBindingsForContext(ScriptContext* context) { | 1140 void Dispatcher::UpdateBindingsForContext(ScriptContext* context) { |
1145 v8::HandleScope handle_scope(context->isolate()); | 1141 v8::HandleScope handle_scope(context->isolate()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 context->GetContextTypeDescription(), | 1265 context->GetContextTypeDescription(), |
1270 ExtensionsRendererClient::Get()->IsIncognitoProcess(), | 1266 ExtensionsRendererClient::Get()->IsIncognitoProcess(), |
1271 is_component_extension, | 1267 is_component_extension, |
1272 manifest_version, | 1268 manifest_version, |
1273 send_request_disabled))); | 1269 send_request_disabled))); |
1274 | 1270 |
1275 delegate_->RegisterNativeHandlers(this, module_system, context); | 1271 delegate_->RegisterNativeHandlers(this, module_system, context); |
1276 } | 1272 } |
1277 | 1273 |
1278 bool Dispatcher::IsRuntimeAvailableToContext(ScriptContext* context) { | 1274 bool Dispatcher::IsRuntimeAvailableToContext(ScriptContext* context) { |
1279 if (extensions::FeatureSwitch::surface_worker()->IsEnabled() && | |
1280 context->GetAvailability("surfaceWorkerInternal").is_available()) { | |
1281 return true; | |
1282 } | |
1283 for (const auto& extension : extensions_) { | 1275 for (const auto& extension : extensions_) { |
1284 ExternallyConnectableInfo* info = static_cast<ExternallyConnectableInfo*>( | 1276 ExternallyConnectableInfo* info = static_cast<ExternallyConnectableInfo*>( |
1285 extension->GetManifestData(manifest_keys::kExternallyConnectable)); | 1277 extension->GetManifestData(manifest_keys::kExternallyConnectable)); |
1286 if (info && info->matches.MatchesURL(context->GetURL())) | 1278 if (info && info->matches.MatchesURL(context->GetURL())) |
1287 return true; | 1279 return true; |
1288 } | 1280 } |
1289 return false; | 1281 return false; |
1290 } | 1282 } |
1291 | 1283 |
1292 void Dispatcher::UpdateContentCapabilities(ScriptContext* context) { | 1284 void Dispatcher::UpdateContentCapabilities(ScriptContext* context) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 module_system->Require("extensionOptionsAttributes"); | 1404 module_system->Require("extensionOptionsAttributes"); |
1413 } | 1405 } |
1414 | 1406 |
1415 // Require ExtensionView. | 1407 // Require ExtensionView. |
1416 if (context->GetAvailability("extensionViewInternal").is_available()) { | 1408 if (context->GetAvailability("extensionViewInternal").is_available()) { |
1417 module_system->Require("extensionView"); | 1409 module_system->Require("extensionView"); |
1418 module_system->Require("extensionViewApiMethods"); | 1410 module_system->Require("extensionViewApiMethods"); |
1419 module_system->Require("extensionViewAttributes"); | 1411 module_system->Require("extensionViewAttributes"); |
1420 } | 1412 } |
1421 | 1413 |
1422 // Require SurfaceView. | |
1423 if (extensions::FeatureSwitch::surface_worker()->IsEnabled() && | |
1424 context->GetAvailability("surfaceWorkerInternal").is_available()) { | |
1425 module_system->Require("surfaceWorker"); | |
1426 } | |
1427 | |
1428 // Require WebView. | 1414 // Require WebView. |
1429 if (context->GetAvailability("webViewInternal").is_available()) { | 1415 if (context->GetAvailability("webViewInternal").is_available()) { |
1430 module_system->Require("webView"); | 1416 module_system->Require("webView"); |
1431 module_system->Require("webViewApiMethods"); | 1417 module_system->Require("webViewApiMethods"); |
1432 module_system->Require("webViewAttributes"); | 1418 module_system->Require("webViewAttributes"); |
1433 | 1419 |
1434 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { | 1420 if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
1435 module_system->Require("webViewIframe"); | 1421 module_system->Require("webViewIframe"); |
1436 } | 1422 } |
1437 } | 1423 } |
(...skipping 10 matching lines...) Expand all Loading... |
1448 void Dispatcher::AddChannelSpecificFeatures() { | 1434 void Dispatcher::AddChannelSpecificFeatures() { |
1449 // chrome-extension: resources should be allowed to register a Service Worker. | 1435 // chrome-extension: resources should be allowed to register a Service Worker. |
1450 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) | 1436 if (FeatureProvider::GetBehaviorFeature(BehaviorFeature::kServiceWorker) |
1451 ->IsAvailableToEnvironment() | 1437 ->IsAvailableToEnvironment() |
1452 .is_available()) | 1438 .is_available()) |
1453 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( | 1439 WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers( |
1454 WebString::fromUTF8(kExtensionScheme)); | 1440 WebString::fromUTF8(kExtensionScheme)); |
1455 } | 1441 } |
1456 | 1442 |
1457 } // namespace extensions | 1443 } // namespace extensions |
OLD | NEW |