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

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

Issue 102163002: Revert 238283 "Infobar system refactor." (Closed) Base URL: svn://svn.chromium.org/chrome/
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: trunk/src/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc
===================================================================
--- trunk/src/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc (revision 238401)
+++ trunk/src/chrome/browser/ui/gtk/infobars/translate_infobar_base_gtk.cc (working copy)
@@ -21,27 +21,24 @@
// TranslateInfoBarDelegate ---------------------------------------------------
-// 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()));
+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);
}
// TranslateInfoBarBase -------------------------------------------------------
-TranslateInfoBarBase::TranslateInfoBarBase(
- scoped_ptr<TranslateInfoBarDelegate> delegate)
- : InfoBarGtk(delegate.PassAs<InfoBarDelegate>()),
+TranslateInfoBarBase::TranslateInfoBarBase(InfoBarService* owner,
+ TranslateInfoBarDelegate* delegate)
+ : InfoBarGtk(owner, delegate),
background_error_percent_(0) {
- TranslateInfoBarDelegate* translate_delegate = GetDelegate();
- DCHECK(translate_delegate);
+ DCHECK(delegate);
TranslateInfoBarDelegate::BackgroundAnimationType animation =
- translate_delegate->background_animation_type();
+ delegate->background_animation_type();
if (animation != TranslateInfoBarDelegate::NONE) {
background_color_animation_.reset(new gfx::SlideAnimation(this));
background_color_animation_->SetTweenType(gfx::Tween::LINEAR);
@@ -55,7 +52,7 @@
background_color_animation_->Hide();
}
} else {
- background_error_percent_ = translate_delegate->is_error() ? 1 : 0;
+ background_error_percent_ = delegate->is_error() ? 1 : 0;
}
}
@@ -74,22 +71,6 @@
}
}
-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) {
@@ -140,6 +121,22 @@
}
}
+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