Commit 694e2760 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Refactor to use AddChildView<T>, AddTab<T> and Tab::SetTitleText for translate bubble.

Bug: 974811
Change-Id: Ie7d2b0cffaa96a908b5c5a905b3e4e928452a436
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658651Reviewed-by: default avataranthonyvd <anthonyvd@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672244}
parent d32ce02f
...@@ -234,64 +234,58 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, ...@@ -234,64 +234,58 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView,
// Updates the visibilities of child views according to the current view type. // Updates the visibilities of child views according to the current view type.
void UpdateChildVisibilities(); void UpdateChildVisibilities();
// Creates the 'before translate' view for the existing Button UI. Caller // Creates the 'before translate' view.
// takes ownership of the returned view. std::unique_ptr<views::View> CreateViewBeforeTranslate();
views::View* CreateViewBeforeTranslate();
// Creates the view for TAB UI. This view is being used before/during/after // Creates the view for TAB UI. This view is being used before/during/after
// translate. // translate.
views::View* CreateViewTab(); std::unique_ptr<views::View> CreateViewTab();
// AddTab function requires a view element to be shown below each tab. // AddTab function requires a view element to be shown below each tab.
// This function creates an empty view so no extra white space below the tab. // This function creates an empty view so no extra white space below the tab.
std::unique_ptr<views::View> CreateEmptyPane(); std::unique_ptr<views::View> CreateEmptyPane();
// Creates the 'translating' view for the existing Button UI. Caller takes // Creates the 'translating' view.
// ownership of the returned view. std::unique_ptr<views::View> CreateViewTranslating();
views::View* CreateViewTranslating();
// Creates the 'after translate' view for the existing Button UI. Caller takes // Creates the 'after translate' view.
// ownership of the returned view. std::unique_ptr<views::View> CreateViewAfterTranslate();
views::View* CreateViewAfterTranslate();
// Creates the 'error' view. Caller takes ownership of the returned view. // Creates the 'error' view. Caller takes ownership of the returned view.
// Three options depending on UI selection in kUseButtonTranslateBubbleUI. // Three options depending on UI selection in kUseButtonTranslateBubbleUI.
views::View* CreateViewError(); std::unique_ptr<views::View> CreateViewError();
// Creates the 'advanced' view. Caller takes ownership of the returned view. // Creates the 'advanced' view. Caller takes ownership of the returned view.
// Three options depending on UI selection in kUseButtonTranslateBubbleUI. // Three options depending on UI selection in kUseButtonTranslateBubbleUI.
views::View* CreateViewAdvanced(); std::unique_ptr<views::View> CreateViewAdvanced();
// Creates source language label and combobox for Tab UI advanced view. // Creates source language label and combobox for Tab Ui advanced view
views::View* TabUiCreateViewAdvanedSource(); std::unique_ptr<views::View> TabUiCreateViewAdvanedSource();
// Creates source language label and combobox for Tab UI advanced view. // Creates source language label and combobox for Tab Ui advanced view
views::View* TabUiCreateViewAdvanedTarget(); std::unique_ptr<views::View> TabUiCreateViewAdvanedTarget();
// Creates the skeleton view for GM2 UI. // Creates the skeleton view for GM2 UI.
views::View* GM2CreateView( std::unique_ptr<views::View> GM2CreateView(
std::unique_ptr<views::Button> action_button, std::unique_ptr<views::Button> action_button,
std::unique_ptr<views::View> status_indicator, std::unique_ptr<views::View> status_indicator,
bool active_option_button, bool active_option_button,
std::unique_ptr<views::Label> source_language_label, std::unique_ptr<views::Label> source_language_label,
std::unique_ptr<views::Label> target_language_label); std::unique_ptr<views::Label> target_language_label);
// Creates the 'before translate' view for Button_GM2 UI. Caller takes // Creates the 'before translate' view for Button_GM2 UI.
// ownership of the returned view. std::unique_ptr<views::View> GM2CreateViewBeforeTranslate();
views::View* GM2CreateViewBeforeTranslate();
// Creates the 'translating' view for Button_GM2 UI. Caller takes ownership // Creates the 'translating' view for Button_GM2 UI.
// of the returned view. std::unique_ptr<views::View> GM2CreateViewTranslating();
views::View* GM2CreateViewTranslating();
// Creates the 'after translate' view for Button_GM2 UI. Caller takes // Creates the 'after translate' view for Button_GM2 UI.
// ownership of the returned view. std::unique_ptr<views::View> GM2CreateViewAfterTranslate();
views::View* GM2CreateViewAfterTranslate();
// Creates the 'advanced' view to show source/target language combobox under // Creates the 'advanced' view to show source/target language combobox under
// TAB UI. Caller takes ownership of the returned view. // TAB UI. Caller takes ownership of the returned view.
views::View* CreateViewAdvancedTabUi( std::unique_ptr<views::View> CreateViewAdvancedTabUi(
views::Combobox* combobox, std::unique_ptr<views::Combobox> combobox,
std::unique_ptr<views::Label> language_title_label); std::unique_ptr<views::Label> language_title_label);
// Get the current always translate checkbox // Get the current always translate checkbox
...@@ -317,41 +311,46 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, ...@@ -317,41 +311,46 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView,
// Handles the reset button in advanced view under Tab UI. // Handles the reset button in advanced view under Tab UI.
void ResetLanguage(); void ResetLanguage();
// Retrieve the names of the from/to languages and reset the language
// indices.
void UpdateLanguageNames(base::string16* original_language_name,
base::string16* target_language_name);
static TranslateBubbleView* translate_bubble_view_; static TranslateBubbleView* translate_bubble_view_;
views::View* before_translate_view_; views::View* before_translate_view_ = nullptr;
views::View* translating_view_; views::View* translating_view_ = nullptr;
views::View* after_translate_view_; views::View* after_translate_view_ = nullptr;
views::View* error_view_; views::View* error_view_ = nullptr;
views::View* advanced_view_; views::View* advanced_view_ = nullptr;
views::View* tab_translate_view_; views::View* tab_translate_view_ = nullptr;
views::View* advanced_view_source_; views::View* advanced_view_source_ = nullptr;
views::View* advanced_view_target_; views::View* advanced_view_target_ = nullptr;
std::unique_ptr<SourceLanguageComboboxModel> source_language_combobox_model_; std::unique_ptr<SourceLanguageComboboxModel> source_language_combobox_model_;
std::unique_ptr<TargetLanguageComboboxModel> target_language_combobox_model_; std::unique_ptr<TargetLanguageComboboxModel> target_language_combobox_model_;
views::Combobox* source_language_combobox_; views::Combobox* source_language_combobox_ = nullptr;
views::Combobox* target_language_combobox_; views::Combobox* target_language_combobox_ = nullptr;
views::Checkbox* before_always_translate_checkbox_; views::Checkbox* before_always_translate_checkbox_ = nullptr;
views::Checkbox* advanced_always_translate_checkbox_; views::Checkbox* advanced_always_translate_checkbox_ = nullptr;
views::TabbedPane* tabbed_pane_; views::TabbedPane* tabbed_pane_ = nullptr;
// Button_GM2 UI source/target language label class variable to be updated // Button_GM2 UI source/target language label class variable to be updated
// based on user selction in // based on user selction in
views::Label* gm2_source_language_label_; views::Label* gm2_source_language_label_ = nullptr;
views::Label* gm2_target_language_label_; views::Label* gm2_target_language_label_ = nullptr;
views::LabelButton* advanced_cancel_button_; views::LabelButton* advanced_cancel_button_ = nullptr;
views::LabelButton* advanced_done_button_; views::LabelButton* advanced_done_button_ = nullptr;
// Default source/target language without user interaction. // Default source/target language without user interaction.
int previous_source_language_index_; int previous_source_language_index_;
int previous_target_language_index_; int previous_target_language_index_;
// Used to trigger the options menu in tests. // Used to trigger the options menu in tests.
views::Button* before_translate_options_button_; views::Button* before_translate_options_button_ = nullptr;
std::unique_ptr<ui::SimpleMenuModel> options_menu_model_; std::unique_ptr<ui::SimpleMenuModel> options_menu_model_;
std::unique_ptr<views::MenuRunner> options_menu_runner_; std::unique_ptr<views::MenuRunner> options_menu_runner_;
...@@ -367,7 +366,7 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, ...@@ -367,7 +366,7 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView,
const language::TranslateUIBubbleModel bubble_ui_model_; const language::TranslateUIBubbleModel bubble_ui_model_;
bool should_always_translate_; bool should_always_translate_ = false;
std::unique_ptr<WebContentMouseHandler> mouse_handler_; std::unique_ptr<WebContentMouseHandler> mouse_handler_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment