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