OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/browser_bubble.h" | 5 #include "chrome/browser/views/browser_bubble.h" |
6 | 6 |
7 #include "app/l10n_util_win.h" | 7 #include "app/l10n_util_win.h" |
8 #include "chrome/browser/views/frame/browser_view.h" | 8 #include "chrome/browser/views/frame/browser_view.h" |
9 #include "views/widget/widget_win.h" | 9 #include "views/widget/widget_win.h" |
10 #include "views/window/window.h" | |
10 | 11 |
11 void BrowserBubble::InitPopup() { | 12 void BrowserBubble::InitPopup() { |
12 gfx::NativeView native_view = frame_->GetNativeView(); | 13 gfx::NativeView native_view = frame_->GetNativeView(); |
14 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); | |
13 views::WidgetWin* pop = new views::WidgetWin(); | 15 views::WidgetWin* pop = new views::WidgetWin(); |
14 pop->set_delete_on_destroy(false); | 16 pop->set_delete_on_destroy(false); |
15 pop->set_window_style(WS_POPUP); | 17 pop->set_window_style(WS_POPUP); |
16 pop->set_window_ex_style(WS_EX_LAYERED | | 18 pop->set_window_ex_style(WS_EX_LAYERED | |
17 WS_EX_TOOLWINDOW | | 19 WS_EX_TOOLWINDOW | |
18 l10n_util::GetExtendedTooltipStyles()); | 20 l10n_util::GetExtendedTooltipStyles()); |
19 pop->SetOpacity(0xFF); | 21 pop->SetOpacity(0xFF); |
20 pop->Init(native_view, bounds_, false); | 22 pop->Init(native_view, bounds_, false); |
21 pop->SetContentsView(view_); | 23 pop->SetContentsView(view_); |
22 popup_.reset(pop); | 24 popup_.reset(pop); |
23 Reposition(); | 25 Reposition(); |
24 | 26 |
25 BrowserView* browser_view = | 27 BrowserView* browser_view = |
26 BrowserView::GetBrowserViewForNativeView(native_view); | 28 BrowserView::GetBrowserViewForNativeWindow(native_window); |
27 DCHECK(browser_view); | 29 DCHECK(browser_view); |
28 if (browser_view) | 30 if (browser_view) |
29 browser_view->AttachBrowserBubble(this); | 31 browser_view->AttachBrowserBubble(this); |
30 } | 32 } |
31 | 33 |
32 void BrowserBubble::DestroyPopup() { | 34 void BrowserBubble::DestroyPopup() { |
33 gfx::NativeView native_view = frame_->GetNativeView(); | 35 gfx::NativeView native_view = frame_->GetNativeView(); |
sky
2009/05/28 00:03:50
I don't think you need native_view here anymore.
| |
36 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); | |
34 BrowserView* browser_view = | 37 BrowserView* browser_view = |
35 BrowserView::GetBrowserViewForNativeView(native_view); | 38 BrowserView::GetBrowserViewForNativeWindow(native_window); |
36 if (browser_view) | 39 if (browser_view) |
37 browser_view->DetachBrowserBubble(this); | 40 browser_view->DetachBrowserBubble(this); |
38 } | 41 } |
39 | 42 |
40 void BrowserBubble::MovePopup(int x, int y, int w, int h) { | 43 void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
41 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 44 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
42 pop->MoveWindow(x, y, w, h); | 45 pop->MoveWindow(x, y, w, h); |
43 } | 46 } |
44 | 47 |
45 void BrowserBubble::Show() { | 48 void BrowserBubble::Show() { |
46 if (visible_) | 49 if (visible_) |
47 return; | 50 return; |
48 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 51 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
49 pop->Show(); | 52 pop->Show(); |
50 visible_ = true; | 53 visible_ = true; |
51 } | 54 } |
52 | 55 |
53 void BrowserBubble::Hide() { | 56 void BrowserBubble::Hide() { |
54 if (!visible_) | 57 if (!visible_) |
55 return; | 58 return; |
56 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 59 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
57 pop->Hide(); | 60 pop->Hide(); |
58 visible_ = false; | 61 visible_ = false; |
59 } | 62 } |
OLD | NEW |