OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/widget/widget.h" | 5 #include "ui/views/widget/widget.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { | 1442 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED) { |
1443 // If we're going to maximize, wait until Show is invoked to set the | 1443 // If we're going to maximize, wait until Show is invoked to set the |
1444 // bounds. That way we avoid a noticeable resize. | 1444 // bounds. That way we avoid a noticeable resize. |
1445 initial_restored_bounds_ = saved_bounds; | 1445 initial_restored_bounds_ = saved_bounds; |
1446 } else if (!saved_bounds.IsEmpty()) { | 1446 } else if (!saved_bounds.IsEmpty()) { |
1447 // If the saved bounds are valid, use them. | 1447 // If the saved bounds are valid, use them. |
1448 SetBounds(saved_bounds); | 1448 SetBounds(saved_bounds); |
1449 } | 1449 } |
1450 } else { | 1450 } else { |
1451 if (bounds.IsEmpty()) { | 1451 if (bounds.IsEmpty()) { |
1452 // No initial bounds supplied, so size the window to its content and | 1452 if (bounds.origin().IsOrigin()) { |
1453 // center over its parent. | 1453 // No initial bounds supplied, so size the window to its content and |
1454 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); | 1454 // center over its parent. |
| 1455 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); |
| 1456 } else { |
| 1457 // Use the preferred size and the supplied origin. |
| 1458 gfx::Rect preferred_bounds(bounds); |
| 1459 preferred_bounds.set_size(non_client_view_->GetPreferredSize()); |
| 1460 SetBoundsConstrained(preferred_bounds); |
| 1461 } |
1455 } else { | 1462 } else { |
1456 // Use the supplied initial bounds. | 1463 // Use the supplied initial bounds. |
1457 SetBoundsConstrained(bounds); | 1464 SetBoundsConstrained(bounds); |
1458 } | 1465 } |
1459 } | 1466 } |
1460 } | 1467 } |
1461 | 1468 |
1462 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { | 1469 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { |
1463 if (bounds.IsEmpty()) { | 1470 if (bounds.IsEmpty()) { |
1464 View* contents_view = GetContentsView(); | 1471 View* contents_view = GetContentsView(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1505 | 1512 |
1506 //////////////////////////////////////////////////////////////////////////////// | 1513 //////////////////////////////////////////////////////////////////////////////// |
1507 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1514 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1508 | 1515 |
1509 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1516 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1510 return this; | 1517 return this; |
1511 } | 1518 } |
1512 | 1519 |
1513 } // namespace internal | 1520 } // namespace internal |
1514 } // namespace views | 1521 } // namespace views |
OLD | NEW |