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

Unified Diff: chrome/browser/extensions/external_install_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/external_install_ui.cc
diff --git a/chrome/browser/extensions/external_install_ui.cc b/chrome/browser/extensions/external_install_ui.cc
index 0888c976cb227e126c5454adc8f7e8d4d3f5e9ac..0b0f4e96e77abd8ba27d85b6eabfb3920909aa42 100644
--- a/chrome/browser/extensions/external_install_ui.cc
+++ b/chrome/browser/extensions/external_install_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"
@@ -29,10 +28,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_url_handler.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"
@@ -90,8 +85,9 @@ class ExternalInstallDialogDelegate
// Only shows a menu item, no bubble. Clicking the menu item shows
// an external install dialog.
-class ExternalInstallMenuAlert : public GlobalError,
- public content::NotificationObserver {
+class ExternalInstallMenuAlert
+ : public GlobalError,
+ public ExtensionService::DisabledExtensionObserver {
public:
ExternalInstallMenuAlert(ExtensionService* service,
const Extension* extension);
@@ -114,15 +110,13 @@ class ExternalInstallMenuAlert : public GlobalError,
virtual void BubbleViewAcceptButtonPressed(Browser* browser) OVERRIDE;
virtual void BubbleViewCancelButtonPressed(Browser* browser) 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;
protected:
ExtensionService* service_;
const Extension* extension_;
- content::NotificationRegistrar registrar_;
};
// Shows a menu item and a global error bubble, replacing the install dialog.
@@ -242,13 +236,11 @@ ExternalInstallMenuAlert::ExternalInstallMenuAlert(
const Extension* extension)
: service_(service),
extension_(extension) {
- 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);
}
ExternalInstallMenuAlert::~ExternalInstallMenuAlert() {
+ service_->RemoveDisabledExtensionObserver(this);
}
GlobalError::Severity ExternalInstallMenuAlert::GetSeverity() {
@@ -311,27 +303,16 @@ void ExternalInstallMenuAlert::BubbleViewCancelButtonPressed(
NOTREACHED();
}
-void ExternalInstallMenuAlert::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- const Extension* extension = NULL;
+void ExternalInstallMenuAlert::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_) {
- GlobalErrorService* error_service =
- GlobalErrorServiceFactory::GetForProfile(service_->profile());
- error_service->RemoveGlobalError(this);
- service_->AcknowledgeExternalExtension(extension_->id());
- delete this;
- }
+ if (extension != extension_)
+ return;
+ GlobalErrorService* error_service =
+ GlobalErrorServiceFactory::GetForProfile(service_->profile());
+ error_service->RemoveGlobalError(this);
+ service_->AcknowledgeExternalExtension(extension_->id());
+ delete this;
}
// ExternalInstallGlobalError -----------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698