Chromium Code Reviews| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 // when |reason| is AUTOMATIC. If |immersive_mode_controller_| is present, the | 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. | 75 // bubble will auto-close when the top-of-window views are revealed. |
| 76 ZoomBubbleView(views::View* anchor_view, | 76 ZoomBubbleView(views::View* anchor_view, |
| 77 const gfx::Point& anchor_point, | 77 const gfx::Point& anchor_point, |
| 78 content::WebContents* web_contents, | 78 content::WebContents* web_contents, |
| 79 DisplayReason reason, | 79 DisplayReason reason, |
| 80 ImmersiveModeController* immersive_mode_controller); | 80 ImmersiveModeController* immersive_mode_controller); |
| 81 ~ZoomBubbleView() override; | 81 ~ZoomBubbleView() override; |
| 82 | 82 |
| 83 // LocationBarBubbleDelegateView: | 83 // LocationBarBubbleDelegateView: |
| 84 gfx::Size GetPreferredSize() const override; | |
| 84 void OnGestureEvent(ui::GestureEvent* event) override; | 85 void OnGestureEvent(ui::GestureEvent* event) override; |
| 85 void OnMouseEntered(const ui::MouseEvent& event) override; | 86 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 86 void OnMouseExited(const ui::MouseEvent& event) override; | 87 void OnMouseExited(const ui::MouseEvent& event) override; |
| 87 void Init() override; | 88 void Init() override; |
| 88 void WindowClosing() override; | 89 void WindowClosing() override; |
| 89 void CloseBubble() override; | 90 void CloseBubble() override; |
| 91 bool ShouldSnapFrameWidth() const override; | |
| 90 | 92 |
| 91 // views::ButtonListener: | 93 // views::ButtonListener: |
| 92 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 94 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 93 | 95 |
| 94 // ImmersiveModeController::Observer: | 96 // ImmersiveModeController::Observer: |
| 95 void OnImmersiveRevealStarted() override; | 97 void OnImmersiveRevealStarted() override; |
| 96 void OnImmersiveModeControllerDestroyed() override; | 98 void OnImmersiveModeControllerDestroyed() override; |
| 97 | 99 |
| 98 // extensions::IconImage::Observer: | 100 // extensions::IconImage::Observer: |
| 99 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | 101 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
| 100 | 102 |
| 101 // Sets information about the extension that initiated the zoom change. | 103 // Sets information about the extension that initiated the zoom change. |
| 102 // Calling this method asserts that the extension |extension| did initiate | 104 // Calling this method asserts that the extension |extension| did initiate |
| 103 // the zoom change. | 105 // the zoom change. |
| 104 void SetExtensionInfo(const extensions::Extension* extension); | 106 void SetExtensionInfo(const extensions::Extension* extension); |
| 105 | 107 |
| 108 // Updates |label_| with the up to date zoom. | |
| 109 void UpdateZoomPercent(); | |
| 110 | |
| 106 // Starts a timer which will close the bubble if |auto_close_| is true. | 111 // Starts a timer which will close the bubble if |auto_close_| is true. |
| 107 void StartTimerIfNecessary(); | 112 void StartTimerIfNecessary(); |
| 108 | 113 |
| 109 // Stops the auto-close timer. | 114 // Stops the auto-close timer. |
| 110 void StopTimer(); | 115 void StopTimer(); |
| 111 | 116 |
| 112 ZoomBubbleExtensionInfo extension_info_; | 117 ZoomBubbleExtensionInfo extension_info_; |
| 113 | 118 |
| 114 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 119 // 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 | 120 // the active browser window, so there is no case in which it will be shown |
| 116 // twice at the same time. | 121 // twice at the same time. |
| 117 static ZoomBubbleView* zoom_bubble_; | 122 static ZoomBubbleView* zoom_bubble_; |
| 118 | 123 |
| 119 // Timer used to auto close the bubble. | 124 // Timer used to auto close the bubble. |
| 120 base::OneShotTimer timer_; | 125 base::OneShotTimer timer_; |
| 121 | 126 |
| 127 // Timer duration that is made longer if a user presses + or - buttons. | |
| 128 base::TimeDelta auto_close_duration_; | |
| 129 | |
| 122 // Image button in the zoom bubble that will show the |extension_icon_| image | 130 // 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 | 131 // if an extension initiated the zoom change, and links to that extension at |
| 124 // "chrome://extensions". | 132 // "chrome://extensions". |
| 125 views::ImageButton* image_button_; | 133 views::ImageButton* image_button_; |
| 126 | 134 |
| 127 // Label displaying the zoom percentage. | 135 // Label displaying the zoom percentage. |
| 128 views::Label* label_; | 136 views::Label* label_; |
| 129 | 137 |
| 138 // Action buttons that can change zoom. | |
| 139 views::Button* zoom_out_button_; | |
| 140 views::Button* zoom_in_button_; | |
| 141 views::Button* reset_button_; | |
| 142 | |
| 130 // The WebContents for the page whose zoom has changed. | 143 // The WebContents for the page whose zoom has changed. |
| 131 content::WebContents* web_contents_; | 144 content::WebContents* web_contents_; |
| 132 | 145 |
| 133 // Whether the currently displayed bubble will automatically close. | 146 // Whether the currently displayed bubble will automatically close. |
| 134 bool auto_close_; | 147 bool auto_close_; |
| 135 | 148 |
| 149 // True when handling a button click event. | |
|
Peter Kasting
2017/05/05 23:50:40
Nit: Maybe "Used to ignore close requests generate
varkha
2017/05/15 22:34:42
Done.
| |
| 150 bool ignore_close_bubble_; | |
| 151 | |
| 136 // The immersive mode controller for the BrowserView containing | 152 // The immersive mode controller for the BrowserView containing |
| 137 // |web_contents_|. | 153 // |web_contents_|. |
| 138 // Not owned. | 154 // Not owned. |
| 139 ImmersiveModeController* immersive_mode_controller_; | 155 ImmersiveModeController* immersive_mode_controller_; |
| 140 | 156 |
| 141 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 157 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
| 142 }; | 158 }; |
| 143 | 159 |
| 144 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 160 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
| OLD | NEW |