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..3e64731f6616d2eb05eeaafa3030e6f0371544ed 100644 |
| --- a/ui/views/widget/widget.cc |
| +++ b/ui/views/widget/widget.cc |
| @@ -336,6 +336,11 @@ void Widget::Init(const InitParams& params) { |
| else if (params.show_state == ui::SHOW_STATE_MINIMIZED) |
| Minimize(); |
| UpdateWindowTitle(); |
| + } else { |
|
Ben Goodger (Google)
2012/01/31 00:14:19
} else if (params.delegate) {
jennyz
2012/01/31 00:24:03
Done.
|
| + if (params.delegate != NULL) { |
| + SetContentsView(params.delegate->GetContentsView()); |
| + SetInitialBoundsForFramelessWindow(params.bounds); |
| + } |
| } |
| native_widget_initialized_ = true; |
| } |
| @@ -406,6 +411,9 @@ const Widget* Widget::GetTopLevelWidget() const { |
| } |
| void Widget::SetContentsView(View* view) { |
| + // Do not SetContentsView() again if it is already set to the same view. |
| + if (view == GetContentsView()) |
| + return; |
| root_view_->SetContentsView(view); |
| if (non_client_view_ != view) |
| non_client_view_ = NULL; |
| @@ -1204,6 +1212,19 @@ void Widget::SetInitialBounds(const gfx::Rect& bounds) { |
| } |
| } |
| +void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { |
| + View* contents_view = GetContentsView(); |
| + DCHECK(contents_view != NULL); |
|
mazda
2012/01/30 23:26:29
DCHECK(contents_view);
jennyz
2012/01/31 00:24:03
Done.
|
| + 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 |