| Index: chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
|
| diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
|
| index 7b5d37e0dfeb9b652ca2ef4b191108c954cc60d9..ff254346a6ee9c8da02a5453943bde41b5308e6a 100644
|
| --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
|
| +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.h
|
| @@ -12,29 +12,35 @@
|
| #include "ui/gfx/geometry/insets.h"
|
| #include "ui/gfx/geometry/size.h"
|
| #include "ui/views/animation/ink_drop_host_view.h"
|
| +#include "ui/views/animation/ink_drop_observer.h"
|
| #include "ui/views/controls/label.h"
|
| +#include "ui/views/widget/widget_observer.h"
|
|
|
| namespace gfx {
|
| -class Canvas;
|
| class FontList;
|
| class ImageSkia;
|
| }
|
|
|
| namespace views {
|
| class ImageView;
|
| -class Label;
|
| +class InkDropContainerView;
|
| }
|
|
|
| // View used to draw a bubble, containing an icon and a label. We use this as a
|
| // base for the classes that handle the location icon (including the EV bubble),
|
| // tab-to-search UI, and content settings.
|
| -class IconLabelBubbleView : public views::InkDropHostView {
|
| +class IconLabelBubbleView : public views::InkDropHostView,
|
| + public views::InkDropObserver,
|
| + public views::WidgetObserver {
|
| public:
|
| static constexpr int kTrailingPaddingPreMd = 2;
|
|
|
| IconLabelBubbleView(const gfx::FontList& font_list, bool elide_in_middle);
|
| ~IconLabelBubbleView() override;
|
|
|
| + // InkDropObserver:
|
| + void AnimationStarted() override;
|
| +
|
| void SetLabel(const base::string16& label);
|
| void SetImage(const gfx::ImageSkia& image);
|
|
|
| @@ -71,19 +77,34 @@ class IconLabelBubbleView : public views::InkDropHostView {
|
| // true if some handling was performed.
|
| virtual bool OnActivate(const ui::Event& event);
|
|
|
| + // Returns true if the bubble anchored to the icon is shown. This is to
|
| + // prevent the bubble from reshowing on a mouse release.
|
| + virtual bool IsBubbleShown() const;
|
| +
|
| + // Returns true if the user can click on the icon.
|
| + virtual bool CanClick() const;
|
| +
|
| // views::InkDropHostView:
|
| gfx::Size GetPreferredSize() const override;
|
| void Layout() override;
|
| + bool OnMousePressed(const ui::MouseEvent& event) override;
|
| + void OnMouseReleased(const ui::MouseEvent& event) override;
|
| bool OnKeyPressed(const ui::KeyEvent& event) override;
|
| bool OnKeyReleased(const ui::KeyEvent& event) override;
|
| void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
|
| void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override;
|
| void AddInkDropLayer(ui::Layer* ink_drop_layer) override;
|
| void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override;
|
| + std::unique_ptr<views::InkDrop> CreateInkDrop() override;
|
| std::unique_ptr<views::InkDropHighlight> CreateInkDropHighlight()
|
| const override;
|
| + std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
|
| SkColor GetInkDropBaseColor() const override;
|
|
|
| + // views::WidgetObserver:
|
| + void OnWidgetDestroying(views::Widget* widget) override;
|
| + void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
|
| +
|
| const gfx::FontList& font_list() const { return label_->font_list(); }
|
|
|
| SkColor GetParentBackgroundColor() const;
|
| @@ -91,6 +112,23 @@ class IconLabelBubbleView : public views::InkDropHostView {
|
| gfx::Size GetSizeForLabelWidth(int label_width) const;
|
|
|
| private:
|
| + // A view that draws the separator.
|
| + class SeparatorView : public views::View {
|
| + public:
|
| + explicit SeparatorView(IconLabelBubbleView* owner);
|
| +
|
| + // View:
|
| + void OnPaint(gfx::Canvas* canvas) override;
|
| + bool CanProcessEventsWithinSubtree() const override;
|
| +
|
| + // Updates the opacity based on the ink drop's state.
|
| + void UpdateOpacity();
|
| +
|
| + private:
|
| + // Weak.
|
| + IconLabelBubbleView* owner_;
|
| + };
|
| +
|
| // Amount of padding from the leading edge of the view to the leading edge of
|
| // the image, and from the trailing edge of the label (or image, if the label
|
| // is invisible) to the trailing edge of the view.
|
| @@ -106,17 +144,23 @@ class IconLabelBubbleView : public views::InkDropHostView {
|
|
|
| // views::View:
|
| const char* GetClassName() const override;
|
| - void OnPaint(gfx::Canvas* canvas) override;
|
|
|
| // The contents of the bubble.
|
| views::ImageView* image_;
|
| views::Label* label_;
|
| + views::InkDropContainerView* ink_drop_container_;
|
| + std::unique_ptr<SeparatorView> separator_view_;
|
|
|
| // The padding of the element that will be displayed after |this|. This value
|
| // is relevant for calculating the amount of space to reserve after the
|
| // separator.
|
| int next_element_interior_padding_ = 0;
|
|
|
| + // This is used to check if the bubble was showing during the mouse pressed
|
| + // event. If this is true then the mouse released event is ignored to prevent
|
| + // the bubble from reshowing.
|
| + bool suppress_mouse_released_action_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(IconLabelBubbleView);
|
| };
|
|
|
|
|