diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 23:27:29 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-27 23:27:29 +0000 |
commit | 017f19b5f1af1702252655b4b52bdcd9ab7a0de2 (patch) | |
tree | 72ac07978cf531eebdc071ca9645ed78c42f435a /chrome/browser/views | |
parent | 1b66e47eba578f499c610a3b608a23a086254f48 (diff) | |
download | chromium_src-017f19b5f1af1702252655b4b52bdcd9ab7a0de2.zip chromium_src-017f19b5f1af1702252655b4b52bdcd9ab7a0de2.tar.gz chromium_src-017f19b5f1af1702252655b4b52bdcd9ab7a0de2.tar.bz2 |
Fix a crash in ExtensionGalleryInstallApiTest.InstallAndUninstall caused by
the ExtensionInstalledBubble.
The info bubble was closing after the extension was uninstalled. This wouldn't
always happen - sometimes the browser shut down first, so we didn't crash.
BUG=56558
TEST=covered by browser_test
Review URL: http://codereview.chromium.org/4112007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/extensions/extension_installed_bubble.cc | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/chrome/browser/views/extensions/extension_installed_bubble.cc b/chrome/browser/views/extensions/extension_installed_bubble.cc index 4997ac6..27910e5 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/views/extensions/extension_installed_bubble.cc @@ -272,7 +272,9 @@ ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, // be sure that a BrowserAction or PageAction has had views created which we // can inspect for the purpose of previewing of pointing to them. registrar_.Add(this, NotificationType::EXTENSION_LOADED, - NotificationService::AllSources()); + Source<Profile>(browser->profile())); + registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, + Source<Profile>(browser->profile())); } void ExtensionInstalledBubble::Observe(NotificationType type, @@ -286,6 +288,10 @@ void ExtensionInstalledBubble::Observe(NotificationType type, MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, &ExtensionInstalledBubble::ShowInternal)); } + } else if (type == NotificationType::EXTENSION_UNLOADED) { + const Extension* extension = Details<const Extension>(details).ptr(); + if (extension == extension_) + extension_ = NULL; } else { NOTREACHED() << L"Received unexpected notification"; } @@ -354,25 +360,27 @@ void ExtensionInstalledBubble::ShowInternal() { // InfoBubbleDelegate void ExtensionInstalledBubble::InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) { - if (type_ == PAGE_ACTION) { - BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( - browser_->window()->GetNativeHandle()); - browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( - extension_->page_action(), - false); // preview_enabled - } else if (type_ == EXTENSION_APP) { - if (bubble_content_->create_shortcut()) { - ShellIntegration::ShortcutInfo shortcut_info; - shortcut_info.url = extension_->GetFullLaunchURL(); - shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); - shortcut_info.title = UTF8ToUTF16(extension_->name()); - shortcut_info.description = UTF8ToUTF16(extension_->description()); - shortcut_info.favicon = icon_; - shortcut_info.create_on_desktop = true; - shortcut_info.create_in_applications_menu = false; - shortcut_info.create_in_quick_launch_bar = false; - web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, - NULL); + if (extension_) { + if (type_ == PAGE_ACTION) { + BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( + browser_->window()->GetNativeHandle()); + browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( + extension_->page_action(), + false); // preview_enabled + } else if (type_ == EXTENSION_APP) { + if (bubble_content_->create_shortcut()) { + ShellIntegration::ShortcutInfo shortcut_info; + shortcut_info.url = extension_->GetFullLaunchURL(); + shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); + shortcut_info.title = UTF8ToUTF16(extension_->name()); + shortcut_info.description = UTF8ToUTF16(extension_->description()); + shortcut_info.favicon = icon_; + shortcut_info.create_on_desktop = true; + shortcut_info.create_in_applications_menu = false; + shortcut_info.create_in_quick_launch_bar = false; + web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, + NULL); + } } } |