1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_GTK_INFOBARS_TRANSLATE_INFOBAR_BASE_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_INFOBARS_TRANSLATE_INFOBAR_BASE_GTK_H_
8 #include "base/compiler_specific.h"
9 #include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
10 #include "ui/gfx/animation/animation_delegate.h"
12 class TranslateInfoBarDelegate
;
14 // This class contains some of the base functionality that translate infobars
16 class TranslateInfoBarBase
: public InfoBarGtk
{
18 explicit TranslateInfoBarBase(scoped_ptr
<TranslateInfoBarDelegate
> delegate
);
19 virtual ~TranslateInfoBarBase();
22 virtual void AnimationProgressed(const gfx::Animation
* animation
) OVERRIDE
;
23 virtual void PlatformSpecificSetOwner() OVERRIDE
;
24 virtual void GetTopColor(InfoBarDelegate::Type type
,
25 double* r
, double* g
, double* b
) OVERRIDE
;
26 virtual void GetBottomColor(InfoBarDelegate::Type type
,
27 double* r
, double* g
, double* b
) OVERRIDE
;
29 // Sub-classes that want to have the options menu button showing should
30 // override and return true.
31 virtual bool ShowOptionsMenuButton() const;
33 // Creates a combobox that displays the languages currently available.
34 // |selected_language| is the language index (as used in the
35 // TranslateInfoBarDelegate) that should be selected initially.
36 // |exclude_language| is the language index of the language that should not be
37 // included in the list (TranslateInfoBarDelegate::kNoIndex means no language
39 GtkWidget
* CreateLanguageCombobox(size_t selected_language
,
40 size_t exclude_language
);
42 // Given an above-constructed combobox, returns the currently selected
44 static size_t GetLanguageComboboxActiveId(GtkComboBox
* combo
);
46 // Convenience to retrieve the TranslateInfoBarDelegate for this infobar.
47 TranslateInfoBarDelegate
* GetDelegate();
50 // To be able to map from language id <-> entry in the combo box, we
51 // store the language id in the combo box data model in addition to the
54 LANGUAGE_COMBO_COLUMN_ID
,
55 LANGUAGE_COMBO_COLUMN_NAME
,
56 LANGUAGE_COMBO_COLUMN_COUNT
59 CHROMEGTK_CALLBACK_0(TranslateInfoBarBase
, void, OnOptionsClicked
);
61 // A percentage to average the normal page action background with the error
62 // background. When 0, the infobar background should be pure PAGE_ACTION_TYPE.
63 // When 1, the infobar background should be pure WARNING_TYPE.
64 double background_error_percent_
;
66 // Changes the color of the background from normal to error color and back.
67 scoped_ptr
<gfx::SlideAnimation
> background_color_animation_
;
69 // The model for the current menu displayed.
70 scoped_ptr
<ui::MenuModel
> menu_model_
;
72 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarBase
);
75 #endif // CHROME_BROWSER_UI_GTK_INFOBARS_TRANSLATE_INFOBAR_BASE_GTK_H_