Index: chrome/browser/tab_contents/tab_contents.cc |
=================================================================== |
--- chrome/browser/tab_contents/tab_contents.cc (revision 16872) |
+++ chrome/browser/tab_contents/tab_contents.cc (working copy) |
@@ -313,21 +313,25 @@ |
window->CloseConstrainedWindow(); |
} |
+ // Notify any observer that have a reference on this tab contents. |
+ NotificationService::current()->Notify( |
+ NotificationType::TAB_CONTENTS_DESTROYED, |
+ Source<TabContents>(this), |
+ NotificationService::NoDetails()); |
+ |
// Notify any lasting InfobarDelegates that have not yet been removed that |
// whatever infobar they were handling in this TabContents has closed, |
// because the TabContents is going away entirely. |
+ // This must happen after the TAB_CONTENTS_DESTROYED notification as the |
+ // notification may trigger infobars calls that access their delegate. (and |
+ // some implementations of InfoBarDelegate do delete themselves on |
+ // InfoBarClosed()). |
for (int i = 0; i < infobar_delegate_count(); ++i) { |
InfoBarDelegate* delegate = GetInfoBarDelegateAt(i); |
delegate->InfoBarClosed(); |
} |
infobar_delegates_.clear(); |
- // Notify any observer that have a reference on this tab contents. |
- NotificationService::current()->Notify( |
- NotificationType::TAB_CONTENTS_DESTROYED, |
- Source<TabContents>(this), |
- NotificationService::NoDetails()); |
- |
// TODO(brettw) this should be moved to the view. |
#if defined(OS_WIN) |
// If we still have a window handle, destroy it. GetNativeView can return |