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 | |
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
-rw-r--r-- | chrome/browser/translate/translate_manager.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/infobars/infobar_container.cc | 26 |
2 files changed, 16 insertions, 12 deletions
diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index 2b23e07..5f24cb6 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -139,7 +139,7 @@ void TranslateManager::InitiateTranslation(TabContents* tab, // translate related infobars as they would prevent any new infobar from // showing. (As TabContents will not add an infobar if there is already one // showing equal to the one being added.) - for (int i = 0; i < tab->infobar_delegate_count(); ++i) { + for (int i = tab->infobar_delegate_count() - 1; i >= 0; --i) { InfoBarDelegate* info_bar = tab->GetInfoBarDelegateAt(i); if (info_bar->AsTranslateInfoBarDelegate()) tab->RemoveInfoBar(info_bar); 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(); + } } } |