Commit e59d5715 authored by wittman@chromium.org's avatar wittman@chromium.org

Move bookmarks_ui manifest key from chrome_settings_overrides to chrome_ui_overrides

Separates bookmark UI overrides from settings overrides to avoid
future conflict in requirements/goals of the two different pieces of
functionality.

Retains deprecated support under chrome_settings_overrides for
backwards compatibility. This will be removed for the M36 release.

BUG=349049
R=kalman@chromium.org, pkasting@chromium.org, vasilii@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255959 0039d316-1c4b-4281-b951-d872f2087c98
parent a6e8a0af
......@@ -20,6 +20,7 @@
#include "chrome/browser/ui/accelerator_utils.h"
#include "chrome/common/extensions/api/commands/commands_handler.h"
#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
#include "content/public/browser/notification_details.h"
......@@ -172,12 +173,16 @@ CommandService* CommandService::Get(content::BrowserContext* context) {
// static
bool CommandService::RemovesBookmarkShortcut(
const extensions::Extension* extension) {
using extensions::UIOverrides;
using extensions::SettingsOverrides;
const UIOverrides* ui_overrides = UIOverrides::Get(extension);
const SettingsOverrides* settings_overrides =
SettingsOverrides::Get(extension);
return settings_overrides &&
SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides) &&
return ((settings_overrides &&
SettingsOverrides::RemovesBookmarkShortcut(*settings_overrides)) ||
(ui_overrides &&
UIOverrides::RemovesBookmarkShortcut(*ui_overrides))) &&
(extensions::PermissionsData::HasAPIPermission(
extension,
extensions::APIPermission::kBookmarkManagerPrivate) ||
......
......@@ -241,17 +241,9 @@ IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_DontOverwriteSystemShortcuts) {
ASSERT_TRUE(result);
}
#if defined(OS_WIN)
// TODO(wittman): Enable the test once the bookmarks aren't a part of Settings
// Overrides API.
#define MAYBE_OverwriteBookmarkShortcut OverwriteBookmarkShortcut
#else
#define MAYBE_OverwriteBookmarkShortcut DISABLED_OverwriteBookmarkShortcut
#endif
// This test validates that an extension can override the Chrome bookmark
// shortcut if it has requested to do so.
IN_PROC_BROWSER_TEST_F(CommandsApiTest, MAYBE_OverwriteBookmarkShortcut) {
IN_PROC_BROWSER_TEST_F(CommandsApiTest, OverwriteBookmarkShortcut) {
ASSERT_TRUE(test_server()->Start());
ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
......
......@@ -7,7 +7,8 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
#include "extensions/browser/extension_system.h"
#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/permissions/permissions_data.h"
......@@ -20,21 +21,19 @@ LocationBar::~LocationBar() {
}
bool LocationBar::IsBookmarkStarHiddenByExtension() const {
const ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
// Extension service may be NULL during unit test execution.
if (!extension_service)
return false;
const extensions::ExtensionSet* extension_set =
extension_service->extensions();
for (extensions::ExtensionSet::const_iterator i = extension_set->begin();
i != extension_set->end(); ++i) {
const extensions::ExtensionSet& extension_set =
extensions::ExtensionRegistry::Get(profile_)->enabled_extensions();
for (extensions::ExtensionSet::const_iterator i = extension_set.begin();
i != extension_set.end(); ++i) {
using extensions::UIOverrides;
using extensions::SettingsOverrides;
const UIOverrides* ui_overrides = UIOverrides::Get(i->get());
const SettingsOverrides* settings_overrides =
SettingsOverrides::Get(i->get());
if (settings_overrides &&
SettingsOverrides::RemovesBookmarkButton(*settings_overrides) &&
if (((settings_overrides &&
SettingsOverrides::RemovesBookmarkButton(*settings_overrides)) ||
(ui_overrides &&
UIOverrides::RemovesBookmarkButton(*ui_overrides))) &&
(extensions::PermissionsData::HasAPIPermission(
*i,
extensions::APIPermission::kBookmarkManagerPrivate) ||
......
......@@ -214,6 +214,8 @@
'common/extensions/manifest_handlers/settings_overrides_handler.h',
'common/extensions/manifest_handlers/theme_handler.cc',
'common/extensions/manifest_handlers/theme_handler.h',
'common/extensions/manifest_handlers/ui_overrides_handler.cc',
'common/extensions/manifest_handlers/ui_overrides_handler.h',
'common/extensions/manifest_url_handler.cc',
'common/extensions/manifest_url_handler.h',
'common/extensions/message_bundle.cc',
......
......@@ -1809,6 +1809,7 @@
'common/extensions/manifest_handlers/exclude_matches_manifest_unittest.cc',
'common/extensions/manifest_handlers/externally_connectable_unittest.cc',
'common/extensions/manifest_handlers/settings_overrides_handler_unittest.cc',
'common/extensions/manifest_handlers/ui_overrides_handler_unittest.cc',
'common/extensions/manifest_tests/extension_manifest_test.cc',
'common/extensions/manifest_tests/extension_manifests_background_unittest.cc',
'common/extensions/manifest_tests/extension_manifests_chromepermission_unittest.cc',
......
......@@ -83,6 +83,18 @@
"channel": "dev",
"extension_types": ["extension"],
"platforms": ["win"]
}, { // TODO(wittman): remove this section for M36.
"channel": "stable",
"extension_types": ["extension"],
"whitelist": [
"CB2E4E7174A398FCB3AFA6840500C2E1D22DA7B2", // Bookmark Manager
"D5736E4B5CF695CB93A2FB57E4FDC6E5AFAB6FE2", // http://crbug.com/312900
"D57DE394F36DC1C3220E7604C575D29C51A6C495" // http://crbug.com/319444
]
}],
"chrome_ui_overrides": [{
"channel": "dev",
"extension_types": ["extension"]
}, {
"channel": "stable",
"extension_types": ["extension"],
......
......@@ -43,10 +43,12 @@
"type": "object",
"description": "Chrome settings which can be overriden by an extension.",
"properties": {
// TODO(wittman): Remove for M36.
"bookmarks_ui": {
"type": "object",
"description": "Settings to permit bookmarks user interface customization by extensions.",
"optional": true,
"nodoc": true,
"properties": {
"remove_button": {
"type": "boolean",
......@@ -55,10 +57,9 @@
},
"remove_bookmark_shortcut": {
"type": "boolean",
"description": "If <code>true</code>, the built-in \"Bookmark this page...\" shortcut key is removed and the extension is permitted to override the shortcut by binding it in the commands section of the manifest.",
"description": "If <code>true</code>, the built-in \"Bookmark this page...\" shortcut key is removed and the extension is permitted to override the shortcut by binding it in the commands section of the manifest. The corresponding menu item is also removed or overridden as well.",
"optional": true
},
// TODO(wittman): Remove for M36.
"hide_bookmark_button": {
"type": "boolean",
"description": "Deprecated. Use remove_button instead.",
......@@ -151,6 +152,30 @@
}
}
},
{
"id": "ChromeUIOverrides",
"type": "object",
"description": "Chrome user interface features which can be overriden by an extension.",
"properties": {
"bookmarks_ui": {
"type": "object",
"description": "Settings to permit bookmarks user interface customization by extensions.",
"optional": true,
"properties": {
"remove_button": {
"type": "boolean",
"description": "If <code>true</code>, the built-in bookmark button will be removed from the user interface.",
"optional": true
},
"remove_bookmark_shortcut": {
"type": "boolean",
"description": "If <code>true</code>, the built-in \"Bookmark this page...\" shortcut key is removed and the extension is permitted to override the shortcut by binding it in the commands section of the manifest.",
"optional": true
}
}
}
}
},
{
"id": "SocketHostPatterns",
"description": "<p>A single string or a list of strings representing host:port patterns.</p>",
......
......@@ -34,6 +34,7 @@
#include "chrome/common/extensions/manifest_handlers/nacl_modules_handler.h"
#include "chrome/common/extensions/manifest_handlers/settings_overrides_handler.h"
#include "chrome/common/extensions/manifest_handlers/theme_handler.h"
#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/mime_types_handler.h"
#include "extensions/common/manifest_handlers/requirements_info.h"
......@@ -77,6 +78,7 @@ void RegisterChromeManifestHandlers() {
(new SystemIndicatorHandler)->Register();
(new ThemeHandler)->Register();
(new TtsEngineManifestHandler)->Register();
(new UIOverridesHandler)->Register();
(new UpdateURLHandler)->Register();
(new UrlHandlersParser)->Register();
(new URLOverridesHandler)->Register();
......
<h1>Settings Overrides</h1>
<p>
Settings overrides are a way for extensions to override selected Chrome settings
and user interface properties.
Settings overrides are a way for extensions to override selected Chrome settings.
</p>
<h2 id="bookmarks">Bookmarks User Interface</h2>
<p>
Register the settings you want to override in the
<a href="manifest.html">extension manifest</a> like this:
</p>
<pre>{
"name": "My extension",
...
<b>
"chrome_settings_overrides" : {
"bookmarks_ui": {
"remove_button": "true",
"remove_bookmark_shortcut": "true"
}
}</b>,
...
}</pre>
<p>
<ul>
<li>
<a href="#bookmarks_ui">Bookmark button</a>: the "star" button that is used
to bookmark pages. Extensions may remove this button using the settings
overrides, and optionally replace it with a browser action or page action.
</li>
<li>
<a href="#bookmarks_ui">Bookmark shortcut</a>: the shortcut key that is
used to bookmark a page (Ctrl-D on Windows). Extensions may remove this
shortcut via the settings overrides, and optionally bind their own command
to it using the <code>commands</code> section of the manifest.
</li>
</ul>
</p>
<p class="note">
<b>Note:</b> Settings overrides for <code>bookmarks_ui</code> are only enabled
in the Chrome Dev release, and Chrome must be started with the
<code>--enable-override-bookmarks-ui=1</code> command line flag to enable
bookmarks user interface overrides.</p>
<h2 id="others">Homepage, Search Provider, and Startup Pages</h2>
<p>
Here is an example how <a href="#homepage">homepage</a>, <a
......
<h1>Settings Overrides</h1>
<h1>User Interface Overrides</h1>
<p>
Settings overrides are a way for extensions to override selected Chrome settings
and user interface properties.
User interface overrides are a way for extensions to override selected Chrome
user interface properties.
</p>
<h2 id="bookmarks">Bookmarks User Interface</h2>
<p>
Register the settings you want to override in the
Register the user interface properties you want to override in the
<a href="manifest.html">extension manifest</a> like this:
</p>
......@@ -15,7 +15,7 @@ Register the settings you want to override in the
"name": "My extension",
...
<b>
"chrome_settings_overrides" : {
"chrome_ui_overrides" : {
"bookmarks_ui": {
"remove_button": "true",
"remove_bookmark_shortcut": "true"
......@@ -33,10 +33,12 @@ Register the settings you want to override in the
</li>
<li>
<a href="#bookmarks_ui">Bookmark shortcut</a>: the shortcut key that is
used to bookmark a page (Ctrl-D on Windows). Extensions may remove this
shortcut via the settings overrides, and optionally bind their own command
to it using the <code>commands</code> section of the manifest.
<a href="#bookmarks_ui">Bookmark shortcut</a>: the shortcut key that is used
to bookmark a page (Ctrl-D on Windows). Extensions may remove this shortcut
via the settings overrides, and optionally bind their own command to it
using the <code>commands</code> section of the manifest. If the shortcut key
is removed or rebound, the corresponding menu item as also removed or
overridden respectively.
</li>
</ul>
</p>
......@@ -47,48 +49,6 @@ in the Chrome Dev release, and Chrome must be started with the
<code>--enable-override-bookmarks-ui=1</code> command line flag to enable
bookmarks user interface overrides.</p>
<h2 id="others">Homepage, Search Provider, and Startup Pages</h2>
<p>
Here is an example how <a href="#homepage">homepage</a>, <a
href="#search_provider">search provider</a> and <a href="#startup_pages">startup
pages</a> can be modified in the <a href="manifest.html">extension
manifest</a>.</p>
<pre>{
"name": "My extension",
...
"chrome_settings_overrides": {
"homepage": "http://www.homepage.com",
"search_provider": {
"name": "name.__MSG_url_domain__",
"keyword": "keyword.__MSG_url_domain__",
"search_url": "http://www.foo.__MSG_url_domain__/s?q={searchTerms}",
"favicon_url": "http://www.foo.__MSG_url_domain__/favicon.ico",
"suggest_url": "http://www.foo.__MSG_url_domain__/suggest?q={searchTerms}",
"instant_url": "http://www.foo.__MSG_url_domain__/instant?q={searchTerms}",
"image_url": "http://www.foo.__MSG_url_domain__/image?q={searchTerms}",
"search_url_post_params": "search_lang=__MSG_url_domain__",
"suggest_url_post_params": "suggest_lang=__MSG_url_domain__",
"instant_url_post_params": "instant_lang=__MSG_url_domain__",
"image_url_post_params": "image_lang=__MSG_url_domain__",
"alternate_urls": [
"http://www.moo.__MSG_url_domain__/s?q={searchTerms}",
"http://www.noo.__MSG_url_domain__/s?q={searchTerms}"
],
"encoding": "UTF-8",
"is_default": true
},
"startup_pages": ["http://www.startup.com"]
},
"default_locale": "de",
...
}</pre>
<p class="note">
<b>Note:</b> Settings overrides for <code>homepage</code>,
<code>search_provider</code>, and <code>startup_pages</code> are only enabled
in the Chrome Dev release.</p>
<h2 id="reference">Reference</h2>
<p>
An extension can override one or more of the following properties in the
......@@ -96,7 +56,7 @@ manifest:
</p>
<ul>
{{#f:apis.manifestTypes.byName.ChromeSettingsOverrides.properties}}
{{#f:apis.manifestTypes.byName.ChromeUIOverrides.properties}}
<li>
<p id="{{f.name}}"><b><code>{{f.name}}</code> ({{+partials.variable_type type:f/}})</b></p>
<p>{{f.description}}</p>
......@@ -112,4 +72,3 @@ manifest:
{{/}}
{{/}}
</ul>
......@@ -25,6 +25,15 @@
"documentation": "settings_override.html",
"example": {}
},
"chrome_ui_overrides": {
"documentation": "ui_override.html",
"example": {
"bookmarks_ui": {
"remove_button": true,
"remove_bookmark_shortcut": true
}
}
},
"chrome_url_overrides": {
"documentation": "override.html",
"example": {}
......
{{+partials.standard_extensions_article article:intros.ui_override/}}
......@@ -261,8 +261,9 @@ bool SettingsOverridesHandler::Parse(Extension* extension,
info->startup_pages = ParseStartupPage(*settings, error);
if (!info->bookmarks_ui && !info->homepage &&
!info->search_engine && info->startup_pages.empty()) {
*error =
base::ASCIIToUTF16(manifest_errors::kInvalidEmptySettingsOverrides);
*error = ErrorUtils::FormatErrorMessageUTF16(
manifest_errors::kInvalidEmptyDictionary,
manifest_keys::kSettingsOverride);
return false;
}
info->manifest_permission.reset(new ManifestPermissionImpl(
......
......@@ -8,6 +8,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -120,7 +121,9 @@ TEST_F(OverrideSettingsTest, ParseBrokenManifest) {
#if defined(OS_WIN)
EXPECT_FALSE(extension);
EXPECT_EQ(
std::string(extensions::manifest_errors::kInvalidEmptySettingsOverrides),
extensions::ErrorUtils::FormatErrorMessage(
extensions::manifest_errors::kInvalidEmptyDictionary,
extensions::manifest_keys::kSettingsOverride),
error);
#else
EXPECT_TRUE(extension);
......
......@@ -13,37 +13,30 @@ namespace extensions {
class ManifestPermission;
// SettingsOverride is associated with "chrome_settings_overrides" manifest key.
// An extension can add a search engine as default or non-default, overwrite the
// homepage and append a startup page to the list.
struct SettingsOverrides : public Extension::ManifestData {
SettingsOverrides();
virtual ~SettingsOverrides();
static const SettingsOverrides* Get(const Extension* extension);
static bool RemovesBookmarkButton(
const SettingsOverrides& settings_overrides);
static bool RemovesBookmarkShortcut(
const SettingsOverrides& settings_overrides);
scoped_ptr<api::manifest_types::ChromeSettingsOverrides::Bookmarks_ui>
bookmarks_ui;
scoped_ptr<api::manifest_types::ChromeSettingsOverrides::Search_provider>
search_engine;
scoped_ptr<GURL> homepage;
std::vector<GURL> startup_pages;
// UIOverrides is associated with "chrome_ui_overrides" manifest key, and
// represents manifest settings to override aspects of the Chrome user
// interface.
struct UIOverrides : public Extension::ManifestData {
UIOverrides();
virtual ~UIOverrides();
static const UIOverrides* Get(const Extension* extension);
static bool RemovesBookmarkButton(const UIOverrides& ui_overrides);
static bool RemovesBookmarkShortcut(const UIOverrides& ui_overrides);
scoped_ptr<api::manifest_types::ChromeUIOverrides::Bookmarks_ui> bookmarks_ui;
scoped_ptr<ManifestPermission> manifest_permission;
private:
DISALLOW_COPY_AND_ASSIGN(SettingsOverrides);
DISALLOW_COPY_AND_ASSIGN(UIOverrides);
};
class SettingsOverridesHandler : public ManifestHandler {
class UIOverridesHandler : public ManifestHandler {
public:
SettingsOverridesHandler();
virtual ~SettingsOverridesHandler();
UIOverridesHandler();
virtual ~UIOverridesHandler();
virtual bool Parse(Extension* extension, base::string16* error) OVERRIDE;
virtual bool Validate(const Extension* extension,
......@@ -59,7 +52,7 @@ class SettingsOverridesHandler : public ManifestHandler {
virtual const std::vector<std::string> Keys() const OVERRIDE;
DISALLOW_COPY_AND_ASSIGN(SettingsOverridesHandler);
DISALLOW_COPY_AND_ASSIGN(UIOverridesHandler);
};
} // namespace extensions
......
......@@ -4,10 +4,12 @@
#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
#include "base/command_line.h"
#include "base/json/json_string_value_serializer.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -17,50 +19,37 @@ namespace {
const char kManifest[] = "{"
" \"version\" : \"1.0.0.0\","
" \"name\" : \"Test\","
" \"chrome_settings_overrides\" : {"
" \"homepage\" : \"http://www.homepage.com\","
" \"search_provider\" : {"
" \"name\" : \"first\","
" \"keyword\" : \"firstkey\","
" \"search_url\" : \"http://www.foo.com/s?q={searchTerms}\","
" \"favicon_url\" : \"http://www.foo.com/favicon.ico\","
" \"suggest_url\" : \"http://www.foo.com/s?q={searchTerms}\","
" \"encoding\" : \"UTF-8\","
" \"is_default\" : true"
" },"
" \"startup_pages\" : [\"http://www.startup.com\"]"
" \"chrome_ui_overrides\" : {"
" \"bookmarks_ui\" : {"
" \"remove_button\" : true,"
" \"remove_bookmark_shortcut\" : true"
" }"
" }"
"}";
const char kBrokenManifest[] = "{"
" \"version\" : \"1.0.0.0\","
" \"name\" : \"Test\","
" \"chrome_settings_overrides\" : {"
" \"homepage\" : \"{invalid}\","
" \"search_provider\" : {"
" \"name\" : \"first\","
" \"keyword\" : \"firstkey\","
" \"search_url\" : \"{invalid}/s?q={searchTerms}\","
" \"favicon_url\" : \"{invalid}/favicon.ico\","
" \"encoding\" : \"UTF-8\","
" \"is_default\" : true"
" },"
" \"startup_pages\" : [\"{invalid}\"]"
" \"chrome_ui_overrides\" : {"
" }"
"}";
using extensions::api::manifest_types::ChromeSettingsOverrides;
using extensions::api::manifest_types::ChromeUIOverrides;
using extensions::Extension;
using extensions::Manifest;
using extensions::SettingsOverrides;
using extensions::UIOverrides;
namespace manifest_keys = extensions::manifest_keys;
class OverrideSettingsTest : public testing::Test {
class UIOverrideTest : public testing::Test {
};
TEST_F(OverrideSettingsTest, ParseManifest) {
TEST_F(UIOverrideTest, ParseManifest) {
extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
// This functionality requires a feature flag.
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
"--enable-override-bookmarks-ui",
"1");
std::string manifest(kManifest);
JSONStringValueSerializer json(&manifest);
std::string error;
......@@ -73,38 +62,23 @@ TEST_F(OverrideSettingsTest, ParseManifest) {
*static_cast<base::DictionaryValue*>(root.get()),
Extension::NO_FLAGS,
&error);
ASSERT_TRUE(extension);
#if defined(OS_WIN)
ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
ASSERT_TRUE(extension) << error;
ASSERT_TRUE(extension->manifest()->HasPath(manifest_keys::kUIOverride));
SettingsOverrides* settings_override = static_cast<SettingsOverrides*>(
extension->GetManifestData(manifest_keys::kSettingsOverride));
ASSERT_TRUE(settings_override);
ASSERT_TRUE(settings_override->search_engine);
EXPECT_TRUE(settings_override->search_engine->is_default);
const ChromeSettingsOverrides::Search_provider* search_engine =
settings_override->search_engine.get();
EXPECT_EQ("first", search_engine->name);
EXPECT_EQ("firstkey", search_engine->keyword);
EXPECT_EQ("http://www.foo.com/s?q={searchTerms}", search_engine->search_url);
EXPECT_EQ("http://www.foo.com/favicon.ico", search_engine->favicon_url);
EXPECT_EQ("http://www.foo.com/s?q={searchTerms}",
*search_engine->suggest_url);
EXPECT_EQ("UTF-8", search_engine->encoding);
EXPECT_EQ(std::vector<GURL>(1, GURL("http://www.startup.com")),
settings_override->startup_pages);
ASSERT_TRUE(settings_override->homepage);
EXPECT_EQ(GURL("http://www.homepage.com"), *settings_override->homepage);
#else
EXPECT_FALSE(
extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
#endif
UIOverrides* ui_override = static_cast<UIOverrides*>(
extension->GetManifestData(manifest_keys::kUIOverride));
ASSERT_TRUE(ui_override);
ASSERT_TRUE(ui_override->bookmarks_ui);
EXPECT_TRUE(ui_override->bookmarks_ui->remove_button);
EXPECT_TRUE(ui_override->bookmarks_ui->remove_bookmark_shortcut);
}
TEST_F(OverrideSettingsTest, ParseBrokenManifest) {
TEST_F(UIOverrideTest, ParseBrokenManifest) {
extensions::ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_DEV);
// This functionality requires a feature flag.
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
"--enable-override-bookmarks-ui",
"1");
std::string manifest(kBrokenManifest);
JSONStringValueSerializer json(&manifest);
std::string error;
......@@ -117,16 +91,12 @@ TEST_F(OverrideSettingsTest, ParseBrokenManifest) {
*static_cast<base::DictionaryValue*>(root.get()),
Extension::NO_FLAGS,
&error);
#if defined(OS_WIN)
EXPECT_FALSE(extension);
EXPECT_EQ(
std::string(extensions::manifest_errors::kInvalidEmptySettingsOverrides),
extensions::ErrorUtils::FormatErrorMessage(
extensions::manifest_errors::kInvalidEmptyDictionary,
extensions::manifest_keys::kUIOverride),
error);
#else
EXPECT_TRUE(extension);
EXPECT_FALSE(
extension->manifest()->HasPath(manifest_keys::kSettingsOverride));
#endif
}
} // namespace
......@@ -6,7 +6,7 @@
"scripts": ["background.js"]
},
"permissions": ["activeTab"],
"chrome_settings_overrides": {
"chrome_ui_overrides": {
"bookmarks_ui": {
"remove_bookmark_shortcut": true
}
......
......@@ -17,7 +17,7 @@ const char kBackgroundPageLegacy[] = "background_page";
const char kBackgroundPersistent[] = "background.persistent";
const char kBackgroundScripts[] = "background.scripts";
const char kBluetooth[] = "bluetooth";
const char kBookmarkUI[] = "chrome_settings_overrides.bookmarks_ui";
const char kBookmarkUI[] = "chrome_ui_overrides.bookmarks_ui";
const char kBrowserAction[] = "browser_action";
const char kChromeURLOverrides[] = "chrome_url_overrides";
const char kCommands[] = "commands";
......@@ -157,6 +157,7 @@ const char kTtsVoicesLang[] = "lang";
const char kTtsVoicesRemote[] = "remote";
const char kTtsVoicesVoiceName[] = "voice_name";
const char kType[] = "type";
const char kUIOverride[] = "chrome_ui_overrides";
const char kUpdateURL[] = "update_url";
const char kUrlHandlers[] = "url_handlers";
const char kUrlHandlerTitle[] = "title";
......@@ -313,6 +314,7 @@ const char kInvalidDisplayInLauncher[] =
"Invalid value for 'display_in_launcher'.";
const char kInvalidDisplayInNewTabPage[] =
"Invalid value for 'display_in_new_tab_page'.";
const char kInvalidEmptyDictionary[] = "Empty dictionary for '*'.";
const char kInvalidExcludeMatch[] =
"Invalid value for 'content_scripts[*].exclude_matches[*]': *";
const char kInvalidExcludeMatches[] =
......@@ -558,8 +560,6 @@ const char kInvalidSearchEngineURL[] =
"Invalid URL [*] for 'chrome_settings_overrides.search_provider'.";
const char kInvalidServiceWorkerScript[] =
"Invalid value for 'service_worker.script'.";
const char kInvalidEmptySettingsOverrides[] =
"Empty dictionary for 'chrome_settings_overrides'.";
const char kInvalidShortName[] =
"Invalid value for 'short_name'.";
const char kInvalidSignature[] =
......
......@@ -165,6 +165,7 @@ extern const char kTtsVoicesLang[];
extern const char kTtsVoicesRemote[];
extern const char kTtsVoicesVoiceName[];
extern const char kType[];
extern const char kUIOverride[];
extern const char kUpdateURL[];
extern const char kUrlHandlers[];
extern const char kUrlHandlerTitle[];
......@@ -276,6 +277,7 @@ extern const char kInvalidDescription[];
extern const char kInvalidDevToolsPage[];
extern const char kInvalidDisplayInLauncher[];
extern const char kInvalidDisplayInNewTabPage[];
extern const char kInvalidEmptyDictionary[];
extern const char kInvalidExcludeMatch[];
extern const char kInvalidExcludeMatches[];
extern const char kInvalidExport[];
......@@ -395,7 +397,6 @@ extern const char kInvalidSandboxedPagesCSP[];
extern const char kInvalidScriptBadge[];
extern const char kInvalidSearchEngineURL[];
extern const char kInvalidServiceWorkerScript[];
extern const char kInvalidEmptySettingsOverrides[];
extern const char kInvalidShortName[];
extern const char kInvalidSignature[];
extern const char kInvalidSpellcheck[];
......
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