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

Unified Diff: chrome/browser/extensions/extension_disabled_ui.cc

Issue 21443002: Add NOTIFICATION_EXTENSION_REMOVED for Extensions removed from ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months 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/extension_disabled_ui.cc
diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc
index d1c3b5c3c9a260ac3ac90454394b1be90f37bbf1..c870c68fb738a8465dfa31e9390feab767add351 100644
--- a/chrome/browser/extensions/extension_disabled_ui.cc
+++ b/chrome/browser/extensions/extension_disabled_ui.cc
@@ -14,7 +14,6 @@
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/extension_install_prompt.h"
#include "chrome/browser/extensions/extension_install_ui.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -30,10 +29,6 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
#include "chrome/common/extensions/permissions/permission_set.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/notification_source.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -134,9 +129,10 @@ void ExtensionDisabledDialogDelegate::InstallUIAbort(bool user_initiated) {
// ExtensionDisabledGlobalError -----------------------------------------------
-class ExtensionDisabledGlobalError : public GlobalError,
- public content::NotificationObserver,
- public ExtensionUninstallDialog::Delegate {
+class ExtensionDisabledGlobalError
+ : public GlobalError,
+ public ExtensionService::DisabledExtensionObserver,
+ public ExtensionUninstallDialog::Delegate {
public:
ExtensionDisabledGlobalError(ExtensionService* service,
const Extension* extension,
@@ -163,10 +159,9 @@ class ExtensionDisabledGlobalError : public GlobalError,
virtual void ExtensionUninstallAccepted() OVERRIDE;
virtual void ExtensionUninstallCanceled() OVERRIDE;
- // content::NotificationObserver implementation.
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
+ // ExtensionService::DisabledExtensionObserver implementation.
+ virtual void OnDisabledExtensionRemoved(const Extension* extension,
+ bool was_enabled) OVERRIDE;
private:
ExtensionService* service_;
@@ -186,8 +181,6 @@ class ExtensionDisabledGlobalError : public GlobalError,
// Menu command ID assigned for this extension's error.
int menu_command_id_;
-
- content::NotificationRegistrar registrar_;
};
// TODO(yoz): create error at startup for disabled extensions.
@@ -209,10 +202,7 @@ ExtensionDisabledGlobalError::ExtensionDisabledGlobalError(
skia::ImageOperations::RESIZE_BEST,
gfx::Size(kIconSize, kIconSize)));
}
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
- content::Source<Profile>(service->profile()));
- registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
- content::Source<Profile>(service->profile()));
+ service_->AddDisabledExtensionObserver(this);
}
ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {
@@ -220,6 +210,7 @@ ExtensionDisabledGlobalError::~ExtensionDisabledGlobalError() {
UMA_HISTOGRAM_ENUMERATION("Extensions.DisabledUIUserResponse",
user_response_,
EXTENSION_DISABLED_UI_BUCKET_BOUNDARY);
+ service_->RemoveDisabledExtensionObserver(this);
}
GlobalError::Severity ExtensionDisabledGlobalError::GetSeverity() {
@@ -314,31 +305,20 @@ void ExtensionDisabledGlobalError::ExtensionUninstallCanceled() {
// Nothing happens, and the error is still there.
}
-void ExtensionDisabledGlobalError::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- const Extension* extension = NULL;
+void ExtensionDisabledGlobalError::OnDisabledExtensionRemoved(
+ const Extension* extension, bool was_enabled) {
// The error is invalidated if the extension has been reloaded
// or unloaded.
- if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
- extension = content::Details<const Extension>(details).ptr();
- } else {
- DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type);
- extensions::UnloadedExtensionInfo* info =
- content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
- extension = info->extension;
- }
- if (extension == extension_) {
- GlobalErrorServiceFactory::GetForProfile(service_->profile())->
- RemoveGlobalError(this);
-
- if (type == chrome::NOTIFICATION_EXTENSION_LOADED)
- user_response_ = REENABLE;
- else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED)
- user_response_ = UNINSTALL;
- delete this;
- }
+ if (extension != extension_)
+ return;
+ GlobalErrorServiceFactory::GetForProfile(service_->profile())->
+ RemoveGlobalError(this);
+
+ if (was_enabled)
+ user_response_ = REENABLE;
+ else
+ user_response_ = UNINSTALL;
+ delete this;
}
// Globals --------------------------------------------------------------------
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | chrome/browser/extensions/extension_service.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698