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 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 // BubbleView anchoring to |anchor_view| or |anchor_point| as available. | |
|
msw
2017/04/24 18:53:39
nit: "The bubble will anchor to |anchor_view| or |
varkha
2017/04/26 04:52:59
Ouch, looks like some errant keystroke has erased
| |
| 67 ZoomBubbleView(views::View* anchor_view, | 73 ZoomBubbleView(views::View* anchor_view, |
| 74 const gfx::Point& anchor_point, | |
| 68 content::WebContents* web_contents, | 75 content::WebContents* web_contents, |
| 69 DisplayReason reason, | 76 DisplayReason reason, |
| 70 ImmersiveModeController* immersive_mode_controller); | 77 ImmersiveModeController* immersive_mode_controller); |
| 71 ~ZoomBubbleView() override; | 78 ~ZoomBubbleView() override; |
| 72 | 79 |
| 73 // LocationBarBubbleDelegateView: | 80 // LocationBarBubbleDelegateView: |
| 74 void OnGestureEvent(ui::GestureEvent* event) override; | 81 void OnGestureEvent(ui::GestureEvent* event) override; |
| 75 void OnMouseEntered(const ui::MouseEvent& event) override; | 82 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 76 void OnMouseExited(const ui::MouseEvent& event) override; | 83 void OnMouseExited(const ui::MouseEvent& event) override; |
| 77 void Init() override; | 84 void Init() override; |
| 78 void WindowClosing() override; | 85 void WindowClosing() override; |
| 79 void CloseBubble() override; | 86 void CloseBubble() override; |
| 80 | 87 |
| 81 // views::ButtonListener: | 88 // views::ButtonListener: |
| 82 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 89 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 83 | 90 |
| 84 // ImmersiveModeController::Observer: | 91 // ImmersiveModeController::Observer: |
| 85 void OnImmersiveRevealStarted() override; | 92 void OnImmersiveRevealStarted() override; |
| 86 void OnImmersiveModeControllerDestroyed() override; | 93 void OnImmersiveModeControllerDestroyed() override; |
| 87 | 94 |
| 88 // extensions::IconImage::Observer: | 95 // extensions::IconImage::Observer: |
| 89 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; | 96 void OnExtensionIconImageChanged(extensions::IconImage* /* image */) override; |
| 90 | 97 |
| 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. | 98 // Sets information about the extension that initiated the zoom change. |
| 96 // Calling this method asserts that the extension |extension| did initiate | 99 // Calling this method asserts that the extension |extension| did initiate |
| 97 // the zoom change. | 100 // the zoom change. |
| 98 void SetExtensionInfo(const extensions::Extension* extension); | 101 void SetExtensionInfo(const extensions::Extension* extension); |
| 99 | 102 |
| 100 // Starts a timer which will close the bubble if |auto_close_| is true. | 103 // Starts a timer which will close the bubble if |auto_close_| is true. |
| 101 void StartTimerIfNecessary(); | 104 void StartTimerIfNecessary(); |
| 102 | 105 |
| 103 // Stops the auto-close timer. | 106 // Stops the auto-close timer. |
| 104 void StopTimer(); | 107 void StopTimer(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 129 | 132 |
| 130 // The immersive mode controller for the BrowserView containing | 133 // The immersive mode controller for the BrowserView containing |
| 131 // |web_contents_|. | 134 // |web_contents_|. |
| 132 // Not owned. | 135 // Not owned. |
| 133 ImmersiveModeController* immersive_mode_controller_; | 136 ImmersiveModeController* immersive_mode_controller_; |
| 134 | 137 |
| 135 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 138 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
| 136 }; | 139 }; |
| 137 | 140 |
| 138 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 141 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
| OLD | NEW |