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/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 class ImageButton; | 29 class ImageButton; |
30 } // namespace views | 30 } // namespace views |
31 | 31 |
32 // View used to display the zoom percentage when it has changed. | 32 // View used to display the zoom percentage when it has changed. |
33 class ZoomBubbleView : public LocationBarBubbleDelegateView, | 33 class ZoomBubbleView : public LocationBarBubbleDelegateView, |
34 public views::ButtonListener, | 34 public views::ButtonListener, |
35 public ImmersiveModeController::Observer, | 35 public ImmersiveModeController::Observer, |
36 public extensions::IconImage::Observer { | 36 public extensions::IconImage::Observer { |
37 public: | 37 public: |
38 // Shows the bubble and automatically closes it after a short time period if | 38 // Shows the bubble and automatically closes it after a short time period if |
39 // |auto_close| is true. | 39 // |reason| is AUTOMATIC. |
40 static void ShowBubble(content::WebContents* web_contents, | 40 static void ShowBubble(content::WebContents* web_contents, |
41 bool auto_close); | 41 DisplayReason reason); |
42 | 42 |
43 // Closes the showing bubble (if one exists). | 43 // Closes the showing bubble (if one exists). |
44 static void CloseBubble(); | 44 static void CloseBubble(); |
45 | 45 |
46 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL | 46 // Returns the zoom bubble if the zoom bubble is showing. Returns NULL |
47 // otherwise. | 47 // otherwise. |
48 static ZoomBubbleView* GetZoomBubble(); | 48 static ZoomBubbleView* GetZoomBubble(); |
49 | 49 |
50 private: | 50 private: |
51 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen); | 51 FRIEND_TEST_ALL_PREFIXES(ZoomBubbleBrowserTest, ImmersiveFullscreen); |
(...skipping 12 matching lines...) Expand all Loading... |
64 // button in the zoom bubble. | 64 // button in the zoom bubble. |
65 std::string name; | 65 std::string name; |
66 | 66 |
67 // 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 |
68 // image button. | 68 // image button. |
69 scoped_ptr<const extensions::IconImage> icon_image; | 69 scoped_ptr<const extensions::IconImage> icon_image; |
70 }; | 70 }; |
71 | 71 |
72 ZoomBubbleView(views::View* anchor_view, | 72 ZoomBubbleView(views::View* anchor_view, |
73 content::WebContents* web_contents, | 73 content::WebContents* web_contents, |
74 bool auto_close, | 74 DisplayReason reason, |
75 ImmersiveModeController* immersive_mode_controller); | 75 ImmersiveModeController* immersive_mode_controller); |
76 ~ZoomBubbleView() override; | 76 ~ZoomBubbleView() override; |
77 | 77 |
78 // LocationBarBubbleDelegateView: | 78 // LocationBarBubbleDelegateView: |
79 void OnGestureEvent(ui::GestureEvent* event) override; | 79 void OnGestureEvent(ui::GestureEvent* event) override; |
80 void OnMouseEntered(const ui::MouseEvent& event) override; | 80 void OnMouseEntered(const ui::MouseEvent& event) override; |
81 void OnMouseExited(const ui::MouseEvent& event) override; | 81 void OnMouseExited(const ui::MouseEvent& event) override; |
82 void Init() override; | 82 void Init() override; |
83 void WindowClosing() override; | 83 void WindowClosing() override; |
84 void Close() override; | 84 void Close() override; |
(...skipping 23 matching lines...) Expand all Loading... |
108 // Stops the auto-close timer. | 108 // Stops the auto-close timer. |
109 void StopTimer(); | 109 void StopTimer(); |
110 | 110 |
111 ZoomBubbleExtensionInfo extension_info_; | 111 ZoomBubbleExtensionInfo extension_info_; |
112 | 112 |
113 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on | 113 // Singleton instance of the zoom bubble. The zoom bubble can only be shown on |
114 // the active browser window, so there is no case in which it will be shown | 114 // the active browser window, so there is no case in which it will be shown |
115 // twice at the same time. | 115 // twice at the same time. |
116 static ZoomBubbleView* zoom_bubble_; | 116 static ZoomBubbleView* zoom_bubble_; |
117 | 117 |
118 // Timer used to close the bubble when |auto_close_| is true. | 118 // Timer used to auto close the bubble. |
119 base::OneShotTimer timer_; | 119 base::OneShotTimer timer_; |
120 | 120 |
121 // Image button in the zoom bubble that will show the |extension_icon_| image | 121 // Image button in the zoom bubble that will show the |extension_icon_| image |
122 // if an extension initiated the zoom change, and links to that extension at | 122 // if an extension initiated the zoom change, and links to that extension at |
123 // "chrome://extensions". | 123 // "chrome://extensions". |
124 views::ImageButton* image_button_; | 124 views::ImageButton* image_button_; |
125 | 125 |
126 // Label displaying the zoom percentage. | 126 // Label displaying the zoom percentage. |
127 views::Label* label_; | 127 views::Label* label_; |
128 | 128 |
129 // The WebContents for the page whose zoom has changed. | 129 // The WebContents for the page whose zoom has changed. |
130 content::WebContents* web_contents_; | 130 content::WebContents* web_contents_; |
131 | 131 |
132 // Whether the currently displayed bubble will automatically close. | 132 // Whether the currently displayed bubble will automatically close. |
133 bool auto_close_; | 133 bool auto_close_; |
134 | 134 |
135 // The immersive mode controller for the BrowserView containing | 135 // The immersive mode controller for the BrowserView containing |
136 // |web_contents_|. | 136 // |web_contents_|. |
137 // Not owned. | 137 // Not owned. |
138 ImmersiveModeController* immersive_mode_controller_; | 138 ImmersiveModeController* immersive_mode_controller_; |
139 | 139 |
140 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); | 140 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); |
141 }; | 141 }; |
142 | 142 |
143 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ | 143 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_BUBBLE_VIEW_H_ |
OLD | NEW |