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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/management/management_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 709
710 DeveloperPrivateEnableFunction::DeveloperPrivateEnableFunction() {} 710 DeveloperPrivateEnableFunction::DeveloperPrivateEnableFunction() {}
711 711
712 bool DeveloperPrivateEnableFunction::RunImpl() { 712 bool DeveloperPrivateEnableFunction::RunImpl() {
713 scoped_ptr<Enable::Params> params(Enable::Params::Create(*args_)); 713 scoped_ptr<Enable::Params> params(Enable::Params::Create(*args_));
714 EXTENSION_FUNCTION_VALIDATE(params.get()); 714 EXTENSION_FUNCTION_VALIDATE(params.get());
715 715
716 std::string extension_id = params->item_id; 716 std::string extension_id = params->item_id;
717 717
718 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); 718 ExtensionSystem* system = ExtensionSystem::Get(GetProfile());
719 ManagementPolicy* management_policy = system->management_policy(); 719 ManagementPolicy* policy = system->management_policy();
720 ExtensionService* service = GetProfile()->GetExtensionService(); 720 ExtensionService* service = GetProfile()->GetExtensionService();
721 721
722 const Extension* extension = service->GetInstalledExtension(extension_id); 722 const Extension* extension = service->GetInstalledExtension(extension_id);
723 if (!extension || 723 if (!extension) {
724 !management_policy->UserMayModifySettings(extension, NULL)) { 724 LOG(ERROR) << "Did not find extension with id " << extension_id;
725 LOG(ERROR) << "Attempt to enable an extension that is non-usermanagable " 725 return false;
726 "was made. Extension id: " << extension_id.c_str(); 726 }
727 bool enable = params->enable;
728 if (!policy->UserMayModifySettings(extension, NULL) ||
729 (!enable && policy->MustRemainEnabled(extension, NULL)) ||
730 (enable && policy->MustRemainDisabled(extension, NULL, NULL))) {
731 LOG(ERROR) << "Attempt to change enable state denied by management policy. "
732 << "Extension id: " << extension_id.c_str();
727 return false; 733 return false;
728 } 734 }
729 735
730 if (params->enable) { 736 if (enable) {
731 ExtensionPrefs* prefs = service->extension_prefs(); 737 ExtensionPrefs* prefs = service->extension_prefs();
732 if (prefs->DidExtensionEscalatePermissions(extension_id)) { 738 if (prefs->DidExtensionEscalatePermissions(extension_id)) {
733 ShellWindowRegistry* registry = ShellWindowRegistry::Get(GetProfile()); 739 ShellWindowRegistry* registry = ShellWindowRegistry::Get(GetProfile());
734 CHECK(registry); 740 CHECK(registry);
735 ShellWindow* shell_window = registry->GetShellWindowForRenderViewHost( 741 ShellWindow* shell_window = registry->GetShellWindowForRenderViewHost(
736 render_view_host()); 742 render_view_host());
737 if (!shell_window) { 743 if (!shell_window) {
738 return false; 744 return false;
739 } 745 }
740 746
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 return true; 1353 return true;
1348 } 1354 }
1349 1355
1350 DeveloperPrivateIsProfileManagedFunction:: 1356 DeveloperPrivateIsProfileManagedFunction::
1351 ~DeveloperPrivateIsProfileManagedFunction() { 1357 ~DeveloperPrivateIsProfileManagedFunction() {
1352 } 1358 }
1353 1359
1354 } // namespace api 1360 } // namespace api
1355 1361
1356 } // namespace extensions 1362 } // namespace extensions
OLDNEW
« 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