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

Unified Diff: chrome/browser/extensions/installed_loader.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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/installed_loader.cc
diff --git a/chrome/browser/extensions/installed_loader.cc b/chrome/browser/extensions/installed_loader.cc
index 75241cd0d9bd71973c689354b81a22e1bcfe35c6..e92d36d0f9c5a9f5a3f999cd4e8c1f5a14a0169a 100644
--- a/chrome/browser/extensions/installed_loader.cc
+++ b/chrome/browser/extensions/installed_loader.cc
@@ -166,11 +166,18 @@ void InstalledLoader::Load(const ExtensionInfo& info, bool write_to_prefs) {
// Chrome was not running.
const ManagementPolicy* policy = extensions::ExtensionSystem::Get(
extension_service_->profile())->management_policy();
- if (extension.get() && !policy->UserMayLoad(extension.get(), NULL)) {
- // The error message from UserMayInstall() often contains the extension ID
- // and is therefore not well suited to this UI.
- error = errors::kDisabledByPolicy;
- extension = NULL;
+ if (extension.get()) {
+ Extension::DisableReason disable_reason = Extension::DISABLE_NONE;
+ if (!policy->UserMayLoad(extension.get(), NULL)) {
+ // The error message from UserMayInstall() often contains the extension ID
+ // and is therefore not well suited to this UI.
+ error = errors::kDisabledByPolicy;
+ extension = NULL;
+ } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) &&
+ policy->MustRemainDisabled(extension, &disable_reason, NULL)) {
+ extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED);
+ extension_prefs_->AddDisableReason(extension->id(), disable_reason);
+ }
}
if (!extension.get()) {

Powered by Google App Engine
This is Rietveld 408576698