diff options
| author | Ben Murdoch <benm@google.com> | 2010-11-18 18:32:45 +0000 |
|---|---|---|
| committer | Ben Murdoch <benm@google.com> | 2010-11-18 18:38:07 +0000 |
| commit | 513209b27ff55e2841eac0e4120199c23acce758 (patch) | |
| tree | aeba30bb08c5f47c57003544e378a377c297eee6 /chrome/browser/cocoa/extension_installed_bubble_controller.mm | |
| parent | 164f7496de0fbee436b385a79ead9e3cb81a50c1 (diff) | |
| download | external_chromium-513209b27ff55e2841eac0e4120199c23acce758.zip external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.gz external_chromium-513209b27ff55e2841eac0e4120199c23acce758.tar.bz2 | |
Merge Chromium at r65505: Initial merge by git.
Change-Id: I31d8f1d8cd33caaf7f47ffa7350aef42d5fbdb45
Diffstat (limited to 'chrome/browser/cocoa/extension_installed_bubble_controller.mm')
| -rw-r--r-- | chrome/browser/cocoa/extension_installed_bubble_controller.mm | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/extension_installed_bubble_controller.mm b/chrome/browser/cocoa/extension_installed_bubble_controller.mm index 00cd535..b1263fd 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: @@ -44,12 +46,19 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == [controller_ extension]) { [controller_ performSelectorOnMainThread:@selector(showWindow:) 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."; } @@ -65,7 +74,7 @@ class ExtensionLoadedNotificationObserver : public NotificationObserver { @synthesize pageActionRemoved = pageActionRemoved_; // Exposed for unit test. - (id)initWithParentWindow:(NSWindow*)parentWindow - extension:(Extension*)extension + extension:(const Extension*)extension browser:(Browser*)browser icon:(SkBitmap)icon { NSString* nibPath = @@ -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 |
