| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" | 9 #include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" |
| 10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/gfx/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
| 12 | 12 |
| 13 class LocationBarView; | 13 class LocationBarView; |
| 14 | 14 |
| 15 namespace ui { | |
| 16 class LocatedEvent; | |
| 17 } | |
| 18 | |
| 19 // Use a LocationIconView to display an icon on the leading side of the edit | 15 // Use a LocationIconView to display an icon on the leading side of the edit |
| 20 // field. It shows the user's current action (while the user is editing), or the | 16 // field. It shows the user's current action (while the user is editing), or the |
| 21 // page security status (after navigation has completed), or extension name (if | 17 // page security status (after navigation has completed), or extension name (if |
| 22 // the URL is a chrome-extension:// URL). | 18 // the URL is a chrome-extension:// URL). |
| 23 class LocationIconView : public IconLabelBubbleView, | 19 class LocationIconView : public IconLabelBubbleView { |
| 24 public gfx::AnimationDelegate { | |
| 25 public: | 20 public: |
| 26 LocationIconView(const gfx::FontList& font_list, | 21 LocationIconView(const gfx::FontList& font_list, |
| 27 LocationBarView* location_bar); | 22 LocationBarView* location_bar); |
| 28 ~LocationIconView() override; | 23 ~LocationIconView() override; |
| 29 | 24 |
| 30 // IconLabelBubbleView: | 25 // IconLabelBubbleView: |
| 31 gfx::Size GetMinimumSize() const override; | 26 gfx::Size GetMinimumSize() const override; |
| 32 bool OnMousePressed(const ui::MouseEvent& event) override; | 27 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 33 bool OnMouseDragged(const ui::MouseEvent& event) override; | 28 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 34 void OnMouseReleased(const ui::MouseEvent& event) override; | |
| 35 void OnGestureEvent(ui::GestureEvent* event) override; | |
| 36 bool GetTooltipText(const gfx::Point& p, | 29 bool GetTooltipText(const gfx::Point& p, |
| 37 base::string16* tooltip) const override; | 30 base::string16* tooltip) const override; |
| 38 SkColor GetTextColor() const override; | 31 SkColor GetTextColor() const override; |
| 39 bool OnActivate(const ui::Event& event) override; | 32 bool ShowBubble(const ui::Event& event) override; |
| 40 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 33 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 34 bool IsBubbleShown() const override; |
| 41 | 35 |
| 42 // Whether we should show the tooltip for this icon or not. | 36 // Whether we should show the tooltip for this icon or not. |
| 43 void set_show_tooltip(bool show_tooltip) { show_tooltip_ = show_tooltip; } | 37 void set_show_tooltip(bool show_tooltip) { show_tooltip_ = show_tooltip; } |
| 44 | 38 |
| 45 // Returns what the minimum size would be if the label text were |text|. | 39 // Returns what the minimum size would be if the label text were |text|. |
| 46 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; | 40 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; |
| 47 | 41 |
| 48 const gfx::FontList& GetFontList() const { return font_list(); } | 42 const gfx::FontList& GetFontList() const { return font_list(); } |
| 49 | 43 |
| 50 // Sets whether the text should be visible. |should_animate| controls whether | 44 // Sets whether the text should be visible. |should_animate| controls whether |
| 51 // any necessary transition to this state should be animated. | 45 // any necessary transition to this state should be animated. |
| 52 void SetTextVisibility(bool should_show, bool should_animate); | 46 void SetTextVisibility(bool should_show, bool should_animate); |
| 53 | 47 |
| 48 protected: |
| 49 // IconLabelBubbleView: |
| 50 bool IsTriggerableEvent(const ui::Event& event) override; |
| 51 |
| 54 private: | 52 private: |
| 55 // IconLabelBubbleView: | 53 // IconLabelBubbleView: |
| 56 double WidthMultiplier() const override; | 54 double WidthMultiplier() const override; |
| 57 | 55 |
| 58 // gfx::AnimationDelegate: | 56 // gfx::AnimationDelegate: |
| 59 void AnimationProgressed(const gfx::Animation*) override; | 57 void AnimationProgressed(const gfx::Animation*) override; |
| 60 | 58 |
| 61 void ProcessLocatedEvent(const ui::LocatedEvent& event); | |
| 62 | |
| 63 // Returns what the minimum size would be if the preferred size were |size|. | 59 // Returns what the minimum size would be if the preferred size were |size|. |
| 64 gfx::Size GetMinimumSizeForPreferredSize(gfx::Size size) const; | 60 gfx::Size GetMinimumSizeForPreferredSize(gfx::Size size) const; |
| 65 | 61 |
| 66 // Handles both click and gesture events by delegating to the page info | |
| 67 // helper in the appropriate circumstances. | |
| 68 void OnClickOrTap(const ui::LocatedEvent& event); | |
| 69 | |
| 70 // Set to true when the bubble is already showing at the time the icon is | |
| 71 // clicked. This suppresses re-showing the bubble on mouse release, so that | |
| 72 // clicking the icon repeatedly will appear to toggle the bubble on and off. | |
| 73 bool suppress_mouse_released_action_; | |
| 74 | |
| 75 // True if hovering this view should display a tooltip. | 62 // True if hovering this view should display a tooltip. |
| 76 bool show_tooltip_; | 63 bool show_tooltip_; |
| 77 | 64 |
| 78 LocationBarView* location_bar_; | 65 LocationBarView* location_bar_; |
| 79 gfx::SlideAnimation animation_; | 66 gfx::SlideAnimation animation_; |
| 80 | 67 |
| 81 DISALLOW_COPY_AND_ASSIGN(LocationIconView); | 68 DISALLOW_COPY_AND_ASSIGN(LocationIconView); |
| 82 }; | 69 }; |
| 83 | 70 |
| 84 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ | 71 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ |
| OLD | NEW |