diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-07 01:29:47 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-07 01:29:47 +0000 |
commit | f81821cd9abdabf27c751dc42b84023098769c66 (patch) | |
tree | 8ab796226cbbf4068e78592972f00a42d20563f2 /chrome/browser/views/infobars | |
parent | 0e80dfe1bc81e7f13f56f6812a25c04b7947a698 (diff) | |
download | chromium_src-f81821cd9abdabf27c751dc42b84023098769c66.zip chromium_src-f81821cd9abdabf27c751dc42b84023098769c66.tar.gz chromium_src-f81821cd9abdabf27c751dc42b84023098769c66.tar.bz2 |
Fix a few bugs with the theme infobar:
* Don't animate the infobar closing and opening when switching
between themes.
* Don't show multiple infobars when intalling themes in rapid
succession.
BUG=18213
Review URL: http://codereview.chromium.org/165029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22711 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/infobars')
-rw-r--r-- | chrome/browser/views/infobars/infobar_container.cc | 37 | ||||
-rw-r--r-- | chrome/browser/views/infobars/infobar_container.h | 14 |
2 files changed, 40 insertions, 11 deletions
diff --git a/chrome/browser/views/infobars/infobar_container.cc b/chrome/browser/views/infobars/infobar_container.cc index 530236c..792729b 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 } diff --git a/chrome/browser/views/infobars/infobar_container.h b/chrome/browser/views/infobars/infobar_container.h index 063ba26..b5ea0f0 100644 --- a/chrome/browser/views/infobars/infobar_container.h +++ b/chrome/browser/views/infobars/infobar_container.h @@ -57,13 +57,19 @@ class InfoBarContainer : public views::View, void UpdateInfoBars(); // Adds an InfoBar for the specified delegate, in response to a notification - // from the selected TabContents. The InfoBar's appearance will be animated. - void AddInfoBar(InfoBarDelegate* delegate); + // from the selected TabContents. The InfoBar's appearance will be animated + // if |use_animation| is true. + void AddInfoBar(InfoBarDelegate* delegate, bool use_animation); // Removes an InfoBar for the specified delegate, in response to a // notification from the selected TabContents. The InfoBar's disappearance - // will be animated. - void RemoveInfoBar(InfoBarDelegate* delegate); + // will be animated if |use_animation| is true. + void RemoveInfoBar(InfoBarDelegate* delegate, bool use_animation); + + // Replaces an InfoBar for the specified delegate with a new one. There is no + // animation. + void ReplaceInfoBar(InfoBarDelegate* old_delegate, + InfoBarDelegate* new_delegate); NotificationRegistrar registrar_; |