| 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); | 15 pop->set_delete_on_destroy(false); |
| 16 pop->set_window_style(WS_POPUP); | 16 pop->set_window_style(WS_POPUP); |
| 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 // A focus manager is necessary if you want to be able to handle various | 25 // A focus manager is necessary if you want to be able to handle various |
| 26 // mouse events properly. | 26 // mouse events properly. |
| 27 pop->Init(frame_native_view_, | 27 pop->Init(frame_native_view_, bounds_); |
| 28 bounds_, | |
| 29 true); // Give the widget a focus manager. | |
| 30 pop->SetContentsView(view_); | 28 pop->SetContentsView(view_); |
| 31 popup_.reset(pop); | 29 popup_.reset(pop); |
| 32 Reposition(); | 30 Reposition(); |
| 33 | 31 |
| 34 AttachToBrowser(); | 32 AttachToBrowser(); |
| 35 } | 33 } |
| 36 | 34 |
| 37 void BrowserBubble::MovePopup(int x, int y, int w, int h) { | 35 void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
| 38 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 36 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
| 39 pop->MoveWindow(x, y, w, h); | 37 pop->MoveWindow(x, y, w, h); |
| 40 } | 38 } |
| 41 | 39 |
| 42 void BrowserBubble::Show() { | 40 void BrowserBubble::Show() { |
| 43 if (visible_) | 41 if (visible_) |
| 44 return; | 42 return; |
| 45 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 43 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
| 46 pop->Show(); | 44 pop->Show(); |
| 47 visible_ = true; | 45 visible_ = true; |
| 48 } | 46 } |
| 49 | 47 |
| 50 void BrowserBubble::Hide() { | 48 void BrowserBubble::Hide() { |
| 51 if (!visible_) | 49 if (!visible_) |
| 52 return; | 50 return; |
| 53 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); | 51 views::WidgetWin* pop = static_cast<views::WidgetWin*>(popup_.get()); |
| 54 pop->Hide(); | 52 pop->Hide(); |
| 55 visible_ = false; | 53 visible_ = false; |
| 56 } | 54 } |
| OLD | NEW |