| 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
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..58b8220e911b23755e3104578ab7086c797b35f3
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/translate/translate_bubble_view.h
|
| @@ -0,0 +1,175 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_UI_VIEWS_TRANSLATE_TRANSLATE_BUBBLE_VIEW_H_
|
| +#define CHROME_BROWSER_UI_VIEWS_TRANSLATE_TRANSLATE_BUBBLE_VIEW_H_
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "chrome/browser/ui/translate/language_combobox_model.h"
|
| +#include "chrome/browser/ui/translate/translate_bubble_model.h"
|
| +#include "ui/views/bubble/bubble_delegate.h"
|
| +#include "ui/views/controls/button/button.h"
|
| +#include "ui/views/controls/combobox/combobox_listener.h"
|
| +#include "ui/views/controls/link_listener.h"
|
| +
|
| +class Browser;
|
| +class PrefService;
|
| +class TranslateBubbleModel;
|
| +
|
| +namespace content {
|
| +class WebContents;
|
| +}
|
| +
|
| +namespace views {
|
| +class Checkbox;
|
| +class GridLayout;
|
| +class LabelButton;
|
| +class Link;
|
| +class View;
|
| +}
|
| +
|
| +class TranslateBubbleView : public views::BubbleDelegateView,
|
| + public views::ButtonListener,
|
| + public views::ComboboxListener,
|
| + public views::LinkListener {
|
| + public:
|
| + // Shows the Translate bubble.
|
| + static void ShowBubble(views::View* anchor_view,
|
| + content::WebContents* web_contents,
|
| + TranslateBubbleModel::ViewType type,
|
| + Browser* browser);
|
| +
|
| + // If true, the Translate bubble is being shown.
|
| + static bool IsShowing();
|
| +
|
| + virtual ~TranslateBubbleView();
|
| +
|
| + TranslateBubbleView(views::View* anchor_view,
|
| + scoped_ptr<TranslateBubbleModel> model,
|
| + TranslateBubbleModel::ViewType type,
|
| + bool is_in_incognito_window,
|
| + Browser* browser);
|
| +
|
| + // views::BubbleDelegateView methods.
|
| + virtual void Init() OVERRIDE;
|
| + virtual void ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) OVERRIDE;
|
| +
|
| + // views::WidgetDelegate method.
|
| + virtual void WindowClosing() OVERRIDE;
|
| +
|
| + // views::View methods.
|
| + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
|
| + virtual gfx::Size GetPreferredSize() OVERRIDE;
|
| +
|
| + // views::CombboxListener method.
|
| + virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
|
| +
|
| + // views::LinkListener method.
|
| + virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
|
| +
|
| + private:
|
| + enum {
|
| + LINK_ID_ADVANCED,
|
| + LINK_ID_LEARN_MORE,
|
| + };
|
| +
|
| + enum {
|
| + BUTTON_ID_TRANSLATE,
|
| + BUTTON_ID_DONE,
|
| + BUTTON_ID_CANCEL,
|
| + BUTTON_ID_SHOW_ORIGINAL,
|
| + BUTTON_ID_TRY_AGAIN,
|
| + BUTTON_ID_ALWAYS_TRANSLATE,
|
| + };
|
| +
|
| + enum {
|
| + COMBOBOX_ID_DENIAL,
|
| + COMBOBOX_ID_SOURCE_LANGUAGE,
|
| + COMBOBOX_ID_TARGET_LANGUAGE,
|
| + };
|
| +
|
| + friend class TranslateBubbleViewTest;
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, TranslateButton);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, AdvancedLink);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, ShowOriginalButton);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, TryAgainButton);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, AlwaysTranslateCheckbox);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, DoneButton);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest,
|
| + CancelButtonReturningBeforeTranslate);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest,
|
| + CancelButtonReturningAfterTranslate);
|
| + FRIEND_TEST_ALL_PREFIXES(TranslateBubbleViewTest, CancelButtonReturningError);
|
| +
|
| + // Handles the event when the user presses a button.
|
| + void HandleButtonPressed(int sender_id);
|
| +
|
| + // Handles the event when the user clicks a link.
|
| + void HandleLinkClicked(int sender_id);
|
| +
|
| + // Switches the view according to |type|.
|
| + void SwitchView(TranslateBubbleModel::ViewType type);
|
| +
|
| + // Updates the visibilities of child views according to the current
|
| + // |view_type_|. Contrary to SwitchView, this doesn't change anything but
|
| + // the visibilities.
|
| + void UpdateChildVisibilities();
|
| +
|
| + // Creates the 'before translate' view. Caller takes ownership of the returned
|
| + // view.
|
| + views::View* CreateViewBeforeTranslate();
|
| +
|
| + // Creates the 'translating' view. Caller takes ownership of the returned
|
| + // view.
|
| + views::View* CreateViewTranslating();
|
| +
|
| + // Creates the 'after translate' view. Caller takes ownership of the returned
|
| + // view.
|
| + views::View* CreateViewAfterTranslate();
|
| +
|
| + // Creates the 'error' view. Caller takes ownership of the returned view.
|
| + views::View* CreateViewError();
|
| +
|
| + // Creates the 'advanced' view. Caller takes ownership of the returned view.
|
| + views::View* CreateViewAdvanced();
|
| +
|
| + // Updates the advanced view.
|
| + void UpdateAdvancedView();
|
| +
|
| + static TranslateBubbleView* translate_bubble_view_;
|
| +
|
| + scoped_ptr<LanguageComboboxModel> source_language_combobox_model_;
|
| + scoped_ptr<LanguageComboboxModel> target_language_combobox_model_;
|
| +
|
| + views::Combobox* source_language_combobox_;
|
| + views::Combobox* target_language_combobox_;
|
| + views::Checkbox* always_translate_checkbox_;
|
| +
|
| + scoped_ptr<TranslateBubbleModel> model_;
|
| +
|
| + // The view type
|
| + TranslateBubbleModel::ViewType view_type_;
|
| +
|
| + // The view type. When the current view type is not 'Advanced' view, this is
|
| + // equivalent to |view_type_|. Otherwise, this is the previous view type
|
| + // before the user opens the 'Advanced' view. This is used to navigate when
|
| + // pressing 'Cancel' button on the 'Advanced' view.
|
| + TranslateBubbleModel::ViewType view_type_before_advanced_view_;
|
| +
|
| + // Whether the window is an incognito window.
|
| + bool is_in_incognito_window_;
|
| +
|
| + // The browser to open the help URL into a new tab.
|
| + Browser* browser_;
|
| +
|
| + // Whether the translation is acutually executed.
|
| + bool translate_executed_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(TranslateBubbleView);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_UI_VIEWS_TRANSLATE_TRANSLATE_BUBBLE_VIEW_H_
|
|
|