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