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

Unified Diff: chrome/browser/extensions/extension_context_menu_model.cc

Issue 1140763003: [Extensions] Show enterprise policy icon in the context menu when unremovable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_context_menu_model.cc
diff --git a/chrome/browser/extensions/extension_context_menu_model.cc b/chrome/browser/extensions/extension_context_menu_model.cc
index 492f0289e593af770f8ea7cffb3aa117ad9a4678..281a7fe6d96474e2ea097f567ee04345e6a1712e 100644
--- a/chrome/browser/extensions/extension_context_menu_model.cc
+++ b/chrome/browser/extensions/extension_context_menu_model.cc
@@ -306,8 +306,22 @@ void ExtensionContextMenuModel::InitMenu(const Extension* extension,
if (!is_component_ || extensions::OptionsPageInfo::HasOptionsPage(extension))
AddItemWithStringId(CONFIGURE, IDS_EXTENSIONS_OPTIONS_MENU_ITEM);
- if (!is_component_)
- AddItem(UNINSTALL, l10n_util::GetStringUTF16(IDS_EXTENSIONS_UNINSTALL));
+ if (!is_component_) {
+ extensions::ManagementPolicy* policy =
+ extensions::ExtensionSystem::Get(profile_)->management_policy();
+ bool is_required_by_policy =
+ !policy->UserMayModifySettings(extension, nullptr) ||
+ policy->MustRemainInstalled(extension, nullptr);
+ int message_id = is_required_by_policy ?
+ IDS_EXTENSIONS_INSTALLED_BY_ADMIN : IDS_EXTENSIONS_UNINSTALL;
+ AddItem(UNINSTALL, l10n_util::GetStringUTF16(message_id));
+ if (is_required_by_policy) {
+ int uninstall_index = GetIndexOfCommandId(UNINSTALL);
+ SetIcon(uninstall_index,
+ ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_CONTROLLED_SETTING_MANDATORY));
+ }
+ }
// Add a toggle visibility (show/hide) if the extension icon is shown on the
// toolbar.
« no previous file with comments | « chrome/app/generated_resources.grd ('k') | chrome/browser/extensions/extension_context_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698