diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 19:51:34 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-12 19:51:34 +0000 |
commit | d9118b8046804a8a185ab058a353a721e668858f (patch) | |
tree | c41186f1578cd544ed0c628d0fec02ecfe0d27f7 /chrome/browser/views | |
parent | f04dd303e05da3227edef00c1d25785f38d5ffdb (diff) | |
download | chromium_src-d9118b8046804a8a185ab058a353a721e668858f.zip chromium_src-d9118b8046804a8a185ab058a353a721e668858f.tar.gz chromium_src-d9118b8046804a8a185ab058a353a721e668858f.tar.bz2 |
first part of fix for dual translate infobars
bug is caused by 2 problems when happen during reload of a translated page:
1) infobar container was removing the wrong infobar, which this cl fixes.
2) notification NAV_ENTRY_COMMITTED is being processed by translate-manager first, then tab-contents
- translate manager would remove all infobars, then add before-translate infobar
- tab contents then removes expired infobars -- since a reload renders an infobar irrelevant, the before-translate that just got added during the same notification is removed
- b4 this cl, because of the bug in infobar container, dual infobars were displayed
- with this cl, removing the correct infobar means no translate infobar is shown, which is also wrong.
BUG=35482
TEST=none for now.
Review URL: http://codereview.chromium.org/604028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/infobars/infobar_container.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/chrome/browser/views/infobars/infobar_container.cc b/chrome/browser/views/infobars/infobar_container.cc index cea200a..99e9eb3 100644 --- a/chrome/browser/views/infobars/infobar_container.cc +++ b/chrome/browser/views/infobars/infobar_container.cc @@ -152,18 +152,22 @@ void InfoBarContainer::AddInfoBar(InfoBarDelegate* delegate, void InfoBarContainer::RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation) { - int index = 0; - for (; index < tab_contents_->infobar_delegate_count(); ++index) { - if (tab_contents_->GetInfoBarDelegateAt(index) == delegate) + // Search for infobar associated with |delegate| among child views. + // We cannot search for |delegate| in tab_contents, because an infobar remains + // a child view until its close animation completes, which can result in + // different number of infobars in container and infobar delegates in tab + // contents. + for (int i = 0; i < GetChildViewCount(); ++i) { + InfoBar* infobar = static_cast<InfoBar*>(GetChildViewAt(i)); + if (infobar->delegate() == delegate) { + if (use_animation) { + // The View will be removed once the Close animation completes. + infobar->AnimateClose(); + } else { + infobar->Close(); + } break; - } - - InfoBar* infobar = static_cast<InfoBar*>(GetChildViewAt(index)); - if (use_animation) { - // The View will be removed once the Close animation completes. - infobar->AnimateClose(); - } else { - infobar->Close(); + } } } |