diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 23:20:48 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-21 23:20:48 +0000 |
commit | b618713c323f0a5e85fb53300719e8ff1cdb410b (patch) | |
tree | 6782542670381c37d6b64667268f092470c57efc /chrome/browser/tab_contents | |
parent | 930eefad81129f1c8db7621f8a02e02b855adf90 (diff) | |
download | chromium_src-b618713c323f0a5e85fb53300719e8ff1cdb410b.zip chromium_src-b618713c323f0a5e85fb53300719e8ff1cdb410b.tar.gz chromium_src-b618713c323f0a5e85fb53300719e8ff1cdb410b.tar.bz2 |
Fix issue 6520 by ensuring that InfoBarClosed is called whenever a tab is closed or a navigation to a URL that is not supported by the current TabContentsType takes place by invoking it on all InfoBarDelegates from TabContents::Destroy(), which is the best least-common-denominator I've found for doing this work. Alternatively I could have made InfoBarDelegate listen for TAB_CONTENTS_DESTROYED and self-invoke InfoBarClosed but that seemed unorthodox (relatively speaking).
This prevents InfoBarDelegates from leaking in these cases.
BUG=6520
Review URL: http://codereview.chromium.org/18381
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8406 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r-- | chrome/browser/tab_contents/infobar_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index fa3f332..5ec5309 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -85,6 +85,8 @@ class InfoBarDelegate { // stored using StoreActiveEntryUniqueID automatically. explicit InfoBarDelegate(TabContents* contents); + virtual ~InfoBarDelegate() { } + // Store the unique id for the active entry in the specified TabContents, to // be used later upon navigation to determine if this InfoBarDelegate should // be expired from |contents_|. diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 70988e2..8afcfef 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -88,6 +88,15 @@ void TabContents::Destroy() { window->CloseConstrainedWindow(); } + // 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. + 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(NOTIFY_TAB_CONTENTS_DESTROYED, Source<TabContents>(this), |