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_STATUS_BUBBLE_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_BUBBLE_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/ui/status_bubble.h" | 14 #include "chrome/browser/ui/status_bubble.h" |
| 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
17 | 18 |
18 namespace gfx { | 19 namespace gfx { |
19 class Point; | 20 class Point; |
20 } | 21 } |
21 namespace views { | 22 namespace views { |
22 class View; | 23 class View; |
23 class Widget; | 24 class Widget; |
24 } | 25 } |
25 | 26 |
26 // StatusBubble displays a bubble of text that fades in, hovers over the | 27 // StatusBubble displays a bubble of text that fades in, hovers over the |
27 // browser chrome and fades away when not needed. It is primarily designed | 28 // browser chrome and fades away when not needed. It is primarily designed |
28 // to allow users to see where hovered links point to. | 29 // to allow users to see where hovered links point to. |
29 class StatusBubbleViews : public StatusBubble { | 30 class StatusBubbleViews : public StatusBubble { |
30 public: | 31 public: |
31 // How wide the bubble's shadow is. | 32 // How wide the bubble's shadow is. |
32 static const int kShadowThickness; | 33 static const int kShadowThickness; |
33 | 34 |
34 // The combined vertical padding above and below the text. | 35 // The combined vertical padding above and below the text. |
35 static const int kTotalVerticalPadding = 7; | 36 static const int kTotalVerticalPadding = 7; |
36 | 37 |
37 // |base_view| is the view that this bubble is positioned relative to. | 38 // |browser_view| created this object. |base_view| is the view that this |
38 explicit StatusBubbleViews(views::View* base_view); | 39 // bubble is positioned relative to. |
| 40 StatusBubbleViews(const BrowserView* browser_view, views::View* base_view); |
39 ~StatusBubbleViews() override; | 41 ~StatusBubbleViews() override; |
40 | 42 |
41 views::View* base_view() { return base_view_; } | 43 views::View* base_view() { return base_view_; } |
42 | 44 |
43 // Reposition the bubble's popup - as we are using a WS_POPUP for the bubble, | 45 // Reposition the bubble's popup - as we are using a WS_POPUP for the bubble, |
44 // we have to manually position it when the browser window moves. | 46 // we have to manually position it when the browser window moves. |
45 void RepositionPopup(); | 47 void RepositionPopup(); |
46 | 48 |
47 // The bubble only has a preferred height: the sum of the height of | 49 // The bubble only has a preferred height: the sum of the height of |
48 // the font and kTotalVerticalPadding. | 50 // the font and kTotalVerticalPadding. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Whether the view contains the mouse. | 121 // Whether the view contains the mouse. |
120 bool contains_mouse_; | 122 bool contains_mouse_; |
121 | 123 |
122 // How vertically offset the bubble is from its root position_. | 124 // How vertically offset the bubble is from its root position_. |
123 int offset_; | 125 int offset_; |
124 | 126 |
125 // We use a HWND for the popup so that it may float above any HWNDs in our | 127 // We use a HWND for the popup so that it may float above any HWNDs in our |
126 // UI (the location bar, for example). | 128 // UI (the location bar, for example). |
127 std::unique_ptr<views::Widget> popup_; | 129 std::unique_ptr<views::Widget> popup_; |
128 | 130 |
| 131 const BrowserView* browser_view_; |
129 views::View* base_view_; | 132 views::View* base_view_; |
130 StatusView* view_; | 133 StatusView* view_; |
131 | 134 |
132 // Manages the expansion of a status bubble to fit a long URL. | 135 // Manages the expansion of a status bubble to fit a long URL. |
133 std::unique_ptr<StatusViewExpander> expand_view_; | 136 std::unique_ptr<StatusViewExpander> expand_view_; |
134 | 137 |
135 // If the download shelf is visible, do not obscure it. | 138 // If the download shelf is visible, do not obscure it. |
136 bool download_shelf_is_visible_; | 139 bool download_shelf_is_visible_; |
137 | 140 |
138 // If the bubble has already been expanded, and encounters a new URL, | 141 // If the bubble has already been expanded, and encounters a new URL, |
139 // change size immediately, with no hover. | 142 // change size immediately, with no hover. |
140 bool is_expanded_; | 143 bool is_expanded_; |
141 | 144 |
142 // Times expansion of status bubble when URL is too long for standard width. | 145 // Times expansion of status bubble when URL is too long for standard width. |
143 base::WeakPtrFactory<StatusBubbleViews> expand_timer_factory_; | 146 base::WeakPtrFactory<StatusBubbleViews> expand_timer_factory_; |
144 | 147 |
145 DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); | 148 DISALLOW_COPY_AND_ASSIGN(StatusBubbleViews); |
146 }; | 149 }; |
147 | 150 |
148 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_BUBBLE_VIEWS_H_ | 151 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_BUBBLE_VIEWS_H_ |
OLD | NEW |