summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:05:07 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-13 18:05:07 +0000
commit63c73a41a18228493aa443243edb5082b667d50b (patch)
tree60e9cbcee02946ec459f5746c71a752b3a7268af
parent278429b7cfff0119359708db1b684815ea832115 (diff)
downloadchromium_src-63c73a41a18228493aa443243edb5082b667d50b.zip
chromium_src-63c73a41a18228493aa443243edb5082b667d50b.tar.gz
chromium_src-63c73a41a18228493aa443243edb5082b667d50b.tar.bz2
Fix a bug where infobars were not getting replaced on linux. This
was added to the info bar api in r22711. There's a tiny flicker when the infobars are replaced, but it's a lot better than the jerky animation there used to be. I imagine mac will still have this bug. BUG=19101 TEST=Install 2 themes from the theme gallery. The second theme should be displayed. Review URL: http://codereview.chromium.org/164456 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23323 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/gtk/infobar_container_gtk.cc40
-rw-r--r--chrome/browser/gtk/infobar_container_gtk.h4
2 files changed, 38 insertions, 6 deletions
diff --git a/chrome/browser/gtk/infobar_container_gtk.cc b/chrome/browser/gtk/infobar_container_gtk.cc
index 9489026..667a72e 100644
--- a/chrome/browser/gtk/infobar_container_gtk.cc
+++ b/chrome/browser/gtk/infobar_container_gtk.cc
@@ -32,6 +32,23 @@ void AnimateClosingForDelegate(GtkWidget* infobar_widget,
infobar->AnimateClose();
}
+// If |infobar_widget| matches |info_bar_delegate|, then close the infobar w/o
+// an animation.
+void ClosingForDelegate(GtkWidget* infobar_widget, gpointer info_bar_delegate) {
+ InfoBarDelegate* delegate =
+ static_cast<InfoBarDelegate*>(info_bar_delegate);
+ InfoBar* infobar = reinterpret_cast<InfoBar*>(
+ g_object_get_data(G_OBJECT(infobar_widget), "info-bar"));
+
+ if (!infobar) {
+ NOTREACHED();
+ return;
+ }
+
+ if (delegate == infobar->delegate())
+ infobar->Close();
+}
+
// Get the height of the widget and add it to |userdata|, but only if it is in
// the process of closing.
void SumClosingBarHeight(GtkWidget* widget, gpointer userdata) {
@@ -73,6 +90,8 @@ void InfoBarContainerGtk::ChangeTabContents(TabContents* contents) {
registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source);
registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
source);
+ registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED,
+ source);
}
}
@@ -94,7 +113,14 @@ void InfoBarContainerGtk::Observe(NotificationType type,
if (type == NotificationType::TAB_CONTENTS_INFOBAR_ADDED) {
AddInfoBar(Details<InfoBarDelegate>(details).ptr(), true);
} else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REMOVED) {
- RemoveInfoBar(Details<InfoBarDelegate>(details).ptr());
+ RemoveInfoBar(Details<InfoBarDelegate>(details).ptr(), true);
+ } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED) {
+ std::pair<InfoBarDelegate*, InfoBarDelegate*>* delegates =
+ Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr();
+
+ // By not animating the removal/addition, this appears to be a replace.
+ RemoveInfoBar(delegates->first, false);
+ AddInfoBar(delegates->second, false);
} else {
NOTREACHED();
}
@@ -120,7 +146,13 @@ void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) {
infobar->Open();
}
-void InfoBarContainerGtk::RemoveInfoBar(InfoBarDelegate* delegate) {
- gtk_container_foreach(GTK_CONTAINER(widget()),
- AnimateClosingForDelegate, delegate);
+void InfoBarContainerGtk::RemoveInfoBar(InfoBarDelegate* delegate,
+ bool animate) {
+ if (animate) {
+ gtk_container_foreach(GTK_CONTAINER(widget()),
+ AnimateClosingForDelegate, delegate);
+ } else {
+ gtk_container_foreach(GTK_CONTAINER(widget()), ClosingForDelegate,
+ delegate);
+ }
}
diff --git a/chrome/browser/gtk/infobar_container_gtk.h b/chrome/browser/gtk/infobar_container_gtk.h
index a8fbeb9..e620b2e 100644
--- a/chrome/browser/gtk/infobar_container_gtk.h
+++ b/chrome/browser/gtk/infobar_container_gtk.h
@@ -50,12 +50,12 @@ class InfoBarContainerGtk : public NotificationObserver {
// Adds an InfoBar for the specified delegate, in response to a notification
// from the selected TabContents.
- void AddInfoBar(InfoBarDelegate* delegate, bool animated);
+ void AddInfoBar(InfoBarDelegate* delegate, bool animate);
// 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);
+ void RemoveInfoBar(InfoBarDelegate* delegate, bool animate);
NotificationRegistrar registrar_;