Chromium Code Reviews| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 webrequest_other_(false), | 406 webrequest_other_(false), |
| 407 source_map_(&ResourceBundle::GetSharedInstance()), | 407 source_map_(&ResourceBundle::GetSharedInstance()), |
| 408 v8_schema_registry_(new V8SchemaRegistry) { | 408 v8_schema_registry_(new V8SchemaRegistry) { |
| 409 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 409 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
| 410 is_extension_process_ = | 410 is_extension_process_ = |
| 411 command_line.HasSwitch(switches::kExtensionProcess) || | 411 command_line.HasSwitch(switches::kExtensionProcess) || |
| 412 command_line.HasSwitch(switches::kSingleProcess); | 412 command_line.HasSwitch(switches::kSingleProcess); |
| 413 | 413 |
| 414 if (is_extension_process_) { | 414 if (is_extension_process_) { |
| 415 RenderThread::Get()->SetIdleNotificationDelayInMs( | 415 RenderThread::Get()->SetIdleNotificationDelayInMs( |
| 416 kInitialExtensionIdleHandlerDelayMs); | 416 kInitialExtensionIdleHandlerDelayMs); |
|
not at google - send to devlin
2013/09/23 20:59:12
... however, if you do want to just always set the
guohui
2013/09/23 21:17:57
i think this will only work for an active extensio
| |
| 417 } | 417 } |
| 418 | 418 |
| 419 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); | 419 RenderThread::Get()->RegisterExtension(SafeBuiltins::CreateV8Extension()); |
| 420 | 420 |
| 421 user_script_slave_.reset(new UserScriptSlave(&extensions_)); | 421 user_script_slave_.reset(new UserScriptSlave(&extensions_)); |
| 422 request_sender_.reset(new RequestSender(this)); | 422 request_sender_.reset(new RequestSender(this)); |
| 423 PopulateSourceMap(); | 423 PopulateSourceMap(); |
| 424 PopulateLazyBindingsMap(); | 424 PopulateLazyBindingsMap(); |
| 425 } | 425 } |
| 426 | 426 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 472 | 472 |
| 473 // Initialize host permissions for any extensions that were activated before | 473 // Initialize host permissions for any extensions that were activated before |
| 474 // WebKit was initialized. | 474 // WebKit was initialized. |
| 475 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); | 475 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); |
| 476 iter != active_extension_ids_.end(); ++iter) { | 476 iter != active_extension_ids_.end(); ++iter) { |
| 477 const Extension* extension = extensions_.GetByID(*iter); | 477 const Extension* extension = extensions_.GetByID(*iter); |
| 478 CHECK(extension); | 478 CHECK(extension); |
| 479 InitOriginPermissions(extension); | 479 InitOriginPermissions(extension); |
| 480 } | 480 } |
| 481 | 481 |
| 482 if (IsWithinPlatformApp()) | 482 EnableCustomElementWhiteList(); |
|
not at google - send to devlin
2013/09/20 16:44:34
could you guard this with the webview permission c
guohui
2013/09/23 18:34:10
But we don't have the extension ID here to check f
not at google - send to devlin
2013/09/23 20:59:12
A few lines above we loop over the extensions; you
guohui
2013/09/23 21:17:57
but we only loop over "active" extensions above, a
| |
| 483 EnableCustomElementWhiteList(); | |
| 484 | 483 |
| 485 is_webkit_initialized_ = true; | 484 is_webkit_initialized_ = true; |
| 486 } | 485 } |
| 487 | 486 |
| 488 void Dispatcher::IdleNotification() { | 487 void Dispatcher::IdleNotification() { |
| 489 if (is_extension_process_) { | 488 if (is_extension_process_) { |
| 490 // Dampen the forced delay as well if the extension stays idle for long | 489 // Dampen the forced delay as well if the extension stays idle for long |
| 491 // periods of time. | 490 // periods of time. |
| 492 int64 forced_delay_ms = std::max( | 491 int64 forced_delay_ms = std::max( |
| 493 RenderThread::Get()->GetIdleNotificationDelayInMs(), | 492 RenderThread::Get()->GetIdleNotificationDelayInMs(), |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 } | 1106 } |
| 1108 | 1107 |
| 1109 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1108 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
| 1110 is_within_platform_app && | 1109 is_within_platform_app && |
| 1111 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 1110 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
| 1112 CommandLine::ForCurrentProcess()->HasSwitch( | 1111 CommandLine::ForCurrentProcess()->HasSwitch( |
| 1113 switches::kEnableAppWindowControls)) { | 1112 switches::kEnableAppWindowControls)) { |
| 1114 module_system->Require("windowControls"); | 1113 module_system->Require("windowControls"); |
| 1115 } | 1114 } |
| 1116 | 1115 |
| 1117 // Only platform apps support the <webview> tag, because the "webView" and | 1116 // Currently only platform apps and whitelisted component extensions support |
| 1118 // "denyWebView" modules will affect the performance of DOM modifications | 1117 // the <webview> tag, because the "webView" and "denyWebView" modules will |
| 1119 // (http://crbug.com/196453). | 1118 // affect the performance of DOM modifications (http://crbug.com/196453). |
| 1120 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1119 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
| 1121 is_within_platform_app) { | |
| 1122 // Note: setting up the WebView class here, not the chrome.webview API. | 1120 // Note: setting up the WebView class here, not the chrome.webview API. |
| 1123 // The API will be automatically set up when first used. | 1121 // The API will be automatically set up when first used. |
| 1124 if (extension->HasAPIPermission(APIPermission::kWebView)) { | 1122 if (extension->HasAPIPermission(APIPermission::kWebView)) { |
| 1125 module_system->Require("webView"); | 1123 module_system->Require("webView"); |
| 1126 bool includeExperimental = | 1124 bool includeExperimental = |
| 1127 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || | 1125 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || |
| 1128 extension->id() == extension_misc::kIdentityApiUiAppId; | 1126 extension->id() == extension_misc::kIdentityApiUiAppId; |
| 1129 if (!includeExperimental) { | 1127 if (!includeExperimental) { |
| 1130 // TODO(asargent) We need a whitelist for webview experimental. | 1128 // TODO(asargent) We need a whitelist for webview experimental. |
| 1131 // crbug.com/264852 | 1129 // crbug.com/264852 |
| 1132 std::string id_hash = base::SHA1HashString(extension->id()); | 1130 std::string id_hash = base::SHA1HashString(extension->id()); |
| 1133 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), | 1131 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), |
| 1134 id_hash.length()); | 1132 id_hash.length()); |
| 1135 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || | 1133 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || |
| 1136 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || | 1134 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || |
| 1137 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || | 1135 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || |
| 1138 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") | 1136 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") |
| 1139 includeExperimental = true; | 1137 includeExperimental = true; |
| 1140 } | 1138 } |
| 1141 if (includeExperimental) | 1139 if (includeExperimental) |
| 1142 module_system->Require("webViewExperimental"); | 1140 module_system->Require("webViewExperimental"); |
| 1143 } else { | 1141 } else { |
| 1144 module_system->Require("denyWebView"); | 1142 module_system->Require("denyWebView"); |
|
not at google - send to devlin
2013/09/20 16:44:34
I particularly like that we're injecting this into
not at google - send to devlin
2013/09/20 16:45:25
Err. *don't* particularly.
guohui
2013/09/23 19:38:11
as discussed offline with Fady, the purpose of den
| |
| 1145 } | 1143 } |
| 1146 } | 1144 } |
| 1147 | 1145 |
| 1148 // Same comment as above for <adview> tag. | 1146 // Same comment as above for <adview> tag. |
| 1149 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && | 1147 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && |
| 1150 is_within_platform_app) { | 1148 is_within_platform_app) { |
| 1151 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { | 1149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { |
| 1152 if (extension->HasAPIPermission(APIPermission::kAdView)) { | 1150 if (extension->HasAPIPermission(APIPermission::kAdView)) { |
| 1153 module_system->Require("adView"); | 1151 module_system->Require("adView"); |
| 1154 } else { | 1152 } else { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 if (is_webkit_initialized_) { | 1243 if (is_webkit_initialized_) { |
| 1246 InitOriginPermissions(extension); | 1244 InitOriginPermissions(extension); |
| 1247 // DOMActivity logger for a main world controlled by an extension (as in | 1245 // DOMActivity logger for a main world controlled by an extension (as in |
| 1248 // the case of an extension background page, options page, popup etc.) | 1246 // the case of an extension background page, options page, popup etc.) |
| 1249 // gets an empty title. | 1247 // gets an empty title. |
| 1250 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId, | 1248 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId, |
| 1251 extension_id, | 1249 extension_id, |
| 1252 extension->url(), | 1250 extension->url(), |
| 1253 string16()); | 1251 string16()); |
| 1254 | 1252 |
| 1255 if (IsWithinPlatformApp()) | 1253 EnableCustomElementWhiteList(); |
|
not at google - send to devlin
2013/09/20 16:44:34
likewise
not at google - send to devlin
2013/09/23 20:59:12
... and here, we do know what the extension is.
guohui
2013/09/23 21:17:57
yes i could add webview check here, though i think
| |
| 1256 EnableCustomElementWhiteList(); | |
| 1257 } | 1254 } |
| 1258 } | 1255 } |
| 1259 | 1256 |
| 1260 void Dispatcher::InitOriginPermissions(const Extension* extension) { | 1257 void Dispatcher::InitOriginPermissions(const Extension* extension) { |
| 1261 // TODO(jstritar): We should try to remove this special case. Also, these | 1258 // TODO(jstritar): We should try to remove this special case. Also, these |
| 1262 // whitelist entries need to be updated when the kManagement permission | 1259 // whitelist entries need to be updated when the kManagement permission |
| 1263 // changes. | 1260 // changes. |
| 1264 if (extension->HasAPIPermission(APIPermission::kManagement)) { | 1261 if (extension->HasAPIPermission(APIPermission::kManagement)) { |
| 1265 WebSecurityPolicy::addOriginAccessWhitelistEntry( | 1262 WebSecurityPolicy::addOriginAccessWhitelistEntry( |
| 1266 extension->url(), | 1263 extension->url(), |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1569 RenderView* background_view = | 1566 RenderView* background_view = |
| 1570 ExtensionHelper::GetBackgroundPage(extension_id); | 1567 ExtensionHelper::GetBackgroundPage(extension_id); |
| 1571 if (background_view) { | 1568 if (background_view) { |
| 1572 background_view->Send(new ExtensionHostMsg_EventAck( | 1569 background_view->Send(new ExtensionHostMsg_EventAck( |
| 1573 background_view->GetRoutingID())); | 1570 background_view->GetRoutingID())); |
| 1574 } | 1571 } |
| 1575 } | 1572 } |
| 1576 } | 1573 } |
| 1577 | 1574 |
| 1578 } // namespace extensions | 1575 } // namespace extensions |
| OLD | NEW |