summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/extension_installed_bubble_controller.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/extension_installed_bubble_controller.mm')
-rw-r--r--chrome/browser/cocoa/extension_installed_bubble_controller.mm23
1 files changed, 18 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
index 00cd535..b83b303 100644
--- a/chrome/browser/cocoa/extension_installed_bubble_controller.mm
+++ b/chrome/browser/cocoa/extension_installed_bubble_controller.mm
@@ -31,10 +31,12 @@
class ExtensionLoadedNotificationObserver : public NotificationObserver {
public:
ExtensionLoadedNotificationObserver(
- ExtensionInstalledBubbleController* controller)
+ ExtensionInstalledBubbleController* controller, Profile* profile)
: controller_(controller) {
registrar_.Add(this, NotificationType::EXTENSION_LOADED,
- NotificationService::AllSources());
+ Source<Profile>(profile));
+ registrar_.Add(this, NotificationType::EXTENSION_UNLOADED,
+ Source<Profile>(profile));
}
private:
@@ -50,6 +52,13 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
withObject:controller_
waitUntilDone:NO];
}
+ } else if (type == NotificationType::EXTENSION_UNLOADED) {
+ const Extension* extension = Details<const Extension>(details).ptr();
+ if (extension == [controller_ extension]) {
+ [controller_ performSelectorOnMainThread:@selector(extensionUnloaded:)
+ withObject:controller_
+ waitUntilDone:NO];
+ }
} else {
NOTREACHED() << "Received unexpected notification.";
}
@@ -91,7 +100,8 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
}
// Start showing window only after extension has fully loaded.
- extensionObserver_.reset(new ExtensionLoadedNotificationObserver(self));
+ extensionObserver_.reset(new ExtensionLoadedNotificationObserver(
+ self, browser->profile()));
}
return self;
}
@@ -140,8 +150,7 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
// Extracted to a function here so that it can be overwritten for unit
// testing.
- (void)removePageActionPreviewIfNecessary {
- DCHECK(extension_);
- if (!extension_->page_action() || pageActionRemoved_)
+ if (!extension_ || !extension_->page_action() || pageActionRemoved_)
return;
pageActionRemoved_ = YES;
@@ -329,4 +338,8 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver {
return [extensionInstalledInfoMsg_ frame];
}
+- (void)extensionUnloaded:(id)sender {
+ extension_ = NULL;
+}
+
@end