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

Unified Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 54903011: Add management policy function allowing extensions to be disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: responded to review comments Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/developer_private/developer_private_api.cc
diff --git a/chrome/browser/extensions/api/developer_private/developer_private_api.cc b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
index 55b0709e97ca93ca652320d97743018bcfc9f1ec..9dc578a6fcd222e802e176079687e0e7e541d6bf 100644
--- a/chrome/browser/extensions/api/developer_private/developer_private_api.cc
+++ b/chrome/browser/extensions/api/developer_private/developer_private_api.cc
@@ -716,18 +716,24 @@ bool DeveloperPrivateEnableFunction::RunImpl() {
std::string extension_id = params->item_id;
ExtensionSystem* system = ExtensionSystem::Get(GetProfile());
- ManagementPolicy* management_policy = system->management_policy();
+ ManagementPolicy* policy = system->management_policy();
ExtensionService* service = GetProfile()->GetExtensionService();
const Extension* extension = service->GetInstalledExtension(extension_id);
- if (!extension ||
- !management_policy->UserMayModifySettings(extension, NULL)) {
- LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable "
- "was made. Extension id: " << extension_id.c_str();
+ if (!extension) {
+ LOG(ERROR) << "Did not find extension with id " << extension_id;
+ return false;
+ }
+ bool enable = params->enable;
+ if (!policy->UserMayModifySettings(extension, NULL) ||
+ (!enable && policy->MustRemainEnabled(extension, NULL)) ||
+ (enable && policy->MustRemainDisabled(extension, NULL, NULL))) {
+ LOG(ERROR) << "Attempt to change enable state denied by management policy. "
+ << "Extension id: " << extension_id.c_str();
return false;
}
- if (params->enable) {
+ if (enable) {
ExtensionPrefs* prefs = service->extension_prefs();
if (prefs->DidExtensionEscalatePermissions(extension_id)) {
ShellWindowRegistry* registry = ShellWindowRegistry::Get(GetProfile());
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698