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

Side by Side Diff: chrome/browser/extensions/api/management/management_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: 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
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/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 const Extension* extension = service()->GetInstalledExtension(extension_id_); 465 const Extension* extension = service()->GetInstalledExtension(extension_id_);
466 if (!extension || extension->ShouldNotBeVisible()) { 466 if (!extension || extension->ShouldNotBeVisible()) {
467 error_ = ErrorUtils::FormatErrorMessage( 467 error_ = ErrorUtils::FormatErrorMessage(
468 keys::kNoExtensionError, extension_id_); 468 keys::kNoExtensionError, extension_id_);
469 return false; 469 return false;
470 } 470 }
471 471
472 const ManagementPolicy* policy = 472 const ManagementPolicy* policy =
473 ExtensionSystem::Get(GetProfile())->management_policy(); 473 ExtensionSystem::Get(GetProfile())->management_policy();
474 if (!policy->UserMayModifySettings(extension, NULL)) { 474 if (!policy->UserMayModifySettings(extension, NULL) ||
475 (!params->enabled && policy->MustRemainEnabled(extension, NULL)) ||
476 (params->enabled && policy->MustRemainDisabled(extension, NULL, NULL))) {
475 error_ = ErrorUtils::FormatErrorMessage( 477 error_ = ErrorUtils::FormatErrorMessage(
476 keys::kUserCantModifyError, extension_id_); 478 keys::kUserCantModifyError, extension_id_);
477 return false; 479 return false;
478 } 480 }
479 481
480 bool currently_enabled = service()->IsExtensionEnabled(extension_id_); 482 bool currently_enabled = service()->IsExtensionEnabled(extension_id_);
481 483
482 if (!currently_enabled && params->enabled) { 484 if (!currently_enabled && params->enabled) {
483 ExtensionPrefs* prefs = service()->extension_prefs(); 485 ExtensionPrefs* prefs = service()->extension_prefs();
484 if (prefs->DidExtensionEscalatePermissions(extension_id_)) { 486 if (prefs->DidExtensionEscalatePermissions(extension_id_)) {
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { 725 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() {
724 return &g_factory.Get(); 726 return &g_factory.Get();
725 } 727 }
726 728
727 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { 729 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) {
728 management_event_router_.reset(new ManagementEventRouter(profile_)); 730 management_event_router_.reset(new ManagementEventRouter(profile_));
729 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 731 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this);
730 } 732 }
731 733
732 } // namespace extensions 734 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698