diff options
author | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 20:24:28 +0000 |
---|---|---|
committer | wittman@chromium.org <wittman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-23 20:24:28 +0000 |
commit | 16c2e79f5cdc896372b0a6ccf471f2a45a206c46 (patch) | |
tree | 00a03f187c048656663a442bf21e1238df1e22da | |
parent | c89271d8ecaab76fd7bf0f9f7b9c2d3593d5bee9 (diff) | |
download | chromium_src-16c2e79f5cdc896372b0a6ccf471f2a45a206c46.zip chromium_src-16c2e79f5cdc896372b0a6ccf471f2a45a206c46.tar.gz chromium_src-16c2e79f5cdc896372b0a6ccf471f2a45a206c46.tar.bz2 |
Rename and deprecate chrome_settings_overrides.bookmarks_ui.hide_bookmark_button key
As discussed in comments on the Remove Bookmark Shortcut extension API proposal:
https://docs.google.com/a/chromium.org/document/d/1C2Mle92O9uGlji5y5gGDM5tNJ_tVE1Vb-2xgsZPNDTk
BUG=335655
Review URL: https://codereview.chromium.org/145173003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246675 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 38 insertions, 15 deletions
diff --git a/chrome/browser/ui/omnibox/location_bar.cc b/chrome/browser/ui/omnibox/location_bar.cc index 2ed2870..5f6d279 100644 --- a/chrome/browser/ui/omnibox/location_bar.cc +++ b/chrome/browser/ui/omnibox/location_bar.cc @@ -33,8 +33,7 @@ bool LocationBar::IsBookmarkStarHiddenByExtension() const { i != extension_set->end(); ++i) { const extensions::SettingsOverrides* settings_overrides = extensions::SettingsOverrides::Get(i->get()); - if (settings_overrides && - settings_overrides->RequiresHideBookmarkButtonPermission() && + if (settings_overrides && settings_overrides->RemovesBookmarkButton() && (extensions::PermissionsData::HasAPIPermission( *i, extensions::APIPermission::kBookmarkManagerPrivate) || diff --git a/chrome/common/extensions/api/manifest_types.json b/chrome/common/extensions/api/manifest_types.json index a2cc9d3b..7f8f3af 100644 --- a/chrome/common/extensions/api/manifest_types.json +++ b/chrome/common/extensions/api/manifest_types.json @@ -48,9 +48,15 @@ "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 + }, + // TODO(wittman): Remove for M36. "hide_bookmark_button": { "type": "boolean", - "description": "If <code>true</code>, the built-in bookmark button will be hidden within the user interface.", + "description": "Deprecated. Use remove_button instead.", "optional": true } } diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc index afd958e..bd97d2c 100644 --- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc +++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.cc @@ -220,9 +220,9 @@ const SettingsOverrides* SettingsOverrides::Get( extension->GetManifestData(manifest_keys::kSettingsOverride)); } -bool SettingsOverrides::RequiresHideBookmarkButtonPermission() const { - return bookmarks_ui && bookmarks_ui->hide_bookmark_button && - *bookmarks_ui->hide_bookmark_button; +bool SettingsOverrides::RemovesBookmarkButton() const { + return bookmarks_ui && bookmarks_ui->remove_button && + *bookmarks_ui->remove_button; } SettingsOverridesHandler::SettingsOverridesHandler() {} @@ -240,6 +240,13 @@ bool SettingsOverridesHandler::Parse(Extension* extension, scoped_ptr<SettingsOverrides> info(new SettingsOverrides); info->bookmarks_ui.swap(settings->bookmarks_ui); + // Support backward compatibility for deprecated key + // chrome_settings_overrides.bookmarks_ui.hide_bookmark_button. + if (info->bookmarks_ui && !info->bookmarks_ui->remove_button && + info->bookmarks_ui->hide_bookmark_button) { + info->bookmarks_ui->remove_button.reset( + new bool(*info->bookmarks_ui->hide_bookmark_button)); + } info->homepage = ParseHomepage(*settings, error); info->search_engine = ParseSearchEngine(settings.get(), error); info->startup_pages = ParseStartupPage(*settings, error); @@ -250,7 +257,7 @@ bool SettingsOverridesHandler::Parse(Extension* extension, return false; } info->manifest_permission.reset(new ManifestPermissionImpl( - info->RequiresHideBookmarkButtonPermission())); + info->RemovesBookmarkButton())); APIPermissionSet* permission_set = PermissionsData::GetInitialAPIPermissions(extension); @@ -285,13 +292,19 @@ bool SettingsOverridesHandler::Validate( const SettingsOverrides* settings_overrides = SettingsOverrides::Get(extension); - if (settings_overrides && settings_overrides->bookmarks_ui && - !FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()) { - warnings->push_back(InstallWarning( - ErrorUtils::FormatErrorMessage( - manifest_errors::kUnrecognizedManifestProperty, - manifest_keys::kHideBookmarkButton, - manifest_keys::kBookmarkUI))); + if (settings_overrides && settings_overrides->bookmarks_ui) { + if (!FeatureSwitch::enable_override_bookmarks_ui()->IsEnabled()) { + warnings->push_back(InstallWarning( + ErrorUtils::FormatErrorMessage( + manifest_errors::kUnrecognizedManifestKey, + manifest_keys::kBookmarkUI))); + } else if (settings_overrides->bookmarks_ui->hide_bookmark_button) { + warnings->push_back(InstallWarning( + ErrorUtils::FormatErrorMessage( + manifest_errors::kKeyIsDeprecatedWithReplacement, + manifest_keys::kHideBookmarkButton, + manifest_keys::kRemoveButton))); + } } return true; diff --git a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.h b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.h index 5b9273e..e63fe86 100644 --- a/chrome/common/extensions/manifest_handlers/settings_overrides_handler.h +++ b/chrome/common/extensions/manifest_handlers/settings_overrides_handler.h @@ -22,7 +22,7 @@ struct SettingsOverrides : public Extension::ManifestData { static const SettingsOverrides* Get(const Extension* extension); - bool RequiresHideBookmarkButtonPermission() const; + bool RemovesBookmarkButton() const; scoped_ptr<api::manifest_types::ChromeSettingsOverrides::Bookmarks_ui> bookmarks_ui; diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 9e59b44..eedce2b 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -109,6 +109,7 @@ const char kPlugins[] = "plugins"; const char kPluginsPath[] = "path"; const char kPluginsPublic[] = "public"; const char kPublicKey[] = "key"; +const char kRemoveButton[] = "remove_button"; const char kResources[] = "resources"; const char kRequirements[] = "requirements"; const char kRunAt[] = "run_at"; @@ -631,6 +632,8 @@ const char kInsecureContentSecurityPolicy[] = " \"'unsafe-eval'\", \"http://127.0.0.1\", \"http://localhost\", or any" " \"https://\" or \"chrome-extension://\" origin. For more information," " see http://developer.chrome.com/extensions/contentSecurityPolicy.html"; +const char kKeyIsDeprecatedWithReplacement[] = + "Key \"*\" is deprecated. Key \"*\" should be used instead."; const char kLaunchPathAndExtentAreExclusive[] = "The 'app.launch.local_path' and 'app.urls' keys cannot both be set."; const char kLaunchPathAndURLAreExclusive[] = diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index 5552b1f..9e10cdd 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -118,6 +118,7 @@ extern const char kPlugins[]; extern const char kPluginsPath[]; extern const char kPluginsPublic[]; extern const char kPublicKey[]; +extern const char kRemoveButton[]; extern const char kResources[]; extern const char kRequirements[]; extern const char kRunAt[]; @@ -426,6 +427,7 @@ extern const char kInvalidWebURL[]; extern const char kInvalidWebURLs[]; extern const char kInvalidZipHash[]; extern const char kInsecureContentSecurityPolicy[]; +extern const char kKeyIsDeprecatedWithReplacement[]; extern const char kLaunchPathAndExtentAreExclusive[]; extern const char kLaunchPathAndURLAreExclusive[]; extern const char kLaunchURLRequired[]; |