diff options
Diffstat (limited to 'chrome/browser')
-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(); + } } } |