Commit bb30da9b authored by fsamuel's avatar fsamuel Committed by Commit bot

Model <webview> and <appview> script injection after <extensionoptions>

BUG=407833

Review URL: https://codereview.chromium.org/512543002

Cr-Commit-Position: refs/heads/master@{#292224}
parent 473591b5
...@@ -1477,7 +1477,7 @@ const Experiment kExperiments[] = { ...@@ -1477,7 +1477,7 @@ const Experiment kExperiments[] = {
"enable-app-view", "enable-app-view",
IDS_FLAGS_ENABLE_APP_VIEW_NAME, IDS_FLAGS_ENABLE_APP_VIEW_NAME,
IDS_FLAGS_ENABLE_APP_VIEW_DESCRIPTION, IDS_FLAGS_ENABLE_APP_VIEW_DESCRIPTION,
kOsAll, kOsDesktop,
SINGLE_VALUE_TYPE(extensions::switches::kEnableAppView) SINGLE_VALUE_TYPE(extensions::switches::kEnableAppView)
}, },
{ {
......
...@@ -804,6 +804,24 @@ ...@@ -804,6 +804,24 @@
// given the blessed_extension denomination. Confusing. // given the blessed_extension denomination. Confusing.
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
"webViewExperimentalInternal": [{
"internal": true,
"channel": "dev",
"contexts": ["blessed_extension"],
"dependencies": ["permission:webview"]
},
{
"internal": true,
"channel": "stable",
"contexts": ["blessed_extension"],
"dependencies": ["permission:webview"],
"whitelist": [
"8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578",
"E703483CEF33DEC18B4B6DD84B5C776FB9182BDB",
"1A26E32DE447A17CBE5E9750CDBA78F58539B39C",
"59048028102D7B4C681DBC7BC6CD980C3DC66DA3"
]
}],
"webViewInternal": [{ "webViewInternal": [{
"internal": true, "internal": true,
"dependencies": ["permission:webview"], "dependencies": ["permission:webview"],
......
...@@ -272,51 +272,21 @@ void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( ...@@ -272,51 +272,21 @@ void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules(
module_system->Require("windowControls"); module_system->Require("windowControls");
} }
const extensions::Extension* extension = context->extension();
// We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform
// apps. An ext/app runs in a blessed extension context, if it is the active
// extension in the current process, in other words, if it is loaded in a top
// frame. To support webview in a non-frame extension, we have to allow
// unblessed extension context as well.
// Note: setting up the WebView class here, not the chrome.webview API. // Note: setting up the WebView class here, not the chrome.webview API.
// The API will be automatically set up when first used. // The API will be automatically set up when first used.
if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || if (context->GetAvailability("webViewInternal").is_available()) {
context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { module_system->Require("webView");
// TODO(fsamuel): Use context->GetAvailability("webViewInternal"). if (context->GetAvailability("webViewExperimentalInternal").is_available())
if (extension->permissions_data()->HasAPIPermission( module_system->Require("webViewExperimental");
extensions::APIPermission::kWebView)) { } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) {
module_system->Require("webView"); module_system->Require("denyWebView");
if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) {
module_system->Require("webViewExperimental");
} else {
// TODO(asargent) We need a whitelist for webview experimental.
// crbug.com/264852
std::string id_hash = base::SHA1HashString(extension->id());
std::string hexencoded_id_hash =
base::HexEncode(id_hash.c_str(), id_hash.length());
if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" ||
hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" ||
hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" ||
hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") {
module_system->Require("webViewExperimental");
}
}
} else {
module_system->Require("denyWebView");
}
} }
if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { if (extensions::FeatureSwitch::app_view()->IsEnabled() &&
// TODO(fsamuel): Use context->GetAvailability("appViewInternal"). context->GetAvailability("appViewEmbedderInternal").is_available()) {
if (CommandLine::ForCurrentProcess()->HasSwitch( module_system->Require("appView");
extensions::switches::kEnableAppView) && } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) {
extension->permissions_data()->HasAPIPermission( module_system->Require("denyAppView");
extensions::APIPermission::kAppView)) {
module_system->Require("appView");
} else {
module_system->Require("denyAppView");
}
} }
if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() &&
......
...@@ -43,7 +43,9 @@ class CommonSwitches { ...@@ -43,7 +43,9 @@ class CommonSwitches {
FeatureSwitch::DEFAULT_DISABLED), FeatureSwitch::DEFAULT_DISABLED),
embedded_extension_options( embedded_extension_options(
switches::kEmbeddedExtensionOptions, switches::kEmbeddedExtensionOptions,
FeatureSwitch::DEFAULT_DISABLED) {} FeatureSwitch::DEFAULT_DISABLED),
app_view(switches::kAppView,
FeatureSwitch::DEFAULT_DISABLED) {}
// Enables extensions to be easily installed from sites other than the web // Enables extensions to be easily installed from sites other than the web
// store. // store.
...@@ -60,6 +62,7 @@ class CommonSwitches { ...@@ -60,6 +62,7 @@ class CommonSwitches {
FeatureSwitch extension_action_redesign; FeatureSwitch extension_action_redesign;
FeatureSwitch scripts_require_action; FeatureSwitch scripts_require_action;
FeatureSwitch embedded_extension_options; FeatureSwitch embedded_extension_options;
FeatureSwitch app_view;
}; };
base::LazyInstance<CommonSwitches> g_common_switches = base::LazyInstance<CommonSwitches> g_common_switches =
...@@ -91,6 +94,9 @@ FeatureSwitch* FeatureSwitch::scripts_require_action() { ...@@ -91,6 +94,9 @@ FeatureSwitch* FeatureSwitch::scripts_require_action() {
FeatureSwitch* FeatureSwitch::embedded_extension_options() { FeatureSwitch* FeatureSwitch::embedded_extension_options() {
return &g_common_switches.Get().embedded_extension_options; return &g_common_switches.Get().embedded_extension_options;
} }
FeatureSwitch* FeatureSwitch::app_view() {
return &g_common_switches.Get().app_view;
}
FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature,
bool override_value) bool override_value)
......
...@@ -27,6 +27,7 @@ class FeatureSwitch { ...@@ -27,6 +27,7 @@ class FeatureSwitch {
static FeatureSwitch* extension_action_redesign(); static FeatureSwitch* extension_action_redesign();
static FeatureSwitch* scripts_require_action(); static FeatureSwitch* scripts_require_action();
static FeatureSwitch* embedded_extension_options(); static FeatureSwitch* embedded_extension_options();
static FeatureSwitch* app_view();
enum DefaultValue { enum DefaultValue {
DEFAULT_ENABLED, DEFAULT_ENABLED,
......
...@@ -16,6 +16,9 @@ const char kAllowHTTPBackgroundPage[] = "allow-http-background-page"; ...@@ -16,6 +16,9 @@ const char kAllowHTTPBackgroundPage[] = "allow-http-background-page";
const char kAllowLegacyExtensionManifests[] = const char kAllowLegacyExtensionManifests[] =
"allow-legacy-extension-manifests"; "allow-legacy-extension-manifests";
// Enables the <appview> tag in platform apps.
const char kAppView[] = "app-view";
// Enables extension options to be embedded in chrome://extensions rather than // Enables extension options to be embedded in chrome://extensions rather than
// a new tab. // a new tab.
const char kEmbeddedExtensionOptions[] = "embedded-extension-options"; const char kEmbeddedExtensionOptions[] = "embedded-extension-options";
...@@ -25,7 +28,8 @@ const char kEmbeddedExtensionOptions[] = "embedded-extension-options"; ...@@ -25,7 +28,8 @@ const char kEmbeddedExtensionOptions[] = "embedded-extension-options";
// insignificant for apps that load most of their resources asynchronously. // insignificant for apps that load most of their resources asynchronously.
const char kEnableAppsShowOnFirstPaint[] = "enable-apps-show-on-first-paint"; const char kEnableAppsShowOnFirstPaint[] = "enable-apps-show-on-first-paint";
// Enables the <appview> tag in platform apps. // Hack so that feature switch can work with about_flags. See
// kEnableScriptsRequireAction.
const char kEnableAppView[] = "enable-app-view"; const char kEnableAppView[] = "enable-app-view";
// Hack so that feature switch can work with about_flags. See // Hack so that feature switch can work with about_flags. See
......
...@@ -13,6 +13,7 @@ namespace switches { ...@@ -13,6 +13,7 @@ namespace switches {
extern const char kAllowHTTPBackgroundPage[]; extern const char kAllowHTTPBackgroundPage[];
extern const char kAllowLegacyExtensionManifests[]; extern const char kAllowLegacyExtensionManifests[];
extern const char kAppView[];
extern const char kEmbeddedExtensionOptions[]; extern const char kEmbeddedExtensionOptions[];
extern const char kEnableAppsShowOnFirstPaint[]; extern const char kEnableAppsShowOnFirstPaint[];
extern const char kEnableAppView[]; extern const char kEnableAppView[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment