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 #include "views/window/window.h" |
11 | 11 |
12 void BrowserBubble::InitPopup() { | 12 void BrowserBubble::InitPopup() { |
13 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); | 13 gfx::NativeWindow native_window = frame_->GetWindow()->GetNativeWindow(); |
14 views::WidgetWin* pop = new views::WidgetWin(); | 14 views::WidgetWin* pop = new views::WidgetWin(); |
15 pop->set_delete_on_destroy(false); | |
16 pop->set_window_style(WS_POPUP); | 15 pop->set_window_style(WS_POPUP); |
| 16 |
17 #if 0 | 17 #if 0 |
18 // TODO(erikkay) Layered windows don't draw child windows. | 18 // TODO(erikkay) Layered windows don't draw child windows. |
19 // Apparently there's some tricks you can do to handle that. | 19 // Apparently there's some tricks you can do to handle that. |
20 // Do the research so we can use this. | 20 // Do the research so we can use this. |
21 pop->set_window_ex_style(WS_EX_LAYERED | | 21 pop->set_window_ex_style(WS_EX_LAYERED | |
22 l10n_util::GetExtendedTooltipStyles()); | 22 l10n_util::GetExtendedTooltipStyles()); |
23 pop->SetOpacity(0xFF); | 23 pop->SetOpacity(0xFF); |
24 #endif | 24 #endif |
| 25 |
25 // A focus manager is necessary if you want to be able to handle various | 26 // A focus manager is necessary if you want to be able to handle various |
26 // mouse events properly. | 27 // mouse events properly. |
27 pop->Init(frame_native_view_, bounds_); | 28 pop->Init(frame_native_view_, bounds_); |
28 pop->SetContentsView(view_); | 29 pop->SetContentsView(view_); |
29 popup_.reset(pop); | 30 |
| 31 popup_ = pop; |
30 Reposition(); | 32 Reposition(); |
31 | |
32 AttachToBrowser(); | 33 AttachToBrowser(); |
33 } | 34 } |
34 | 35 |
35 void BrowserBubble::MovePopup(int x, int y, int w, int h) { | 36 void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
36 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 37 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
37 pop->MoveWindow(x, y, w, h); | 38 pop->MoveWindow(x, y, w, h); |
38 } | 39 } |
39 | 40 |
40 void BrowserBubble::Show() { | 41 void BrowserBubble::Show() { |
41 if (visible_) | 42 if (visible_) |
42 return; | 43 return; |
43 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 44 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
44 pop->Show(); | 45 pop->Show(); |
45 visible_ = true; | 46 visible_ = true; |
46 } | 47 } |
47 | 48 |
48 void BrowserBubble::Hide() { | 49 void BrowserBubble::Hide() { |
49 if (!visible_) | 50 if (!visible_) |
50 return; | 51 return; |
51 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 52 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_); |
52 pop->Hide(); | 53 pop->Hide(); |
53 visible_ = false; | 54 visible_ = false; |
54 } | 55 } |
OLD | NEW |