Chromium Code Reviews| Index: chrome/browser/extensions/extension_service.cc |
| diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc |
| index a57a247f6239d734e458d9070ab9251ab6c450dd..1540cec961c079b1f66b87bddd17ef3445a0e56b 100644 |
| --- a/chrome/browser/extensions/extension_service.cc |
| +++ b/chrome/browser/extensions/extension_service.cc |
| @@ -721,6 +721,8 @@ void ExtensionService::ReloadExtension(const std::string& extension_id) { |
| path = current_extension->path(); |
| DisableExtension(extension_id); |
| + extension_prefs_->SetDisableReason(extension_id, |
| + ExtensionPrefs::DISABLE_RELOAD); |
| disabled_extension_paths_[extension_id] = path; |
| } else { |
| path = unloaded_extension_paths_[extension_id]; |
| @@ -898,6 +900,8 @@ void ExtensionService::EnableExtension(const std::string& extension_id) { |
| return; |
| extension_prefs_->SetExtensionState(extension_id, Extension::ENABLED); |
| + extension_prefs_->SetDisableReason(extension_id, |
| + ExtensionPrefs::DISABLE_UNKNOWN); |
| const Extension* extension = |
| GetExtensionByIdInternal(extension_id, false, true, false); |
| @@ -932,6 +936,8 @@ void ExtensionService::DisableExtension(const std::string& extension_id) { |
| return; |
| extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); |
| + extension_prefs_->SetDisableReason(extension_id, |
| + ExtensionPrefs::DISABLE_USER_ACTION); |
|
Aaron Boodman
2012/04/09 20:30:48
I am not sure this is always a good assumption. Co
Yoyo Zhou
2012/04/10 01:57:36
No, it's probably not, since it's used in RELOAD f
|
| extension = GetExtensionByIdInternal(extension_id, true, false, true); |
| if (!extension) |
| @@ -2035,12 +2041,13 @@ bool ExtensionService::AddExtension(const Extension* extension) { |
| if (disabled) { |
| disabled_extensions_.Insert(scoped_extension); |
| SyncExtensionChangeIfNeeded(*extension); |
| + content::NotificationService::current()->Notify( |
| + chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| + content::Source<Profile>(profile_), |
| + content::Details<const Extension>(extension)); |
| - if (extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { |
| - content::NotificationService::current()->Notify( |
| - chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| - content::Source<Profile>(profile_), |
| - content::Details<const Extension>(extension)); |
| + if (extension_prefs_->GetDisableReason(extension->id()) == |
| + ExtensionPrefs::DISABLE_PERMISSIONS_INCREASE) { |
| extensions::AddExtensionDisabledError(this, extension); |
| } |
| // Although the extension is disabled, we technically did succeed in adding |
| @@ -2115,6 +2122,9 @@ void ExtensionService::InitializePermissions(const Extension* extension) { |
| true, true, false); |
| bool is_extension_upgrade = old != NULL; |
| bool is_privilege_increase = false; |
| + bool previously_disabled = false; |
| + ExtensionPrefs::DisableReason disable_reason = |
| + extension_prefs_->GetDisableReason(extension->id()); |
| // We only need to compare the granted permissions to the current permissions |
| // if the extension is not allowed to silently increase its permissions. |
| @@ -2147,6 +2157,24 @@ void ExtensionService::InitializePermissions(const Extension* extension) { |
| SetBeingUpgraded(extension, true); |
| } |
| + // If the extension was already disabled, suppress any alerts for becoming |
| + // disabled on permissions increase. |
| + previously_disabled = extension_prefs_->IsExtensionDisabled(old->id()); |
| + if (previously_disabled) { |
| + ExtensionPrefs::DisableReason reason = extension_prefs_->GetDisableReason( |
| + old->id()); |
| + if (reason == ExtensionPrefs::DISABLE_UNKNOWN) { |
| + // Initialize the reason for legacy disabled extensions from whether the |
| + // extension already exceeded granted permissions. |
| + if (extension_prefs_->DidExtensionEscalatePermissions(old->id())) |
| + disable_reason = ExtensionPrefs::DISABLE_PERMISSIONS_INCREASE; |
| + else |
| + disable_reason = ExtensionPrefs::DISABLE_USER_ACTION; |
| + } |
| + } else { |
| + disable_reason = ExtensionPrefs::DISABLE_PERMISSIONS_INCREASE; |
| + } |
| + |
| // To upgrade an extension in place, unload the old one and |
| // then load the new one. |
| UnloadExtension(old->id(), extension_misc::UNLOAD_REASON_UPDATE); |
| @@ -2162,6 +2190,7 @@ void ExtensionService::InitializePermissions(const Extension* extension) { |
| } |
| extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
| extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); |
| + extension_prefs_->SetDisableReason(extension->id(), disable_reason); |
| } |
| } |