Commit 5dec37c6 authored by treib's avatar treib Committed by Commit bot

Policy: check MustRemainInstalled in addition to UserMayModifySettings before offering uninstall

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

Cr-Commit-Position: refs/heads/master@{#314784}
parent b630c8ec
...@@ -156,8 +156,10 @@ bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const { ...@@ -156,8 +156,10 @@ bool ExtensionContextMenuModel::IsCommandIdEnabled(int command_id) const {
extension_action_->HasPopup(SessionTabHelper::IdForTab(web_contents)); extension_action_->HasPopup(SessionTabHelper::IdForTab(web_contents));
} else if (command_id == UNINSTALL) { } else if (command_id == UNINSTALL) {
// Some extension types can not be uninstalled. // Some extension types can not be uninstalled.
return extensions::ExtensionSystem::Get( extensions::ManagementPolicy* policy =
profile_)->management_policy()->UserMayModifySettings(extension, NULL); extensions::ExtensionSystem::Get(profile_)->management_policy();
return policy->UserMayModifySettings(extension, nullptr) &&
!policy->MustRemainInstalled(extension, nullptr);
} }
return true; return true;
} }
......
...@@ -184,7 +184,8 @@ void AppInfoFooterPanel::UninstallApp() { ...@@ -184,7 +184,8 @@ void AppInfoFooterPanel::UninstallApp() {
} }
bool AppInfoFooterPanel::CanUninstallApp() const { bool AppInfoFooterPanel::CanUninstallApp() const {
return extensions::ExtensionSystem::Get(profile_) extensions::ManagementPolicy* policy =
->management_policy() extensions::ExtensionSystem::Get(profile_)->management_policy();
->UserMayModifySettings(app_, NULL); return policy->UserMayModifySettings(app_, nullptr) &&
!policy->MustRemainInstalled(app_, nullptr);
} }
...@@ -514,9 +514,10 @@ bool ManagementUninstallFunctionBase::Uninstall( ...@@ -514,9 +514,10 @@ bool ManagementUninstallFunctionBase::Uninstall(
return false; return false;
} }
if (!ExtensionSystem::Get(browser_context()) ManagementPolicy* policy =
->management_policy() ExtensionSystem::Get(browser_context())->management_policy();
->UserMayModifySettings(target_extension, NULL)) { if (!policy->UserMayModifySettings(target_extension, nullptr) ||
policy->MustRemainInstalled(target_extension, nullptr)) {
error_ = ErrorUtils::FormatErrorMessage(keys::kUserCantModifyError, error_ = ErrorUtils::FormatErrorMessage(keys::kUserCantModifyError,
extension_id_); extension_id_);
return false; return false;
......
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