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_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_
6 #define CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_
8 #include "chrome/browser/ui/views/infobars/translate_infobar_base.h"
9 #include "ui/views/controls/button/menu_button_listener.h"
11 class OptionsMenuModel
;
12 class TranslateInfoBarDelegate
;
13 class TranslateLanguageMenuModel
;
19 class AfterTranslateInfoBar
: public TranslateInfoBarBase
,
20 public views::MenuButtonListener
{
22 explicit AfterTranslateInfoBar(scoped_ptr
<TranslateInfoBarDelegate
> delegate
);
25 virtual ~AfterTranslateInfoBar();
27 // TranslateInfoBarBase:
28 virtual void Layout() OVERRIDE
;
29 virtual void ViewHierarchyChanged(
30 const ViewHierarchyChangedDetails
& details
) OVERRIDE
;
31 virtual void ButtonPressed(views::Button
* sender
,
32 const ui::Event
& event
) OVERRIDE
;
33 virtual int ContentMinimumWidth() const OVERRIDE
;
35 // views::MenuButtonListener:
36 virtual void OnMenuButtonClicked(views::View
* source
,
37 const gfx::Point
& point
) OVERRIDE
;
39 // The original and target language buttons can appear in either order, so
40 // this function provides a convenient way to just obtain the two in the
41 // correct visual order, as opposed to adding conditionals in multiple places.
42 void GetButtons(views::MenuButton
** first_button
,
43 views::MenuButton
** second_button
) const;
45 // Returns the width of all content other than the labels. Layout() uses this
46 // to determine how much space the labels can take.
47 int NonLabelWidth() const;
49 // The text displayed in the infobar is something like:
50 // "Translated from <lang1> to <lang2> [more text in some languages]"
51 // ...where <lang1> and <lang2> are comboboxes. So the text is split in 3
52 // chunks, each displayed in one of the labels below.
53 views::Label
* label_1_
;
54 views::Label
* label_2_
;
55 views::Label
* label_3_
;
57 views::MenuButton
* original_language_menu_button_
;
58 views::MenuButton
* target_language_menu_button_
;
59 views::LabelButton
* revert_button_
;
60 views::MenuButton
* options_menu_button_
;
62 scoped_ptr
<TranslateLanguageMenuModel
> original_language_menu_model_
;
63 scoped_ptr
<TranslateLanguageMenuModel
> target_language_menu_model_
;
64 scoped_ptr
<OptionsMenuModel
> options_menu_model_
;
66 // True if the target language comes before the original one.
67 bool swapped_language_buttons_
;
69 // True if the source language is expected to be determined by a server.
70 bool autodetermined_source_language_
;
72 DISALLOW_COPY_AND_ASSIGN(AfterTranslateInfoBar
);
75 #endif // CHROME_BROWSER_UI_VIEWS_INFOBARS_AFTER_TRANSLATE_INFOBAR_H_