| 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 { | 15 namespace ui { |
| 16 class LocatedEvent; | 16 class LocatedEvent; |
| 17 } | 17 } |
| 18 | 18 |
| 19 // Use a LocationIconView to display an icon on the leading side of the edit | 19 // 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 | 20 // field. It shows the user's current action (while the user is editing), or the |
| 21 // page security status (after navigation has completed). | 21 // page security status (after navigation has completed), or extension name (if |
| 22 // the URL is a chrome-extension:// URL). |
| 22 class LocationIconView : public IconLabelBubbleView, | 23 class LocationIconView : public IconLabelBubbleView, |
| 23 public gfx::AnimationDelegate { | 24 public gfx::AnimationDelegate { |
| 24 public: | 25 public: |
| 25 LocationIconView(const gfx::FontList& font_list, | 26 LocationIconView(const gfx::FontList& font_list, |
| 26 LocationBarView* location_bar); | 27 LocationBarView* location_bar); |
| 27 ~LocationIconView() override; | 28 ~LocationIconView() override; |
| 28 | 29 |
| 29 // IconLabelBubbleView: | 30 // IconLabelBubbleView: |
| 30 gfx::Size GetMinimumSize() const override; | 31 gfx::Size GetMinimumSize() const override; |
| 31 bool OnMousePressed(const ui::MouseEvent& event) override; | 32 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 32 bool OnMouseDragged(const ui::MouseEvent& event) override; | 33 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 33 void OnMouseReleased(const ui::MouseEvent& event) override; | 34 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 34 void OnGestureEvent(ui::GestureEvent* event) override; | 35 void OnGestureEvent(ui::GestureEvent* event) override; |
| 35 bool GetTooltipText(const gfx::Point& p, | 36 bool GetTooltipText(const gfx::Point& p, |
| 36 base::string16* tooltip) const override; | 37 base::string16* tooltip) const override; |
| 37 SkColor GetTextColor() const override; | 38 SkColor GetTextColor() const override; |
| 38 bool OnActivate(const ui::Event& event) override; | 39 bool OnActivate(const ui::Event& event) override; |
| 39 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; | 40 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 40 | 41 |
| 41 // Whether we should show the tooltip for this icon or not. | 42 // Whether we should show the tooltip for this icon or not. |
| 42 void set_show_tooltip(bool show_tooltip) { show_tooltip_ = show_tooltip; } | 43 void set_show_tooltip(bool show_tooltip) { show_tooltip_ = show_tooltip; } |
| 43 | 44 |
| 44 // Returns what the minimum size would be if the label text were |text|. | 45 // Returns what the minimum size would be if the label text were |text|. |
| 45 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; | 46 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; |
| 46 | 47 |
| 47 const gfx::FontList& GetFontList() const { return font_list(); } | 48 const gfx::FontList& GetFontList() const { return font_list(); } |
| 48 | 49 |
| 49 // Sets whether the verbose security state text should be visible. | 50 // Sets whether the text should be visible. |should_animate| controls whether |
| 50 // |should_animate| controls whether any necessary transition to this state | 51 // any necessary transition to this state should be animated. |
| 51 // should be animated. | 52 void SetTextVisibility(bool should_show, bool should_animate); |
| 52 void SetSecurityState(bool should_show, bool should_animate); | |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // IconLabelBubbleView: | 55 // IconLabelBubbleView: |
| 56 double WidthMultiplier() const override; | 56 double WidthMultiplier() const override; |
| 57 | 57 |
| 58 // gfx::AnimationDelegate: | 58 // gfx::AnimationDelegate: |
| 59 void AnimationProgressed(const gfx::Animation*) override; | 59 void AnimationProgressed(const gfx::Animation*) override; |
| 60 | 60 |
| 61 void ProcessLocatedEvent(const ui::LocatedEvent& event); | 61 void ProcessLocatedEvent(const ui::LocatedEvent& event); |
| 62 | 62 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 75 // True if hovering this view should display a tooltip. | 75 // True if hovering this view should display a tooltip. |
| 76 bool show_tooltip_; | 76 bool show_tooltip_; |
| 77 | 77 |
| 78 LocationBarView* location_bar_; | 78 LocationBarView* location_bar_; |
| 79 gfx::SlideAnimation animation_; | 79 gfx::SlideAnimation animation_; |
| 80 | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(LocationIconView); | 81 DISALLOW_COPY_AND_ASSIGN(LocationIconView); |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ | 84 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ |
| OLD | NEW |