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

Unified Diff: chrome/browser/gtk/infobar_gtk.cc

Issue 4767001: Make TabContents own its infobar delegates.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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/gtk/infobar_gtk.cc
===================================================================
--- chrome/browser/gtk/infobar_gtk.cc (revision 65558)
+++ chrome/browser/gtk/infobar_gtk.cc (working copy)
@@ -40,7 +40,8 @@
: container_(NULL),
delegate_(delegate),
theme_provider_(NULL),
- arrow_model_(this) {
+ arrow_model_(this),
+ cached_infobar_type_(delegate->GetInfoBarType()) {
// Create |hbox_| and pad the sides.
hbox_ = gtk_hbox_new(FALSE, kElementPadding);
@@ -105,14 +106,12 @@
}
void InfoBar::AnimateClose() {
+ delegate_ = NULL;
slide_widget_->Close();
}
void InfoBar::Close() {
- if (delegate_) {
- delegate_->InfoBarClosed();
- delegate_ = NULL;
- }
+ delegate_ = NULL;
delete this;
}
@@ -276,9 +275,10 @@
}
void InfoBar::OnCloseButton(GtkWidget* button) {
- if (delegate_)
+ if (delegate_) {
delegate_->InfoBarDismissed();
- RemoveInfoBar();
+ RemoveInfoBar();
+ }
}
gboolean InfoBar::OnBackgroundExpose(GtkWidget* sender,
@@ -292,7 +292,7 @@
cairo_pattern_t* pattern = cairo_pattern_create_linear(0, 0, 0, height);
double top_r, top_g, top_b;
- GetTopColor(delegate_->GetInfoBarType(), &top_r, &top_g, &top_b);
+ GetTopColor(cached_infobar_type_, &top_r, &top_g, &top_b);
cairo_pattern_add_color_stop_rgb(pattern, 0.0, top_r, top_g, top_b);
double bottom_r, bottom_g, bottom_b;
@@ -355,10 +355,10 @@
private:
static void OnLinkClick(GtkWidget* button, LinkInfoBar* link_info_bar) {
- if (link_info_bar->delegate_->AsLinkInfoBarDelegate()->
- LinkClicked(gtk_util::DispositionForCurrentButtonPressEvent())) {
+ if (link_info_bar->delegate_ &&
tfarina 2010/11/10 13:11:57 Why the check here and else here? Ah, OK because i
+ link_info_bar->delegate_->AsLinkInfoBarDelegate()->
+ LinkClicked(gtk_util::DispositionForCurrentButtonPressEvent()))
tfarina 2010/11/10 13:11:57 Please, do not remove {} around the if clause.
link_info_bar->RemoveInfoBar();
- }
}
};
@@ -426,20 +426,19 @@
}
void ConfirmInfoBar::OnCancelButton(GtkWidget* widget) {
- if (delegate_->AsConfirmInfoBarDelegate()->Cancel())
+ if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->Cancel())
RemoveInfoBar();
}
void ConfirmInfoBar::OnOkButton(GtkWidget* widget) {
- if (delegate_->AsConfirmInfoBarDelegate()->Accept())
+ if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->Accept())
RemoveInfoBar();
}
void ConfirmInfoBar::OnLinkClicked(GtkWidget* widget) {
- if (delegate_->AsConfirmInfoBarDelegate()->LinkClicked(
- gtk_util::DispositionForCurrentButtonPressEvent())) {
+ if (delegate_ && delegate_->AsConfirmInfoBarDelegate()->LinkClicked(
+ gtk_util::DispositionForCurrentButtonPressEvent()))
tfarina 2010/11/10 13:11:57 Please, do not remove the {} around the if clause
RemoveInfoBar();
- }
}
InfoBar* AlertInfoBarDelegate::CreateInfoBar() {

Powered by Google App Engine
This is Rietveld 408576698