Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/renderer/extensions/dispatcher.cc

Issue 23653012: Support webview tag in component extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only inject denyWebView for platform apps Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/api/_permission_features.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
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
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 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) {
1118 // "denyWebView" modules will affect the performance of DOM modifications
1119 // (http://crbug.com/196453).
1120 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. 1117 // Note: setting up the WebView class here, not the chrome.webview API.
1123 // The API will be automatically set up when first used. 1118 // The API will be automatically set up when first used.
1124 if (extension->HasAPIPermission(APIPermission::kWebView)) { 1119 if (extension->HasAPIPermission(APIPermission::kWebView)) {
1125 module_system->Require("webView"); 1120 module_system->Require("webView");
not at google - send to devlin 2013/09/23 21:24:26 (answering all comments here) Ah I see, you want
guohui 2013/09/23 22:33:06 unfortunately it is too late here, the setup code
1126 bool includeExperimental = 1121 bool includeExperimental =
1127 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || 1122 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV ||
1128 extension->id() == extension_misc::kIdentityApiUiAppId; 1123 extension->id() == extension_misc::kIdentityApiUiAppId;
1129 if (!includeExperimental) { 1124 if (!includeExperimental) {
1130 // TODO(asargent) We need a whitelist for webview experimental. 1125 // TODO(asargent) We need a whitelist for webview experimental.
1131 // crbug.com/264852 1126 // crbug.com/264852
1132 std::string id_hash = base::SHA1HashString(extension->id()); 1127 std::string id_hash = base::SHA1HashString(extension->id());
1133 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(), 1128 std::string hexencoded_id_hash = base::HexEncode(id_hash.c_str(),
1134 id_hash.length()); 1129 id_hash.length());
1135 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || 1130 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" ||
1136 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || 1131 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" ||
1137 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || 1132 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" ||
1138 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") 1133 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3")
1139 includeExperimental = true; 1134 includeExperimental = true;
1140 } 1135 }
1141 if (includeExperimental) 1136 if (includeExperimental)
1142 module_system->Require("webViewExperimental"); 1137 module_system->Require("webViewExperimental");
1143 } else { 1138 } else if (is_within_platform_app) {
1139 // Only inject the "denyWebView" module for platform apps, since it will
1140 // affect the performance of DOM modifications (http://crbug.com/196453).
1144 module_system->Require("denyWebView"); 1141 module_system->Require("denyWebView");
1145 } 1142 }
1146 } 1143 }
1147 1144
1148 // Same comment as above for <adview> tag. 1145 // Same comment as above for <adview> tag.
1149 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT && 1146 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT &&
1150 is_within_platform_app) { 1147 is_within_platform_app) {
1151 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) { 1148 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAdview)) {
1152 if (extension->HasAPIPermission(APIPermission::kAdView)) { 1149 if (extension->HasAPIPermission(APIPermission::kAdView)) {
1153 module_system->Require("adView"); 1150 module_system->Require("adView");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 if (is_webkit_initialized_) { 1242 if (is_webkit_initialized_) {
1246 InitOriginPermissions(extension); 1243 InitOriginPermissions(extension);
1247 // DOMActivity logger for a main world controlled by an extension (as in 1244 // DOMActivity logger for a main world controlled by an extension (as in
1248 // the case of an extension background page, options page, popup etc.) 1245 // the case of an extension background page, options page, popup etc.)
1249 // gets an empty title. 1246 // gets an empty title.
1250 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId, 1247 DOMActivityLogger::AttachToWorld(DOMActivityLogger::kMainWorldId,
1251 extension_id, 1248 extension_id,
1252 extension->url(), 1249 extension->url(),
1253 string16()); 1250 string16());
1254 1251
1255 if (IsWithinPlatformApp()) 1252 EnableCustomElementWhiteList();
1256 EnableCustomElementWhiteList();
1257 } 1253 }
1258 } 1254 }
1259 1255
1260 void Dispatcher::InitOriginPermissions(const Extension* extension) { 1256 void Dispatcher::InitOriginPermissions(const Extension* extension) {
1261 // TODO(jstritar): We should try to remove this special case. Also, these 1257 // TODO(jstritar): We should try to remove this special case. Also, these
1262 // whitelist entries need to be updated when the kManagement permission 1258 // whitelist entries need to be updated when the kManagement permission
1263 // changes. 1259 // changes.
1264 if (extension->HasAPIPermission(APIPermission::kManagement)) { 1260 if (extension->HasAPIPermission(APIPermission::kManagement)) {
1265 WebSecurityPolicy::addOriginAccessWhitelistEntry( 1261 WebSecurityPolicy::addOriginAccessWhitelistEntry(
1266 extension->url(), 1262 extension->url(),
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 RenderView* background_view = 1565 RenderView* background_view =
1570 ExtensionHelper::GetBackgroundPage(extension_id); 1566 ExtensionHelper::GetBackgroundPage(extension_id);
1571 if (background_view) { 1567 if (background_view) {
1572 background_view->Send(new ExtensionHostMsg_EventAck( 1568 background_view->Send(new ExtensionHostMsg_EventAck(
1573 background_view->GetRoutingID())); 1569 background_view->GetRoutingID()));
1574 } 1570 }
1575 } 1571 }
1576 } 1572 }
1577 1573
1578 } // namespace extensions 1574 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/_permission_features.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698