OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/extensions/dispatcher.h" | 5 #include "chrome/renderer/extensions/dispatcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "extensions/common/extension_api.h" | 75 #include "extensions/common/extension_api.h" |
76 #include "extensions/common/extension_urls.h" | 76 #include "extensions/common/extension_urls.h" |
77 #include "extensions/common/features/feature.h" | 77 #include "extensions/common/features/feature.h" |
78 #include "extensions/common/features/feature_provider.h" | 78 #include "extensions/common/features/feature_provider.h" |
79 #include "extensions/common/manifest.h" | 79 #include "extensions/common/manifest.h" |
80 #include "extensions/common/manifest_constants.h" | 80 #include "extensions/common/manifest_constants.h" |
81 #include "extensions/common/manifest_handlers/background_info.h" | 81 #include "extensions/common/manifest_handlers/background_info.h" |
82 #include "extensions/common/manifest_handlers/sandboxed_page_info.h" | 82 #include "extensions/common/manifest_handlers/sandboxed_page_info.h" |
83 #include "extensions/common/permissions/permission_set.h" | 83 #include "extensions/common/permissions/permission_set.h" |
84 #include "extensions/common/permissions/permissions_data.h" | 84 #include "extensions/common/permissions/permissions_data.h" |
| 85 #include "extensions/common/switches.h" |
85 #include "extensions/common/view_type.h" | 86 #include "extensions/common/view_type.h" |
86 #include "grit/common_resources.h" | 87 #include "grit/common_resources.h" |
87 #include "grit/renderer_resources.h" | 88 #include "grit/renderer_resources.h" |
88 #include "third_party/WebKit/public/platform/WebString.h" | 89 #include "third_party/WebKit/public/platform/WebString.h" |
89 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 90 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
90 #include "third_party/WebKit/public/web/WebCustomElement.h" | 91 #include "third_party/WebKit/public/web/WebCustomElement.h" |
91 #include "third_party/WebKit/public/web/WebDataSource.h" | 92 #include "third_party/WebKit/public/web/WebDataSource.h" |
92 #include "third_party/WebKit/public/web/WebDocument.h" | 93 #include "third_party/WebKit/public/web/WebDocument.h" |
93 #include "third_party/WebKit/public/web/WebFrame.h" | 94 #include "third_party/WebKit/public/web/WebFrame.h" |
94 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 95 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 Dispatcher::Dispatcher() | 454 Dispatcher::Dispatcher() |
454 : content_watcher_(new ContentWatcher()), | 455 : content_watcher_(new ContentWatcher()), |
455 is_webkit_initialized_(false), | 456 is_webkit_initialized_(false), |
456 webrequest_adblock_(false), | 457 webrequest_adblock_(false), |
457 webrequest_adblock_plus_(false), | 458 webrequest_adblock_plus_(false), |
458 webrequest_other_(false), | 459 webrequest_other_(false), |
459 source_map_(&ResourceBundle::GetSharedInstance()), | 460 source_map_(&ResourceBundle::GetSharedInstance()), |
460 v8_schema_registry_(new V8SchemaRegistry) { | 461 v8_schema_registry_(new V8SchemaRegistry) { |
461 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 462 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
462 is_extension_process_ = | 463 is_extension_process_ = |
463 command_line.HasSwitch(switches::kExtensionProcess) || | 464 command_line.HasSwitch(extensions::switches::kExtensionProcess) || |
464 command_line.HasSwitch(switches::kSingleProcess); | 465 command_line.HasSwitch(::switches::kSingleProcess); |
465 | 466 |
466 if (is_extension_process_) { | 467 if (is_extension_process_) { |
467 RenderThread::Get()->SetIdleNotificationDelayInMs( | 468 RenderThread::Get()->SetIdleNotificationDelayInMs( |
468 kInitialExtensionIdleHandlerDelayMs); | 469 kInitialExtensionIdleHandlerDelayMs); |
469 } | 470 } |
470 | 471 |
471 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); | 472 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); |
472 | 473 |
473 user_script_slave_.reset(new UserScriptSlave(&extensions_)); | 474 user_script_slave_.reset(new UserScriptSlave(&extensions_)); |
474 request_sender_.reset(new RequestSender(this)); | 475 request_sender_.reset(new RequestSender(this)); |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 bool is_within_platform_app = IsWithinPlatformApp(); | 1173 bool is_within_platform_app = IsWithinPlatformApp(); |
1173 // Inject custom JS into the platform app context. | 1174 // Inject custom JS into the platform app context. |
1174 if (is_within_platform_app) { | 1175 if (is_within_platform_app) { |
1175 module_system->Require("platformApp"); | 1176 module_system->Require("platformApp"); |
1176 } | 1177 } |
1177 | 1178 |
1178 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1179 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
1179 is_within_platform_app && | 1180 is_within_platform_app && |
1180 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 1181 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
1181 CommandLine::ForCurrentProcess()->HasSwitch( | 1182 CommandLine::ForCurrentProcess()->HasSwitch( |
1182 switches::kEnableAppWindowControls)) { | 1183 ::switches::kEnableAppWindowControls)) { |
1183 module_system->Require("windowControls"); | 1184 module_system->Require("windowControls"); |
1184 } | 1185 } |
1185 | 1186 |
1186 // Currently only platform apps and whitelisted component extensions support | 1187 // Currently only platform apps and whitelisted component extensions support |
1187 // the <webview> tag, because the "denyWebView" module will affect the | 1188 // the <webview> tag, because the "denyWebView" module will affect the |
1188 // performance of DOM modifications (http://crbug.com/196453). | 1189 // performance of DOM modifications (http://crbug.com/196453). |
1189 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform | 1190 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform |
1190 // apps. An ext/app runs in a blessed extension context, if it is the active | 1191 // apps. An ext/app runs in a blessed extension context, if it is the active |
1191 // extension in the current process, in other words, if it is loaded in a top | 1192 // extension in the current process, in other words, if it is loaded in a top |
1192 // frame. To support webview in a non-frame extension, we have to allow | 1193 // frame. To support webview in a non-frame extension, we have to allow |
(...skipping 21 matching lines...) Expand all Loading... |
1214 if (includeExperimental) | 1215 if (includeExperimental) |
1215 module_system->Require("webViewExperimental"); | 1216 module_system->Require("webViewExperimental"); |
1216 } else { | 1217 } else { |
1217 module_system->Require("denyWebView"); | 1218 module_system->Require("denyWebView"); |
1218 } | 1219 } |
1219 } | 1220 } |
1220 | 1221 |
1221 // Same comment as above for <adview> tag. | 1222 // Same comment as above for <adview> tag. |
1222 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1223 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
1223 is_within_platform_app) { | 1224 is_within_platform_app) { |
1224 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { | 1225 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1226 ::switches::kEnableAdview)) { |
1225 if (extension->HasAPIPermission(APIPermission::kAdView)) { | 1227 if (extension->HasAPIPermission(APIPermission::kAdView)) { |
1226 module_system->Require("adView"); | 1228 module_system->Require("adView"); |
1227 } else { | 1229 } else { |
1228 module_system->Require("denyAdView"); | 1230 module_system->Require("denyAdView"); |
1229 } | 1231 } |
1230 } | 1232 } |
1231 } | 1233 } |
1232 | 1234 |
1233 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); | 1235 VLOG(1) << "Num tracked contexts: " << v8_context_set_.size(); |
1234 } | 1236 } |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1467 | 1469 |
1468 void Dispatcher::OnUpdateUserScripts( | 1470 void Dispatcher::OnUpdateUserScripts( |
1469 base::SharedMemoryHandle scripts) { | 1471 base::SharedMemoryHandle scripts) { |
1470 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; | 1472 DCHECK(base::SharedMemory::IsHandleValid(scripts)) << "Bad scripts handle"; |
1471 user_script_slave_->UpdateScripts(scripts); | 1473 user_script_slave_->UpdateScripts(scripts); |
1472 UpdateActiveExtensions(); | 1474 UpdateActiveExtensions(); |
1473 } | 1475 } |
1474 | 1476 |
1475 void Dispatcher::UpdateActiveExtensions() { | 1477 void Dispatcher::UpdateActiveExtensions() { |
1476 // In single-process mode, the browser process reports the active extensions. | 1478 // In single-process mode, the browser process reports the active extensions. |
1477 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) | 1479 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) |
1478 return; | 1480 return; |
1479 | 1481 |
1480 std::set<std::string> active_extensions = active_extension_ids_; | 1482 std::set<std::string> active_extensions = active_extension_ids_; |
1481 user_script_slave_->GetActiveExtensions(&active_extensions); | 1483 user_script_slave_->GetActiveExtensions(&active_extensions); |
1482 crash_keys::SetActiveExtensions(active_extensions); | 1484 crash_keys::SetActiveExtensions(active_extensions); |
1483 } | 1485 } |
1484 | 1486 |
1485 void Dispatcher::OnUsingWebRequestAPI( | 1487 void Dispatcher::OnUsingWebRequestAPI( |
1486 bool adblock, bool adblock_plus, bool other) { | 1488 bool adblock, bool adblock_plus, bool other) { |
1487 webrequest_adblock_ = adblock; | 1489 webrequest_adblock_ = adblock; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 RenderView* background_view = | 1664 RenderView* background_view = |
1663 ExtensionHelper::GetBackgroundPage(extension_id); | 1665 ExtensionHelper::GetBackgroundPage(extension_id); |
1664 if (background_view) { | 1666 if (background_view) { |
1665 background_view->Send(new ExtensionHostMsg_EventAck( | 1667 background_view->Send(new ExtensionHostMsg_EventAck( |
1666 background_view->GetRoutingID())); | 1668 background_view->GetRoutingID())); |
1667 } | 1669 } |
1668 } | 1670 } |
1669 } | 1671 } |
1670 | 1672 |
1671 } // namespace extensions | 1673 } // namespace extensions |
OLD | NEW |