| 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;
|
| }
|
|
|