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_ZOOM_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // View used to display the zoom percentage when it has changed. | 27 // View used to display the zoom percentage when it has changed. |
28 class ZoomBubbleView : public LocationBarBubbleDelegateView, | 28 class ZoomBubbleView : public LocationBarBubbleDelegateView, |
29 public views::ButtonListener, | 29 public views::ButtonListener, |
30 public ImmersiveModeController::Observer, | 30 public ImmersiveModeController::Observer, |
31 public extensions::IconImage::Observer { | 31 public extensions::IconImage::Observer { |
32 public: | 32 public: |
33 // Shows the bubble and automatically closes it after a short time period if | 33 // Shows the bubble and automatically closes it after a short time period if |
34 // |reason| is AUTOMATIC. | 34 // |reason| is AUTOMATIC. |
35 static void ShowBubble(content::WebContents* web_contents, | 35 static void ShowBubble(content::WebContents* web_contents, |
| 36 const gfx::Point& anchor_point, |
36 DisplayReason reason); | 37 DisplayReason reason); |
37 | 38 |
38 // Closes the showing bubble (if one exists). | 39 // Closes the showing bubble (if one exists). |
39 static void CloseCurrentBubble(); | 40 static void CloseCurrentBubble(); |
40 | 41 |
41 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL | 42 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL |
42 // otherwise. | 43 // otherwise. |
43 static ZoomBubbleView* GetZoomBubble(); | 44 static ZoomBubbleView* GetZoomBubble(); |
44 | 45 |
| 46 // Refreshes the bubble by changing the zoom percentage appropriately and |
| 47 // resetting the timer if necessary. |
| 48 void Refresh(); |
| 49 |
45 private: | 50 private: |
46 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen); | 51 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen); |
47 | 52 |
48 // Stores information about the extension that initiated the zoom change, if | 53 // Stores information about the extension that initiated the zoom change, if |
49 // any. | 54 // any. |
50 struct ZoomBubbleExtensionInfo { | 55 struct ZoomBubbleExtensionInfo { |
51 ZoomBubbleExtensionInfo(); | 56 ZoomBubbleExtensionInfo(); |
52 ~ZoomBubbleExtensionInfo(); | 57 ~ZoomBubbleExtensionInfo(); |
53 | 58 |
54 // The unique id of the extension, which is used to find the correct | 59 // The unique id of the extension, which is used to find the correct |
55 // extension after clicking on the image button in the zoom bubble. | 60 // extension after clicking on the image button in the zoom bubble. |
56 std::string id; | 61 std::string id; |
57 | 62 |
58 // The name of the extension, which appears in the tooltip of the image | 63 // The name of the extension, which appears in the tooltip of the image |
59 // button in the zoom bubble. | 64 // button in the zoom bubble. |
60 std::string name; | 65 std::string name; |
61 | 66 |
62 // An image of the extension's icon, which appears in the zoom bubble as an | 67 // An image of the extension's icon, which appears in the zoom bubble as an |
63 // image button. | 68 // image button. |
64 std::unique_ptr<const extensions::IconImage> icon_image; | 69 std::unique_ptr<const extensions::IconImage> icon_image; |
65 }; | 70 }; |
66 | 71 |
| 72 // Constructs ZoomBubbleView. Anchors the bubble to |anchor_view| when it is |
| 73 // not nullptr or alternatively, to |anchor_point|. The bubble will auto-close |
| 74 // when |reason| is AUTOMATIC. If |immersive_mode_controller_| is present, the |
| 75 // bubble will auto-close when the top-of-window views are revealed. |
67 ZoomBubbleView(views::View* anchor_view, | 76 ZoomBubbleView(views::View* anchor_view, |
| 77 const gfx::Point& anchor_point, |
68 content::WebContents* web_contents, | 78 content::WebContents* web_contents, |
69 DisplayReason reason, | 79 DisplayReason reason, |
70 ImmersiveModeController* immersive_mode_controller); | 80 ImmersiveModeController* immersive_mode_controller); |
71 ~ZoomBubbleView() override; | 81 ~ZoomBubbleView() override; |
72 | 82 |
73 // LocationBarBubbleDelegateView: | 83 // LocationBarBubbleDelegateView: |
74 void OnGestureEvent(ui::GestureEvent* event) override; | 84 void OnGestureEvent(ui::GestureEvent* event) override; |
75 void OnMouseEntered(const ui::MouseEvent& event) override; | 85 void OnMouseEntered(const ui::MouseEvent& event) override; |
76 void OnMouseExited(const ui::MouseEvent& event) override; | 86 void OnMouseExited(const ui::MouseEvent& event) override; |
77 void Init() override; | 87 void Init() override; |
78 void WindowClosing() override; | 88 void WindowClosing() override; |
79 void CloseBubble() override; | 89 void CloseBubble() override; |
80 | 90 |
81 // views::ButtonListener: | 91 // views::ButtonListener: |
82 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 92 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
83 | 93 |
84 // ImmersiveModeController::Observer: | 94 // ImmersiveModeController::Observer: |
85 void OnImmersiveRevealStarted() override; | 95 void OnImmersiveRevealStarted() override; |
86 void OnImmersiveModeControllerDestroyed() override; | 96 void OnImmersiveModeControllerDestroyed() override; |
87 | 97 |
88 // extensions::IconImage::Observer: | 98 // extensions::IconImage::Observer: |
89 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | 99 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
90 | 100 |
91 // Refreshes the bubble by changing the zoom percentage appropriately and | |
92 // resetting the timer if necessary. | |
93 void Refresh(); | |
94 | |
95 // Sets information about the extension that initiated the zoom change. | 101 // Sets information about the extension that initiated the zoom change. |
96 // Calling this method asserts that the extension |extension| did initiate | 102 // Calling this method asserts that the extension |extension| did initiate |
97 // the zoom change. | 103 // the zoom change. |
98 void SetExtensionInfo(const extensions::Extension* extension); | 104 void SetExtensionInfo(const extensions::Extension* extension); |
99 | 105 |
100 // Starts a timer which will close the bubble if |auto_close_| is true. | 106 // Starts a timer which will close the bubble if |auto_close_| is true. |
101 void StartTimerIfNecessary(); | 107 void StartTimerIfNecessary(); |
102 | 108 |
103 // Stops the auto-close timer. | 109 // Stops the auto-close timer. |
104 void StopTimer(); | 110 void StopTimer(); |
(...skipping 24 matching lines...) Expand all Loading... |
129 | 135 |
130 // The immersive mode controller for the BrowserView containing | 136 // The immersive mode controller for the BrowserView containing |
131 // |web_contents_|. | 137 // |web_contents_|. |
132 // Not owned. | 138 // Not owned. |
133 ImmersiveModeController* immersive_mode_controller_; | 139 ImmersiveModeController* immersive_mode_controller_; |
134 | 140 |
135 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 141 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
136 }; | 142 }; |
137 | 143 |
138 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 144 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |