Chromium Code Reviews| Index: chrome/browser/ui/views/translate/translate_bubble_view.h |
| diff --git a/chrome/browser/ui/views/translate/translate_bubble_view.h b/chrome/browser/ui/views/translate/translate_bubble_view.h |
| index d69f4ba113b7b11a0d65835f6a9d78b938ac09ea..59d4e67d8ded598b406d39e67a81449ca1cd7197 100644 |
| --- a/chrome/browser/ui/views/translate/translate_bubble_view.h |
| +++ b/chrome/browser/ui/views/translate/translate_bubble_view.h |
| @@ -10,6 +10,7 @@ |
| #include "base/gtest_prod_util.h" |
| #include "base/macros.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/translate/chrome_translate_client.h" |
| #include "chrome/browser/ui/translate/language_combobox_model.h" |
| #include "chrome/browser/ui/translate/translate_bubble_model.h" |
| @@ -17,19 +18,28 @@ |
| #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.h" |
| #include "components/translate/core/common/translate_errors.h" |
| #include "content/public/browser/web_contents_observer.h" |
| +#include "ui/base/models/simple_menu_model.h" |
| #include "ui/views/controls/button/button.h" |
| +#include "ui/views/controls/button/menu_button_listener.h" |
| #include "ui/views/controls/combobox/combobox_listener.h" |
| #include "ui/views/controls/link_listener.h" |
| +#include "ui/views/controls/menu/menu_runner.h" |
| +#include "ui/views/controls/styled_label_listener.h" |
| class Browser; |
| class PrefService; |
|
msw
2016/05/03 22:33:34
optional nit: Remove this; it's not used.
ftang
2016/05/03 23:55:42
Done.
|
| +namespace gfx { |
| +class Range; |
|
msw
2016/05/03 22:33:35
Remove this; it should be included via styled_labe
ftang
2016/05/03 23:55:42
Done.
|
| +} |
| + |
| namespace views { |
| class Checkbox; |
| class GridLayout; |
|
msw
2016/05/03 22:33:35
optional nit: Remove this; it's not used.
ftang
2016/05/03 23:55:42
Done.
|
| class LabelButton; |
| class Link; |
|
msw
2016/05/03 22:33:35
optional nit: Remove this; it should be included v
ftang
2016/05/03 23:55:42
Done.
|
| class View; |
| +class StyledLabel; |
|
msw
2016/05/03 22:33:35
Remove this; it should be included via styled_labe
ftang
2016/05/03 23:55:42
Done.
|
| } |
| namespace ui { |
| @@ -40,6 +50,9 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| public views::ButtonListener, |
| public views::ComboboxListener, |
| public views::LinkListener, |
| + public views::MenuButtonListener, |
| + public ui::SimpleMenuModel::Delegate, |
| + public views::StyledLabelListener, |
| public content::WebContentsObserver { |
| public: |
| // Commands shown in the action-style combobox. The value corresponds to the |
| @@ -51,6 +64,8 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| MENU_SIZE = 4, |
| }; |
| + enum DenialMenuItem { NEVER_TRANSLATE_LANGUAGE, NEVER_TRANSLATE_SITE }; |
|
msw
2016/05/03 22:33:35
nit: add a comment "// Item IDs for the denial but
ftang
2016/05/03 23:55:42
Done.
|
| + |
| ~TranslateBubbleView() override; |
| // Shows the Translate bubble. Returns the newly created bubble's Widget or |
| @@ -77,7 +92,8 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| void Init() override; |
| void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| - // views::WidgetDelegate method. |
| + // views::WidgetDelegate methods. |
| + bool ShouldShowCloseButton() const override; |
| void WindowClosing() override; |
| // views::View methods. |
| @@ -90,9 +106,29 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| // views::LinkListener method. |
| void LinkClicked(views::Link* source, int event_flags) override; |
| + // views::MenuButtonListener method. |
| + void OnMenuButtonClicked(views::MenuButton* source, |
| + const gfx::Point& point, |
| + const ui::Event* event) override; |
| + |
| + // ui::SimpleMenuModel::Delegate methods. |
| + bool IsCommandIdChecked(int command_id) const override; |
| + bool IsCommandIdEnabled(int command_id) const override; |
| + bool GetAcceleratorForCommandId(int command_id, |
| + ui::Accelerator* accelerator) override; |
| + void ExecuteCommand(int command_id, int event_flags) override; |
| + |
| + // views::StyledLabelListener method. |
| + void StyledLabelLinkClicked(views::StyledLabel* label, |
| + const gfx::Range& range, |
| + int event_flags) override; |
| + |
| // content::WebContentsObserver method. |
| void WebContentsDestroyed() override; |
| + // Overridden from views::WidgetObserver: |
| + void OnWidgetClosing(views::Widget* widget) override; |
| + |
| // Returns the current view state. |
| TranslateBubbleModel::ViewState GetViewState() const; |
| @@ -120,7 +156,10 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| friend class TranslateBubbleViewTest; |
| friend void ::translate::test_utils::PressTranslate(::Browser*); |
| FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, TranslateButton); |
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, TranslateButtonIn2016Q2UI); |
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, CloseButtonIn2016Q2UI); |
| FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, AdvancedLink); |
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, AdvancedLinkIn2016Q2UI); |
| FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, ShowOriginalButton); |
| FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, TryAgainButton); |
| FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, |
| @@ -183,6 +222,8 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| // Updates the advanced view. |
| void UpdateAdvancedView(); |
| + void ReportUiAction(int action); |
|
msw
2016/05/03 22:33:34
nit: add a comment "Logs metrics for the user's Tr
msw
2016/05/03 22:33:34
Pass |action| as a TranslateBubbleUiEvent, not an
ftang
2016/05/03 23:55:42
Done.
ftang
2016/05/03 23:55:42
Done.
|
| + |
| static TranslateBubbleView* translate_bubble_view_; |
| views::View* before_translate_view_; |
| @@ -204,6 +245,12 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| views::LabelButton* advanced_cancel_button_; |
| views::LabelButton* advanced_done_button_; |
| + views::MenuButton* denial_menu_button_; |
| + |
|
msw
2016/05/03 22:33:34
nit: remove blank line
ftang
2016/05/03 23:55:42
Done.
|
| + std::unique_ptr<ui::SimpleMenuModel> denial_menu_model_; |
| + |
|
msw
2016/05/03 22:33:34
nit: remove blank line
ftang
2016/05/03 23:55:42
Done.
|
| + std::unique_ptr<views::MenuRunner> denial_menu_runner_; |
| + |
| std::unique_ptr<TranslateBubbleModel> model_; |
| translate::TranslateErrors::Type error_type_; |
| @@ -211,8 +258,8 @@ class TranslateBubbleView : public LocationBarBubbleDelegateView, |
| // Whether the window is an incognito window. |
| const bool is_in_incognito_window_; |
| - // Whether the translation is acutually executed. |
| - bool translate_executed_; |
| + // Use the new (2016 Q2) translate UI. |
| + bool use_2016_q2_ui_; |
| DISALLOW_COPY_AND_ASSIGN(TranslateBubbleView); |
| }; |