Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: chrome/browser/views/infobars/infobar_container.cc

Issue 165370: Merge 22711 - Fix a few bugs with the theme infobar:... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/infobars/infobar_container.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/infobars/infobar_container.cc
===================================================================
--- chrome/browser/views/infobars/infobar_container.cc (revision 23152)
+++ chrome/browser/views/infobars/infobar_container.cc (working copy)
@@ -38,6 +38,8 @@
tc_source);
registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
tc_source);
+ registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
+ tc_source);
}
}
@@ -88,9 +90,13 @@
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();
}
@@ -108,20 +114,37 @@
}
}
-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
+}
Property changes on: chrome\browser\views\infobars\infobar_container.cc
___________________________________________________________________
Added: svn:mergeinfo
Merged /trunk/src/chrome/browser/views/infobars/infobar_container.cc:r22711
Merged /branches/chrome_webkit_merge_branch/chrome/browser/views/infobars/infobar_container.cc:r69-2775
« no previous file with comments | « chrome/browser/views/infobars/infobar_container.h ('k') | chrome/common/notification_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698