Chromium Code Reviews| Index: ui/views/widget/widget.cc |
| diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc |
| index 3a77c699ff57fccf405e73bc350bbd17713142fa..799472779716bcd15b5ebac92516feb325fcd2c4 100644 |
| --- a/ui/views/widget/widget.cc |
| +++ b/ui/views/widget/widget.cc |
| @@ -221,6 +221,25 @@ Widget* Widget::CreateWindowWithParentAndBounds(WidgetDelegate* delegate, |
| } |
| // static |
| +Widget* Widget::CreateFramelessWindowWithParentAndBounds( |
| + WidgetDelegate* delegate, |
| + gfx::NativeWindow parent, |
| + const gfx::Rect& bounds) { |
|
Ben Goodger (Google)
2012/01/30 21:16:16
Rather than do this in Widget, can you just move t
jennyz
2012/01/30 23:13:28
Done.
|
| + Widget* widget = new Widget; |
| + Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| + params.delegate = delegate; |
| + // Will this function be called if !defined(USE_AURA)? |
| +#if defined(OS_WIN) || defined(USE_AURA) |
| + params.parent = parent; |
| +#endif |
| + params.bounds = bounds; |
| + widget->Init(params); |
| + widget->SetContentsView(delegate->GetContentsView()); |
| + widget->SetInitialBoundsForFramelessWindow(bounds); |
|
jennyz
2012/01/27 23:17:48
I was thinking for moving SetContentsView(delegate
|
| + return widget; |
| +} |
| + |
| +// static |
| void Widget::SetPureViews(bool pure) { |
| use_pure_views = pure; |
| } |
| @@ -1204,6 +1223,19 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) { |
| } |
| } |
| +void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { |
| + View* contents_view = GetContentsView(); |
| + DCHECK(contents_view != NULL); |
| + if (bounds.IsEmpty()) { |
| + // No initial bounds supplied, so size the window to its content and |
| + // center over its parent. |
| + native_widget_->CenterWindow(contents_view->GetPreferredSize()); |
| + } else { |
| + // Use the supplied initial bounds. |
| + SetBoundsConstrained(bounds); |
| + } |
| +} |
| + |
| bool Widget::GetSavedWindowPlacement(gfx::Rect* bounds, |
| ui::WindowShowState* show_state) { |
| // First we obtain the window's saved show-style and store it. We need to do |