| Index: chrome/browser/views/infobars/infobar_container.cc
|
| diff --git a/chrome/browser/views/infobars/infobar_container.cc b/chrome/browser/views/infobars/infobar_container.cc
|
| index 530236c94b309f581eb95b0f170e785d5ca8de53..792729bb920781fdc77391e4cc8da38986fdc441 100644
|
| --- a/chrome/browser/views/infobars/infobar_container.cc
|
| +++ b/chrome/browser/views/infobars/infobar_container.cc
|
| @@ -38,6 +38,8 @@ void InfoBarContainer::ChangeTabContents(TabContents* contents) {
|
| tc_source);
|
| registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
|
| tc_source);
|
| + registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
|
| + tc_source);
|
| }
|
| }
|
|
|
| @@ -109,9 +111,13 @@ void InfoBarContainer::Observe(NotificationType type,
|
| const NotificationSource& source,
|
| const NotificationDetails& details) {
|
| if (type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED) {
|
| - AddInfoBar(Details<InfoBarDelegate>(details).ptr());
|
| + AddInfoBar(Details<InfoBarDelegate>(details).ptr(), true); // animated
|
| } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) {
|
| - RemoveInfoBar(Details<InfoBarDelegate>(details).ptr());
|
| + RemoveInfoBar(Details<InfoBarDelegate>(details).ptr(), true); // animated
|
| + } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED) {
|
| + std::pair<InfoBarDelegate*, InfoBarDelegate*>* delegates =
|
| + Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr();
|
| + ReplaceInfoBar(delegates->first, delegates->second);
|
| } else {
|
| NOTREACHED();
|
| }
|
| @@ -129,20 +135,37 @@ void InfoBarContainer::UpdateInfoBars() {
|
| }
|
| }
|
|
|
| -void InfoBarContainer::AddInfoBar(InfoBarDelegate* delegate) {
|
| +void InfoBarContainer::AddInfoBar(InfoBarDelegate* delegate,
|
| + bool use_animation) {
|
| InfoBar* infobar = delegate->CreateInfoBar();
|
| infobar->set_container(this);
|
| - infobar->AnimateOpen();
|
| AddChildView(infobar);
|
| +
|
| + if (use_animation)
|
| + infobar->AnimateOpen();
|
| + else
|
| + infobar->Open();
|
| }
|
|
|
| -void InfoBarContainer::RemoveInfoBar(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)
|
| break;
|
| }
|
|
|
| - // The View will be removed once the Close animation completes.
|
| - static_cast<InfoBar*>(GetChildViewAt(index))->AnimateClose();
|
| + 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();
|
| + }
|
| +}
|
| +
|
| +void InfoBarContainer::ReplaceInfoBar(InfoBarDelegate* old_delegate,
|
| + InfoBarDelegate* new_delegate) {
|
| + RemoveInfoBar(old_delegate, false); // no animation
|
| + AddInfoBar(new_delegate, false); // no animation
|
| }
|
|
|