Index: chrome/browser/ui/views/browser_bubble_gtk.cc |
=================================================================== |
--- chrome/browser/ui/views/browser_bubble_gtk.cc (revision 85284) |
+++ chrome/browser/ui/views/browser_bubble_gtk.cc (working copy) |
@@ -23,7 +23,8 @@ |
class BubbleWidget : public views::WidgetGtk { |
public: |
BubbleWidget(BrowserBubble* bubble, const gfx::Insets& content_margins) |
- : bubble_(bubble), |
+ : views::WidgetGtk(new views::Widget), |
+ bubble_(bubble), |
border_contents_(new BorderContents) { |
border_contents_->Init(); |
border_contents_->set_content_margins(content_margins); |
@@ -47,7 +48,7 @@ |
} |
virtual void Hide() { |
- if (IsActive()&& bubble_) { |
+ if (IsActive() && bubble_) { |
BrowserBubble::Delegate* delegate = bubble_->delegate(); |
if (delegate) |
delegate->BubbleLostFocus(bubble_, false); |
@@ -92,18 +93,19 @@ |
void BrowserBubble::InitPopup(const gfx::Insets& content_margins) { |
// TODO(port) |
- BubbleWidget* pop = new BubbleWidget(this, content_margins); |
- pop->MakeTransparent(); |
- pop->make_transient_to_parent(); |
+ BubbleWidget* bubble_widget = new BubbleWidget(this, content_margins); |
+ popup_ = bubble_widget->GetWidget(); |
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
+ params.transparent = true; |
params.parent = frame_->GetNativeView(); |
- pop->Init(params); |
+ params.native_widget = bubble_widget; |
+ popup_->Init(params); |
#if defined(OS_CHROMEOS) |
{ |
vector<int> params; |
params.push_back(0); // don't show while screen is locked |
chromeos::WmIpc::instance()->SetWindowType( |
- pop->GetNativeView(), |
+ popup_->GetNativeView(), |
chromeos::WM_IPC_WINDOW_CHROME_INFO_BUBBLE, |
¶ms); |
} |
@@ -115,42 +117,32 @@ |
// that when |contents| gets added, it will already have a widget, and thus |
// any NativeButtons it creates in ViewHierarchyChanged() will be functional |
// (e.g. calling SetChecked() on checkboxes is safe). |
- pop->SetContentsView(contents_view); |
+ popup_->SetContentsView(contents_view); |
// Added border_contents before |view_| so it will paint under it. |
- contents_view->AddChildView(pop->border_contents()); |
+ contents_view->AddChildView(bubble_widget->border_contents()); |
contents_view->AddChildView(view_); |
- popup_ = pop; |
- |
ResizeToView(); |
Reposition(); |
AttachToBrowser(); |
} |
-void BrowserBubble::MovePopup(int x, int y, int w, int h) { |
- views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_); |
- pop->SetBounds(gfx::Rect(x, y, w, h)); |
-} |
- |
void BrowserBubble::Show(bool activate) { |
- if (visible_) |
- return; |
- static_cast<BubbleWidget*>(popup_)->ShowAndActivate(activate); |
- visible_ = true; |
+ if (!popup_->IsVisible()) { |
+ static_cast<BubbleWidget*>(popup_->native_widget())->ShowAndActivate( |
+ activate); |
+ } |
} |
void BrowserBubble::Hide() { |
- if (!visible_) |
- return; |
- views::WidgetGtk* pop = static_cast<views::WidgetGtk*>(popup_); |
- pop->Hide(); |
- visible_ = false; |
+ if (popup_->IsVisible()) |
+ static_cast<BubbleWidget*>(popup_->native_widget())->Hide(); |
} |
void BrowserBubble::ResizeToView() { |
BorderContents* border_contents = |
- static_cast<BubbleWidget*>(popup_)->border_contents(); |
+ static_cast<BubbleWidget*>(popup_->native_widget())->border_contents(); |
// Calculate and set the bounds for all windows and views. |
gfx::Rect window_bounds; |