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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.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" |
11 #include "ui/base/default_theme_provider.h" | 11 #include "ui/base/default_theme_provider.h" |
12 #include "ui/base/events/event.h" | 12 #include "ui/base/events/event.h" |
13 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
14 #include "ui/base/l10n/l10n_font_util.h" | 14 #include "ui/base/l10n/l10n_font_util.h" |
15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
16 #include "ui/compositor/compositor.h" | 16 #include "ui/compositor/compositor.h" |
17 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 #include "ui/views/controls/menu/menu_controller.h" |
19 #include "ui/views/focus/focus_manager.h" | 20 #include "ui/views/focus/focus_manager.h" |
20 #include "ui/views/focus/focus_manager_factory.h" | 21 #include "ui/views/focus/focus_manager_factory.h" |
21 #include "ui/views/focus/view_storage.h" | 22 #include "ui/views/focus/view_storage.h" |
22 #include "ui/views/focus/widget_focus_manager.h" | 23 #include "ui/views/focus/widget_focus_manager.h" |
23 #include "ui/views/ime/input_method.h" | 24 #include "ui/views/ime/input_method.h" |
24 #include "ui/views/views_delegate.h" | 25 #include "ui/views/views_delegate.h" |
25 #include "ui/views/widget/native_widget_private.h" | 26 #include "ui/views/widget/native_widget_private.h" |
26 #include "ui/views/widget/root_view.h" | 27 #include "ui/views/widget/root_view.h" |
27 #include "ui/views/widget/tooltip_manager.h" | 28 #include "ui/views/widget/tooltip_manager.h" |
28 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
29 #include "ui/views/widget/widget_deletion_observer.h" | 30 #include "ui/views/widget/widget_deletion_observer.h" |
30 #include "ui/views/widget/widget_observer.h" | 31 #include "ui/views/widget/widget_observer.h" |
31 #include "ui/views/window/custom_frame_view.h" | 32 #include "ui/views/window/custom_frame_view.h" |
32 #include "ui/views/window/dialog_delegate.h" | 33 #include "ui/views/window/dialog_delegate.h" |
33 | 34 |
34 #if !defined(OS_MACOSX) | |
35 #include "ui/views/controls/menu/menu_controller.h" | |
36 #endif | |
37 | |
38 namespace views { | 35 namespace views { |
39 | 36 |
40 namespace { | 37 namespace { |
41 | 38 |
42 // If |view| has a layer the layer is added to |layers|. Else this recurses | 39 // If |view| has a layer the layer is added to |layers|. Else this recurses |
43 // through the children. This is used to build a list of the layers created by | 40 // through the children. This is used to build a list of the layers created by |
44 // views that are direct children of the Widgets layer. | 41 // views that are direct children of the Widgets layer. |
45 void BuildRootLayers(View* view, std::vector<ui::Layer*>* layers) { | 42 void BuildRootLayers(View* view, std::vector<ui::Layer*>* layers) { |
46 if (view->layer()) { | 43 if (view->layer()) { |
47 layers->push_back(view->layer()); | 44 layers->push_back(view->layer()); |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 native_widget_->CloseNow(); | 582 native_widget_->CloseNow(); |
586 } | 583 } |
587 | 584 |
588 bool Widget::IsClosed() const { | 585 bool Widget::IsClosed() const { |
589 return widget_closed_; | 586 return widget_closed_; |
590 } | 587 } |
591 | 588 |
592 void Widget::Show() { | 589 void Widget::Show() { |
593 TRACE_EVENT0("views", "Widget::Show"); | 590 TRACE_EVENT0("views", "Widget::Show"); |
594 if (non_client_view_) { | 591 if (non_client_view_) { |
595 #if defined(OS_MACOSX) | |
596 // On the Mac the FullScreenBookmarkBar test is different then for any other | |
597 // OS. Since the new maximize logic from ash does not apply to the mac, we | |
598 // continue to ignore the fullscreen mode here. | |
599 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | |
600 !initial_restored_bounds_.IsEmpty()) { | |
601 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); | |
602 } else { | |
603 native_widget_->ShowWithWindowState(saved_show_state_); | |
604 } | |
605 #else | |
606 // While initializing, the kiosk mode will go to full screen before the | 592 // While initializing, the kiosk mode will go to full screen before the |
607 // widget gets shown. In that case we stay in full screen mode, regardless | 593 // widget gets shown. In that case we stay in full screen mode, regardless |
608 // of the |saved_show_state_| member. | 594 // of the |saved_show_state_| member. |
609 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | 595 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && |
610 !initial_restored_bounds_.IsEmpty() && | 596 !initial_restored_bounds_.IsEmpty() && |
611 !IsFullscreen()) { | 597 !IsFullscreen()) { |
612 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); | 598 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); |
613 } else { | 599 } else { |
614 native_widget_->ShowWithWindowState( | 600 native_widget_->ShowWithWindowState( |
615 IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : saved_show_state_); | 601 IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : saved_show_state_); |
616 } | 602 } |
617 #endif | |
618 // |saved_show_state_| only applies the first time the window is shown. | 603 // |saved_show_state_| only applies the first time the window is shown. |
619 // If we don't reset the value the window may be shown maximized every time | 604 // If we don't reset the value the window may be shown maximized every time |
620 // it is subsequently shown after being hidden. | 605 // it is subsequently shown after being hidden. |
621 saved_show_state_ = ui::SHOW_STATE_NORMAL; | 606 saved_show_state_ = ui::SHOW_STATE_NORMAL; |
622 } else { | 607 } else { |
623 native_widget_->Show(); | 608 native_widget_->Show(); |
624 } | 609 } |
625 } | 610 } |
626 | 611 |
627 void Widget::Hide() { | 612 void Widget::Hide() { |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 | 1416 |
1432 //////////////////////////////////////////////////////////////////////////////// | 1417 //////////////////////////////////////////////////////////////////////////////// |
1433 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1418 // internal::NativeWidgetPrivate, NativeWidget implementation: |
1434 | 1419 |
1435 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1420 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
1436 return this; | 1421 return this; |
1437 } | 1422 } |
1438 | 1423 |
1439 } // namespace internal | 1424 } // namespace internal |
1440 } // namespace views | 1425 } // namespace views |
OLD | NEW |