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

Unified Diff: chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc

Issue 7006010: Change InfoBar-related notifications to be sourced from a TabContentsWrapper, not a TabContents. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
Index: chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc (revision 87541)
+++ chrome/browser/ui/gtk/infobars/infobar_container_gtk.cc (working copy)
@@ -92,7 +92,7 @@
tab_contents_ = contents;
if (tab_contents_) {
- Source<TabContents> source(tab_contents_->tab_contents());
+ Source<TabContentsWrapper> source(tab_contents_);
registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_ADDED, source);
registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED,
source);
@@ -100,7 +100,7 @@
source);
for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) {
InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i);
- AddInfoBar(delegate, false);
+ AddInfoBar(delegate->CreateInfoBar(tab_contents_), false);
}
}
}
@@ -118,19 +118,29 @@
void InfoBarContainerGtk::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- 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(), true);
- } else if (type == NotificationType::TAB_CONTENTS_INFOBAR_REPLACED) {
- std::pair<InfoBarDelegate*, InfoBarDelegate*>* delegates =
- Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr();
+ switch (type.value) {
+ case NotificationType::TAB_CONTENTS_INFOBAR_ADDED:
+ AddInfoBar(Details<InfoBar>(details).ptr(), true);
+ break;
- // By not animating the removal/addition, this appears to be a replace.
- RemoveInfoBar(delegates->first, false);
- AddInfoBar(delegates->second, false);
- } else {
- NOTREACHED();
+ case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: {
+ typedef std::pair<InfoBarDelegate*, bool> RemoveDetails;
+ RemoveDetails* remove_details = Details<RemoveDetails>(details).ptr();
+ RemoveInfoBar(remove_details->first, remove_details->second);
+ break;
+ }
+
+ case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: {
+ typedef std::pair<InfoBarDelegate*, InfoBar*> ReplaceDetails;
+ ReplaceDetails* replace_details = Details<ReplaceDetails>(details).ptr();
+ RemoveInfoBar(replace_details->first, false);
+ AddInfoBar(replace_details->second, false);
+ break;
+ }
+
+ default:
+ NOTREACHED();
+ break;
}
}
@@ -164,15 +174,14 @@
g_list_free(children);
}
-void InfoBarContainerGtk::AddInfoBar(InfoBarDelegate* delegate, bool animate) {
- InfoBar* infobar = delegate->CreateInfoBar(tab_contents_);
+void InfoBarContainerGtk::AddInfoBar(InfoBar* infobar, bool animate) {
infobar->set_container(this);
infobar->SetThemeProvider(GtkThemeService::GetFrom(profile_));
gtk_box_pack_start(GTK_BOX(widget()), infobar->widget(),
FALSE, FALSE, 0);
infobar->Show(animate);
- ShowArrowForDelegate(delegate, animate);
+ ShowArrowForDelegate(infobar->delegate(), animate);
}
void InfoBarContainerGtk::RemoveInfoBar(InfoBarDelegate* delegate,
« no previous file with comments | « chrome/browser/ui/gtk/infobars/infobar_container_gtk.h ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698