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" | |
11 #include "ui/gfx/animation/slide_animation.h" | |
10 | 12 |
11 class LocationBarView; | 13 class LocationBarView; |
12 | 14 |
13 namespace ui { | 15 namespace ui { |
14 class KeyEvent; | 16 class KeyEvent; |
15 class LocatedEvent; | 17 class LocatedEvent; |
16 } | 18 } |
17 | 19 |
18 // Use a LocationIconView to display an icon on the leading side of the edit | 20 // Use a LocationIconView to display an icon on the leading side of the edit |
19 // field. It shows the user's current action (while the user is editing), or the | 21 // field. It shows the user's current action (while the user is editing), or the |
20 // page security status (after navigation has completed). | 22 // page security status (after navigation has completed). |
21 class LocationIconView : public IconLabelBubbleView { | 23 class LocationIconView : public IconLabelBubbleView, |
24 public gfx::AnimationDelegate { | |
22 public: | 25 public: |
23 LocationIconView(const gfx::FontList& font_list, | 26 LocationIconView(const gfx::FontList& font_list, |
24 SkColor parent_background_color, | 27 SkColor parent_background_color, |
25 LocationBarView* location_bar); | 28 LocationBarView* location_bar); |
26 ~LocationIconView() override; | 29 ~LocationIconView() override; |
27 | 30 |
28 // IconLabelBubbleView: | 31 // IconLabelBubbleView: |
29 gfx::Size GetMinimumSize() const override; | 32 gfx::Size GetMinimumSize() const override; |
30 bool OnMousePressed(const ui::MouseEvent& event) override; | 33 bool OnMousePressed(const ui::MouseEvent& event) override; |
31 bool OnMouseDragged(const ui::MouseEvent& event) override; | 34 bool OnMouseDragged(const ui::MouseEvent& event) override; |
(...skipping 10 matching lines...) Expand all Loading... | |
42 | 45 |
43 // Returns what the minimum size would be if the label text were |text|. | 46 // Returns what the minimum size would be if the label text were |text|. |
44 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; | 47 gfx::Size GetMinimumSizeForLabelText(const base::string16& text) const; |
45 | 48 |
46 const gfx::FontList& GetFontList() const { return font_list(); } | 49 const gfx::FontList& GetFontList() const { return font_list(); } |
47 | 50 |
48 // Set the background image. Pass false for |should_show_ev| for all non-EV | 51 // Set the background image. Pass false for |should_show_ev| for all non-EV |
49 // HTTPS contexts. | 52 // HTTPS contexts. |
50 void SetBackground(bool should_show_ev); | 53 void SetBackground(bool should_show_ev); |
51 | 54 |
55 void SetSecurityState(bool should_show, bool should_animate); | |
Peter Kasting
2016/08/30 01:12:42
Nit: I'd add a brief comment, e.g. "Sets whether t
Kevin Bailey
2016/08/30 14:07:15
Done.
| |
56 | |
52 private: | 57 private: |
58 // IconLabelBubbleView: | |
59 double WidthMultiplier() const override; | |
60 | |
61 // gfx::AnimationDelegate: | |
62 void AnimationProgressed(const gfx::Animation*) override; | |
63 | |
53 void ProcessLocatedEvent(const ui::LocatedEvent& event); | 64 void ProcessLocatedEvent(const ui::LocatedEvent& event); |
54 | 65 |
55 // Returns what the minimum size would be if the preferred size were |size|. | 66 // Returns what the minimum size would be if the preferred size were |size|. |
56 gfx::Size GetMinimumSizeForPreferredSize(gfx::Size size) const; | 67 gfx::Size GetMinimumSizeForPreferredSize(gfx::Size size) const; |
57 | 68 |
58 // Handles both click and gesture events by delegating to the page info | 69 // Handles both click and gesture events by delegating to the page info |
59 // helper in the appropriate circumstances. | 70 // helper in the appropriate circumstances. |
60 void OnClickOrTap(const ui::LocatedEvent& event); | 71 void OnClickOrTap(const ui::LocatedEvent& event); |
61 | 72 |
62 // Set to true when the bubble is already showing at the time the icon is | 73 // Set to true when the bubble is already showing at the time the icon is |
63 // clicked. This suppresses re-showing the bubble on mouse release, so that | 74 // clicked. This suppresses re-showing the bubble on mouse release, so that |
64 // clicking the icon repeatedly will appear to toggle the bubble on and off. | 75 // clicking the icon repeatedly will appear to toggle the bubble on and off. |
65 bool suppress_mouse_released_action_; | 76 bool suppress_mouse_released_action_; |
66 | 77 |
67 // True if hovering this view should display a tooltip. | 78 // True if hovering this view should display a tooltip. |
68 bool show_tooltip_; | 79 bool show_tooltip_; |
69 | 80 |
70 LocationBarView* location_bar_; | 81 LocationBarView* location_bar_; |
82 gfx::SlideAnimation animation_; | |
71 | 83 |
72 DISALLOW_COPY_AND_ASSIGN(LocationIconView); | 84 DISALLOW_COPY_AND_ASSIGN(LocationIconView); |
73 }; | 85 }; |
74 | 86 |
75 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ | 87 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_ICON_VIEW_H_ |
OLD | NEW |