OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/views/browser_bubble.h" | 5 #include "chrome/browser/ui/views/browser_bubble.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/frame/browser_view.h" | 7 #include "chrome/browser/ui/views/frame/browser_view.h" |
8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) |
9 #include "chrome/browser/external_tab_container_win.h" | 9 #include "chrome/browser/external_tab_container_win.h" |
10 #endif | 10 #endif |
11 #include "views/widget/root_view.h" | 11 #include "views/widget/root_view.h" |
12 #include "views/window/window.h" | 12 #include "views/window/window.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 BrowserBubbleHost* GetBubbleHostFromFrame(views::Widget* frame) { | 16 BrowserBubbleHost* GetBubbleHostFromFrame(views::Widget* frame) { |
17 if (!frame) | 17 if (!frame) |
18 return NULL; | 18 return NULL; |
19 | 19 |
20 BrowserBubbleHost* bubble_host = NULL; | 20 BrowserBubbleHost* bubble_host = NULL; |
21 views::Window* window = frame->GetWindow(); | 21 views::Window* window = frame->GetWindow(); |
22 if (window) { | 22 if (window) { |
23 bubble_host = BrowserView::GetBrowserViewForNativeWindow( | 23 bubble_host = BrowserView::GetBrowserViewForNativeWindow( |
24 window->GetNativeWindow()); | 24 window->GetNativeWindow()); |
25 DCHECK(bubble_host); | 25 DCHECK(bubble_host); |
26 } | 26 } |
27 #if defined(OS_WIN) | 27 |
28 // The frame may also be an ExternalTabContainer, which is also capable of | |
29 // hosting BrowserBubbles. | |
30 gfx::NativeView native_view = frame->GetNativeView(); | |
31 if (!bubble_host) { | |
32 bubble_host = | |
33 ExternalTabContainer::GetExternalContainerFromNativeWindow(native_view); | |
34 } | |
35 #endif | |
36 return bubble_host; | 28 return bubble_host; |
37 } | 29 } |
38 | 30 |
39 } // namespace | 31 } // namespace |
40 | 32 |
41 BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, | 33 BrowserBubble::BrowserBubble(views::View* view, views::Widget* frame, |
42 const gfx::Point& origin, bool drop_shadow) | 34 const gfx::Point& origin) |
43 : frame_(frame), | 35 : frame_(frame), |
44 view_(view), | 36 view_(view), |
45 visible_(false), | 37 visible_(false), |
46 delegate_(NULL), | 38 delegate_(NULL), |
47 attached_(false), | 39 attached_(false), |
48 drop_shadow_enabled_(drop_shadow), | |
49 bubble_host_(GetBubbleHostFromFrame(frame)) { | 40 bubble_host_(GetBubbleHostFromFrame(frame)) { |
50 gfx::Size size = view->GetPreferredSize(); | 41 gfx::Size size = view->GetPreferredSize(); |
51 bounds_.SetRect(origin.x(), origin.y(), size.width(), size.height()); | 42 bounds_.SetRect(origin.x(), origin.y(), size.width(), size.height()); |
52 InitPopup(); | 43 InitPopup(); |
53 } | 44 } |
54 | 45 |
55 BrowserBubble::~BrowserBubble() { | 46 BrowserBubble::~BrowserBubble() { |
56 DCHECK(!attached_); | 47 DCHECK(!attached_); |
57 popup_->Close(); | 48 popup_->Close(); |
58 | 49 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); | 108 views::View::ConvertPointToScreen(frame_->GetRootView(), &top_left); |
118 MovePopup(top_left.x() + bounds_.x(), | 109 MovePopup(top_left.x() + bounds_.x(), |
119 top_left.y() + bounds_.y(), | 110 top_left.y() + bounds_.y(), |
120 bounds_.width(), | 111 bounds_.width(), |
121 bounds_.height()); | 112 bounds_.height()); |
122 } | 113 } |
123 | 114 |
124 void BrowserBubble::ResizeToView() { | 115 void BrowserBubble::ResizeToView() { |
125 SetBounds(bounds_.x(), bounds_.y(), view_->width(), view_->height()); | 116 SetBounds(bounds_.x(), bounds_.y(), view_->width(), view_->height()); |
126 } | 117 } |
OLD | NEW |