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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 624 } |
625 | 625 |
626 void Widget::Show() { | 626 void Widget::Show() { |
627 const ui::Layer* layer = GetLayer(); | 627 const ui::Layer* layer = GetLayer(); |
628 TRACE_EVENT1("views", "Widget::Show", "layer", | 628 TRACE_EVENT1("views", "Widget::Show", "layer", |
629 layer ? layer->name() : "none"); | 629 layer ? layer->name() : "none"); |
630 if (non_client_view_) { | 630 if (non_client_view_) { |
631 // While initializing, the kiosk mode will go to full screen before the | 631 // While initializing, the kiosk mode will go to full screen before the |
632 // widget gets shown. In that case we stay in full screen mode, regardless | 632 // widget gets shown. In that case we stay in full screen mode, regardless |
633 // of the |saved_show_state_| member. | 633 // of the |saved_show_state_| member. |
634 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | 634 if (((saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && !IsFullscreen()) || |
635 !initial_restored_bounds_.IsEmpty() && | 635 IsMaximized()) && |
636 !IsFullscreen()) { | 636 !initial_restored_bounds_.IsEmpty()) { |
637 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); | 637 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); |
638 } else { | 638 } else { |
639 ui::WindowShowState show_state = | 639 ui::WindowShowState show_state = |
640 IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : | 640 IsFullscreen() |
641 IsMinimized() ? ui::SHOW_STATE_MINIMIZED : saved_show_state_; | 641 ? ui::SHOW_STATE_FULLSCREEN |
| 642 : (IsMaximized() ? ui::SHOW_STATE_MAXIMIZED |
| 643 : (IsMinimized() ? ui::SHOW_STATE_MINIMIZED |
| 644 : saved_show_state_)); |
642 native_widget_->ShowWithWindowState(show_state); | 645 native_widget_->ShowWithWindowState(show_state); |
643 } | 646 } |
644 // |saved_show_state_| only applies the first time the window is shown. | 647 // |saved_show_state_| only applies the first time the window is shown. |
645 // If we don't reset the value the window may be shown maximized every time | 648 // If we don't reset the value the window may be shown maximized every time |
646 // it is subsequently shown after being hidden. | 649 // it is subsequently shown after being hidden. |
647 saved_show_state_ = ui::SHOW_STATE_NORMAL; | 650 saved_show_state_ = ui::SHOW_STATE_NORMAL; |
648 } else { | 651 } else { |
649 CanActivate() | 652 CanActivate() |
650 ? native_widget_->Show() | 653 ? native_widget_->Show() |
651 : native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); | 654 : native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1446 // If the saved bounds are valid, use them. | 1449 // If the saved bounds are valid, use them. |
1447 SetBounds(saved_bounds); | 1450 SetBounds(saved_bounds); |
1448 } | 1451 } |
1449 } else { | 1452 } else { |
1450 if (bounds.IsEmpty()) { | 1453 if (bounds.IsEmpty()) { |
1451 // No initial bounds supplied, so size the window to its content and | 1454 // No initial bounds supplied, so size the window to its content and |
1452 // center over its parent. | 1455 // center over its parent. |
1453 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); | 1456 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); |
1454 } else { | 1457 } else { |
1455 // Use the supplied initial bounds. | 1458 // Use the supplied initial bounds. |
| 1459 if (IsMaximized()) |
| 1460 initial_restored_bounds_ = bounds; |
1456 SetBoundsConstrained(bounds); | 1461 SetBoundsConstrained(bounds); |
1457 } | 1462 } |
1458 } | 1463 } |
1459 } | 1464 } |
1460 | 1465 |
1461 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { | 1466 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { |
1462 if (bounds.IsEmpty()) { | 1467 if (bounds.IsEmpty()) { |
1463 View* contents_view = GetContentsView(); | 1468 View* contents_view = GetContentsView(); |
1464 DCHECK(contents_view); | 1469 DCHECK(contents_view); |
1465 // No initial bounds supplied, so size the window to its content and | 1470 // No initial bounds supplied, so size the window to its content and |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 | 1509 |
1505 //////////////////////////////////////////////////////////////////////////////// | 1510 //////////////////////////////////////////////////////////////////////////////// |
1506 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1511 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1507 | 1512 |
1508 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1513 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1509 return this; | 1514 return this; |
1510 } | 1515 } |
1511 | 1516 |
1512 } // namespace internal | 1517 } // namespace internal |
1513 } // namespace views | 1518 } // namespace views |
OLD | NEW |