Commit 149f67d7 authored by Kelvin Jiang's avatar Kelvin Jiang Committed by Commit Bot

[Extensions] Restrict chrome_style to manifest v2

chrome_style applies styling for an extension's embedded options page.
The styling is old and inconsistent with the modern WebUI appearance.
Since some extensions with many users are still using this flag, support
for it will be phased out in manifest v3

Bug: 973157
Change-Id: I0ae424227bd3a0eda34dc56a5631d9d1a6461464
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2298726
Commit-Queue: Kelvin Jiang <kelvinjiang@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789729}
parent d193a190
......@@ -138,4 +138,15 @@ TEST_F(OptionsPageManifestTest, OptionsPageChromeStyleAndOpenInTab) {
}
}
// Tests that the chrome_style flag is not supported in manifest v3 and will
// trigger an error when specified.
TEST_F(OptionsPageManifestTest, OptionsPageChromeStyleManifestV3) {
LoadAndExpectError(
"options_ui_chrome_style_manifest_v3_false.json",
extensions::manifest_errors::kChromeStyleInvalidForManifestV3);
LoadAndExpectError(
"options_ui_chrome_style_manifest_v3_true.json",
extensions::manifest_errors::kChromeStyleInvalidForManifestV3);
}
} // namespace
{
"name": "options_ui with chrome_style in manifest v3",
"description": "Tests that specifying chrome_style=false is invalid for manifest v3",
"version": "1",
"manifest_version": 3,
"options_ui": {
"page": "options.html",
"chrome_style": false
}
}
{
"name": "options_ui with chrome_style in manifest v3",
"description": "Tests that specifying chrome_style=true is invalid for manifest v3",
"version": "1",
"manifest_version": 3,
"options_ui": {
"page": "options.html",
"chrome_style": true
}
}
......@@ -91,7 +91,7 @@
"type": "string"
},
"chrome_style": {
"description": "If <code>true</code>, a Chrome user agent stylesheet will be applied to your options page. The default value is <code>false</code>, but we recommend you enable it for a consistent UI with Chrome.",
"description": "If <code>true</code>, a Chrome user agent stylesheet will be applied to your options page. The default value is <code>false</code>. We do not recommend you enable it as it no longer results in a consistent UI with Chrome. This option will be removed in Manifest V3.",
"optional": true,
"type": "boolean"
},
......
......@@ -312,6 +312,8 @@ const char kCannotScriptGallery[] =
const char kCannotScriptNtp[] = "The New Tab Page cannot be scripted.";
const char kCannotScriptSigninPage[] =
"The sign-in page cannot be scripted.";
const char kChromeStyleInvalidForManifestV3[] =
"The chrome_style option cannot be used with manifest version 3.";
const char kChromeVersionTooLow[] =
"This extension requires * version * or greater.";
const char kDeclarativeNetRequestPermissionNeeded[] =
......
......@@ -283,6 +283,7 @@ extern const char kCannotScriptGallery[];
extern const char kCannotScriptNtp[];
extern const char kCannotScriptSigninPage[];
extern const char kCannotUninstallManagedExtension[];
extern const char kChromeStyleInvalidForManifestV3[];
extern const char kChromeVersionTooLow[];
extern const char kDeclarativeNetRequestPermissionNeeded[];
extern const char kDefaultStateShouldNotBeSet[];
......
......@@ -144,8 +144,14 @@ std::unique_ptr<OptionsPageInfo> OptionsPageInfo::Create(
install_warnings->push_back(
InstallWarning(base::UTF16ToASCII(options_parse_error)));
}
if (options_ui->chrome_style.get())
chrome_style = *options_ui->chrome_style;
if (options_ui->chrome_style.get()) {
if (extension->manifest_version() < 3)
chrome_style = *options_ui->chrome_style;
else {
*error = base::ASCIIToUTF16(errors::kChromeStyleInvalidForManifestV3);
return nullptr;
}
}
open_in_tab = false;
if (options_ui->open_in_tab.get())
open_in_tab = *options_ui->open_in_tab;
......
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