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" |
11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 11 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
12 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h" | 12 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h" |
13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "extensions/browser/extension_icon_image.h" | 15 #include "extensions/browser/extension_icon_image.h" |
16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
17 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class WebContents; | 20 class WebContents; |
21 } | 21 } |
22 | 22 |
23 namespace gfx { | |
24 struct VectorIcon; | |
25 } | |
26 | |
23 namespace views { | 27 namespace views { |
24 class ImageButton; | 28 class ImageButton; |
25 } // namespace views | 29 } // namespace views |
26 | 30 |
27 // View used to display the zoom percentage when it has changed. | 31 // View used to display the zoom percentage when it has changed. |
28 class ZoomBubbleView : public LocationBarBubbleDelegateView, | 32 class ZoomBubbleView : public LocationBarBubbleDelegateView, |
29 public views::ButtonListener, | 33 public views::ButtonListener, |
30 public ImmersiveModeController::Observer, | 34 public ImmersiveModeController::Observer, |
31 public extensions::IconImage::Observer { | 35 public extensions::IconImage::Observer { |
32 public: | 36 public: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 ImmersiveModeController* immersive_mode_controller); | 84 ImmersiveModeController* immersive_mode_controller); |
81 ~ZoomBubbleView() override; | 85 ~ZoomBubbleView() override; |
82 | 86 |
83 // LocationBarBubbleDelegateView: | 87 // LocationBarBubbleDelegateView: |
84 void OnGestureEvent(ui::GestureEvent* event) override; | 88 void OnGestureEvent(ui::GestureEvent* event) override; |
85 void OnMouseEntered(const ui::MouseEvent& event) override; | 89 void OnMouseEntered(const ui::MouseEvent& event) override; |
86 void OnMouseExited(const ui::MouseEvent& event) override; | 90 void OnMouseExited(const ui::MouseEvent& event) override; |
87 void Init() override; | 91 void Init() override; |
88 void WindowClosing() override; | 92 void WindowClosing() override; |
89 void CloseBubble() override; | 93 void CloseBubble() override; |
94 bool ShouldSnapFrameWidth() const override; | |
95 gfx::Size GetPreferredSize() const override; | |
tapted
2017/05/02 01:28:02
nit: GetPreferredSize() comes from views::View, so
varkha
2017/05/03 01:50:28
Done.
| |
90 | 96 |
91 // views::ButtonListener: | 97 // views::ButtonListener: |
92 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 98 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
93 | 99 |
94 // ImmersiveModeController::Observer: | 100 // ImmersiveModeController::Observer: |
95 void OnImmersiveRevealStarted() override; | 101 void OnImmersiveRevealStarted() override; |
96 void OnImmersiveModeControllerDestroyed() override; | 102 void OnImmersiveModeControllerDestroyed() override; |
97 | 103 |
98 // extensions::IconImage::Observer: | 104 // extensions::IconImage::Observer: |
99 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | 105 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
100 | 106 |
101 // Sets information about the extension that initiated the zoom change. | 107 // Sets information about the extension that initiated the zoom change. |
102 // Calling this method asserts that the extension |extension| did initiate | 108 // Calling this method asserts that the extension |extension| did initiate |
103 // the zoom change. | 109 // the zoom change. |
104 void SetExtensionInfo(const extensions::Extension* extension); | 110 void SetExtensionInfo(const extensions::Extension* extension); |
105 | 111 |
112 // Creates an ImageButton using vector |icon|, sets a tooltip with | |
113 // |tooltip_id|. Returns the button. | |
114 std::unique_ptr<views::Button> CreateZoomButton(const gfx::VectorIcon& icon, | |
tapted
2017/05/02 01:28:02
This doesn't manipulate any members - can it be pu
varkha
2017/05/03 01:50:28
Done.
| |
115 int tooltip_id); | |
116 | |
117 // Updates |label_| with the up to date zoom. | |
118 void UpdateZoomPercent(); | |
119 | |
106 // Starts a timer which will close the bubble if |auto_close_| is true. | 120 // Starts a timer which will close the bubble if |auto_close_| is true. |
107 void StartTimerIfNecessary(); | 121 void StartTimerIfNecessary(); |
108 | 122 |
109 // Stops the auto-close timer. | 123 // Stops the auto-close timer. |
110 void StopTimer(); | 124 void StopTimer(); |
111 | 125 |
112 ZoomBubbleExtensionInfo extension_info_; | 126 ZoomBubbleExtensionInfo extension_info_; |
113 | 127 |
114 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 128 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on |
115 // the active browser window, so there is no case in which it will be shown | 129 // the active browser window, so there is no case in which it will be shown |
116 // twice at the same time. | 130 // twice at the same time. |
117 static ZoomBubbleView* zoom_bubble_; | 131 static ZoomBubbleView* zoom_bubble_; |
118 | 132 |
119 // Timer used to auto close the bubble. | 133 // Timer used to auto close the bubble. |
120 base::OneShotTimer timer_; | 134 base::OneShotTimer timer_; |
121 | 135 |
136 // Timer duration that is made longer if a user presses + or - buttons. | |
137 int timer_duration_; | |
tapted
2017/05/02 01:28:02
Add units? (e.g. timer_duration_ms_), or use a bas
varkha
2017/05/03 01:50:28
I like the self documenting base::TimeDelta consts
| |
138 | |
122 // Image button in the zoom bubble that will show the |extension_icon_| image | 139 // Image button in the zoom bubble that will show the |extension_icon_| image |
123 // if an extension initiated the zoom change, and links to that extension at | 140 // if an extension initiated the zoom change, and links to that extension at |
124 // "chrome://extensions". | 141 // "chrome://extensions". |
125 views::ImageButton* image_button_; | 142 views::ImageButton* image_button_; |
126 | 143 |
127 // Label displaying the zoom percentage. | 144 // Label displaying the zoom percentage. |
128 views::Label* label_; | 145 views::Label* label_; |
129 | 146 |
147 // Action buttons that can change zoom. | |
148 views::Button* zoom_out_button_; | |
149 views::Button* zoom_in_button_; | |
150 views::Button* reset_button_; | |
151 | |
130 // The WebContents for the page whose zoom has changed. | 152 // The WebContents for the page whose zoom has changed. |
131 content::WebContents* web_contents_; | 153 content::WebContents* web_contents_; |
132 | 154 |
133 // Whether the currently displayed bubble will automatically close. | 155 // Whether the currently displayed bubble will automatically close. |
134 bool auto_close_; | 156 bool auto_close_; |
135 | 157 |
158 // True when handling a button click event. | |
159 bool ignore_close_bubble_; | |
160 | |
136 // The immersive mode controller for the BrowserView containing | 161 // The immersive mode controller for the BrowserView containing |
137 // |web_contents_|. | 162 // |web_contents_|. |
138 // Not owned. | 163 // Not owned. |
139 ImmersiveModeController* immersive_mode_controller_; | 164 ImmersiveModeController* immersive_mode_controller_; |
140 | 165 |
141 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 166 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
142 }; | 167 }; |
143 | 168 |
144 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 169 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |