diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 22:39:16 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 22:39:16 +0000 |
commit | d7b4cc7de3c097014cd3850bc6e01e2e5d69d657 (patch) | |
tree | 4a9368a41f1879da31c16cd06da3c38babe15608 /chrome | |
parent | 9181d3e491ff88dab0dfa99f5f2b77a67c1316e7 (diff) | |
download | chromium_src-d7b4cc7de3c097014cd3850bc6e01e2e5d69d657.zip chromium_src-d7b4cc7de3c097014cd3850bc6e01e2e5d69d657.tar.gz chromium_src-d7b4cc7de3c097014cd3850bc6e01e2e5d69d657.tar.bz2 |
Fix crash when reloading/unloading extension after an infobar has been shown.
BUG=26463
TEST=Reload/shoot down the extension process hosting the extension/infobar and
make sure the browser doesn't crash.
Review URL: http://codereview.chromium.org/1001004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41889 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extension_infobar_delegate.cc | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_infobar_delegate.cc b/chrome/browser/extensions/extension_infobar_delegate.cc index 0c7323a..47b9026 100644 --- a/chrome/browser/extensions/extension_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_infobar_delegate.cc @@ -26,6 +26,8 @@ ExtensionInfoBarDelegate::ExtensionInfoBarDelegate(Browser* browser, registrar_.Add(this, NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, Source<Profile>(browser->profile())); + registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, + Source<Profile>(browser->profile())); } ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { @@ -34,6 +36,14 @@ ExtensionInfoBarDelegate::~ExtensionInfoBarDelegate() { bool ExtensionInfoBarDelegate::EqualsDelegate(InfoBarDelegate* delegate) const { ExtensionInfoBarDelegate* extension_delegate = delegate->AsExtensionInfoBarDelegate(); + // When an extension crashes, an InfoBar is shown (for the crashed extension). + // That will result in a call to this function (to see if this InfoBarDelegate + // is already showing the 'extension crashed InfoBar', which it never is), but + // if it is our extension that crashes, the extension delegate is NULL so + // we cannot check. + if (!extension_delegate) + return false; + // Only allow one InfoBar at a time per extension. return extension_delegate->extension_host()->extension() == extension_host_->extension(); @@ -53,8 +63,22 @@ InfoBar* ExtensionInfoBarDelegate::CreateInfoBar() { void ExtensionInfoBarDelegate::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { - DCHECK(type == NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE); - const ExtensionHost* result = Details<ExtensionHost>(details).ptr(); - if (extension_host_.get() == result) - tab_contents_->RemoveInfoBar(this); + switch (type.value) { + case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: { + const ExtensionHost* result = Details<ExtensionHost>(details).ptr(); + if (extension_host_.get() == result) + tab_contents_->RemoveInfoBar(this); + break; + } + case NotificationType::EXTENSION_UNLOADED: { + Extension* extension = Details<Extension>(details).ptr(); + if (extension_ == extension) + tab_contents_->RemoveInfoBar(this); + break; + } + default: { + NOTREACHED() << "Unknown message"; + break; + } + } } |