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

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

Issue 22694006: Infobar system refactor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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/translate_infobar_base_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc (revision 238220)
+++ chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc (working copy)
@@ -21,24 +21,27 @@
// TranslateInfoBarDelegate ---------------------------------------------------
-InfoBar* TranslateInfoBarDelegate::CreateInfoBar(InfoBarService* owner) {
- if (infobar_type_ == BEFORE_TRANSLATE)
- return new BeforeTranslateInfoBar(owner, this);
- if (infobar_type_ == AFTER_TRANSLATE)
- return new AfterTranslateInfoBar(owner, this);
- return new TranslateMessageInfoBar(owner, this);
+// static
+scoped_ptr<InfoBar> TranslateInfoBarDelegate::CreateInfoBar(
+ scoped_ptr<TranslateInfoBarDelegate> delegate) {
+ if (delegate->infobar_type() == BEFORE_TRANSLATE)
+ return scoped_ptr<InfoBar>(new BeforeTranslateInfoBar(delegate.Pass()));
+ if (delegate->infobar_type() == AFTER_TRANSLATE)
+ return scoped_ptr<InfoBar>(new AfterTranslateInfoBar(delegate.Pass()));
+ return scoped_ptr<InfoBar>(new TranslateMessageInfoBar(delegate.Pass()));
}
// TranslateInfoBarBase -------------------------------------------------------
-TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner,
- TranslateInfoBarDelegate* delegate)
- : InfoBarGtk(owner, delegate),
+TranslateInfoBarBase::TranslateInfoBarBase(
+ scoped_ptr<TranslateInfoBarDelegate> delegate)
+ : InfoBarGtk(delegate.PassAs<InfoBarDelegate>()),
background_error_percent_(0) {
- DCHECK(delegate);
+ TranslateInfoBarDelegate* translate_delegate = GetDelegate();
+ DCHECK(translate_delegate);
TranslateInfoBarDelegate::BackgroundAnimationType animation =
- delegate->background_animation_type();
+ translate_delegate->background_animation_type();
if (animation != TranslateInfoBarDelegate::NONE) {
background_color_animation_.reset(new gfx::SlideAnimation(this));
background_color_animation_->SetTweenType(gfx::Tween::LINEAR);
@@ -52,7 +55,7 @@
background_color_animation_->Hide();
}
} else {
- background_error_percent_ = delegate->is_error() ? 1 : 0;
+ background_error_percent_ = translate_delegate->is_error() ? 1 : 0;
}
}
@@ -71,6 +74,22 @@
}
}
+void TranslateInfoBarBase::PlatformSpecificSetOwner() {
+ InfoBarGtk::PlatformSpecificSetOwner();
+
+ if (!ShowOptionsMenuButton())
+ return;
+
+ // The options button sits outside the translate_box so that it can be end
+ // packed in hbox().
+ GtkWidget* options_menu_button = CreateMenuButton(
+ l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS));
+ signals()->Connect(options_menu_button, "clicked",
+ G_CALLBACK(&OnOptionsClickedThunk), this);
+ gtk_widget_show_all(options_menu_button);
+ gtk_util::CenterWidgetInHBox(hbox(), options_menu_button, true, 0);
+}
+
void TranslateInfoBarBase::GetTopColor(InfoBarDelegate::Type type,
double* r, double* g, double* b) {
if (background_error_percent_ <= 0) {
@@ -121,22 +140,6 @@
}
}
-void TranslateInfoBarBase::InitWidgets() {
- InfoBarGtk::InitWidgets();
-
- if (!ShowOptionsMenuButton())
- return;
-
- // The options button sits outside the translate_box so that it can be end
- // packed in hbox().
- GtkWidget* options_menu_button = CreateMenuButton(
- l10n_util::GetStringUTF8(IDS_TRANSLATE_INFOBAR_OPTIONS));
- signals()->Connect(options_menu_button, "clicked",
- G_CALLBACK(&OnOptionsClickedThunk), this);
- gtk_widget_show_all(options_menu_button);
- gtk_util::CenterWidgetInHBox(hbox(), options_menu_button, true, 0);
-}
-
bool TranslateInfoBarBase::ShowOptionsMenuButton() const {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698