| 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 "ash/shell.h" | 5 #include "ash/shell.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/accelerators/accelerator_controller.h" | 11 #include "ash/accelerators/accelerator_controller.h" |
| 12 #include "ash/accelerators/accelerator_delegate.h" | 12 #include "ash/accelerators/accelerator_delegate.h" |
| 13 #include "ash/accelerators/focus_manager_factory.h" | 13 #include "ash/accelerators/focus_manager_factory.h" |
| 14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/aura/wm_shell_aura.h" | 15 #include "ash/aura/wm_shell_aura.h" |
| 16 #include "ash/aura/wm_window_aura.h" | 16 #include "ash/aura/wm_window_aura.h" |
| 17 #include "ash/autoclick/autoclick_controller.h" | 17 #include "ash/autoclick/autoclick_controller.h" |
| 18 #include "ash/common/session/session_state_delegate.h" | 18 #include "ash/common/session/session_state_delegate.h" |
| 19 #include "ash/common/shelf/shelf_item_delegate.h" | 19 #include "ash/common/shelf/shelf_item_delegate.h" |
| 20 #include "ash/common/shelf/shelf_item_delegate_manager.h" | 20 #include "ash/common/shelf/shelf_item_delegate_manager.h" |
| 21 #include "ash/common/shelf/shelf_model.h" | 21 #include "ash/common/shelf/shelf_model.h" |
| 22 #include "ash/common/shell_window_ids.h" | 22 #include "ash/common/shell_window_ids.h" |
| 23 #include "ash/common/wm/mru_window_tracker.h" | 23 #include "ash/common/wm/mru_window_tracker.h" |
| 24 #include "ash/common/wm/root_window_finder.h" | 24 #include "ash/common/wm/root_window_finder.h" |
| 25 #include "ash/common/wm/window_positioner.h" | 25 #include "ash/common/wm/window_positioner.h" |
| 26 #include "ash/common/wm_shell_common.h" |
| 26 #include "ash/container_delegate.h" | 27 #include "ash/container_delegate.h" |
| 27 #include "ash/desktop_background/desktop_background_controller.h" | 28 #include "ash/desktop_background/desktop_background_controller.h" |
| 28 #include "ash/desktop_background/desktop_background_view.h" | 29 #include "ash/desktop_background/desktop_background_view.h" |
| 29 #include "ash/desktop_background/user_wallpaper_delegate.h" | 30 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 30 #include "ash/display/cursor_window_controller.h" | 31 #include "ash/display/cursor_window_controller.h" |
| 31 #include "ash/display/display_configuration_controller.h" | 32 #include "ash/display/display_configuration_controller.h" |
| 32 #include "ash/display/display_manager.h" | 33 #include "ash/display/display_manager.h" |
| 33 #include "ash/display/event_transformation_handler.h" | 34 #include "ash/display/event_transformation_handler.h" |
| 34 #include "ash/display/mouse_cursor_event_filter.h" | 35 #include "ash/display/mouse_cursor_event_filter.h" |
| 35 #include "ash/display/screen_position_controller.h" | 36 #include "ash/display/screen_position_controller.h" |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 | 766 |
| 766 // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| | 767 // |shelf_window_watcher_| has a weak pointer to |shelf_Model_| |
| 767 // and has window observers. | 768 // and has window observers. |
| 768 shelf_window_watcher_.reset(); | 769 shelf_window_watcher_.reset(); |
| 769 | 770 |
| 770 // Destroy all child windows including widgets. | 771 // Destroy all child windows including widgets. |
| 771 window_tree_host_manager_->CloseChildWindows(); | 772 window_tree_host_manager_->CloseChildWindows(); |
| 772 // MruWindowTracker must be destroyed after all windows have been deleted to | 773 // MruWindowTracker must be destroyed after all windows have been deleted to |
| 773 // avoid a possible crash when Shell is destroyed from a non-normal shutdown | 774 // avoid a possible crash when Shell is destroyed from a non-normal shutdown |
| 774 // path. (crbug.com/485438). | 775 // path. (crbug.com/485438). |
| 775 mru_window_tracker_.reset(); | 776 wm_shell_common_->DeleteMruWindowTracker(); |
| 776 | 777 |
| 777 // Chrome implementation of shelf delegate depends on FocusClient, | 778 // Chrome implementation of shelf delegate depends on FocusClient, |
| 778 // so must be deleted before |focus_client_| (below). | 779 // so must be deleted before |focus_client_| (below). |
| 779 shelf_delegate_.reset(); | 780 shelf_delegate_.reset(); |
| 780 | 781 |
| 781 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems | 782 // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
| 782 // needs to remove observers from it. | 783 // needs to remove observers from it. |
| 783 system_tray_notifier_.reset(); | 784 system_tray_notifier_.reset(); |
| 784 | 785 |
| 785 // These need a valid Shell instance to clean up properly, so explicitly | 786 // These need a valid Shell instance to clean up properly, so explicitly |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 819 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
| 819 // destruction | 820 // destruction |
| 820 // of its owned RootWindowControllers relies on the value. | 821 // of its owned RootWindowControllers relies on the value. |
| 821 display_manager_->CreateScreenForShutdown(); | 822 display_manager_->CreateScreenForShutdown(); |
| 822 display_configuration_controller_.reset(); | 823 display_configuration_controller_.reset(); |
| 823 | 824 |
| 824 // Needs to happen before |window_tree_host_manager_|. Calls back to Shell, so | 825 // Needs to happen before |window_tree_host_manager_|. Calls back to Shell, so |
| 825 // also needs to be destroyed before |instance_| reset to null. | 826 // also needs to be destroyed before |instance_| reset to null. |
| 826 wm_shell_.reset(); | 827 wm_shell_.reset(); |
| 827 | 828 |
| 829 // Must happen after |wm_shell_| is deleted. |
| 830 wm_shell_common_.reset(); |
| 831 |
| 828 // Depends on |focus_client_|, so must be destroyed before. | 832 // Depends on |focus_client_|, so must be destroyed before. |
| 829 window_tree_host_manager_->Shutdown(); | 833 window_tree_host_manager_->Shutdown(); |
| 830 window_tree_host_manager_.reset(); | 834 window_tree_host_manager_.reset(); |
| 831 focus_client_.reset(); | 835 focus_client_.reset(); |
| 832 screen_position_controller_.reset(); | 836 screen_position_controller_.reset(); |
| 833 accessibility_delegate_.reset(); | 837 accessibility_delegate_.reset(); |
| 834 new_window_delegate_.reset(); | 838 new_window_delegate_.reset(); |
| 835 media_delegate_.reset(); | 839 media_delegate_.reset(); |
| 836 container_delegate_.reset(); | 840 container_delegate_.reset(); |
| 837 pointer_watcher_delegate_.reset(); | 841 pointer_watcher_delegate_.reset(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 860 instance_ = nullptr; | 864 instance_ = nullptr; |
| 861 } | 865 } |
| 862 | 866 |
| 863 void Shell::Init(const ShellInitParams& init_params) { | 867 void Shell::Init(const ShellInitParams& init_params) { |
| 864 in_mus_ = init_params.in_mus; | 868 in_mus_ = init_params.in_mus; |
| 865 | 869 |
| 866 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 870 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 867 DCHECK(in_mus_) << "linux desktop does not support ash."; | 871 DCHECK(in_mus_) << "linux desktop does not support ash."; |
| 868 #endif | 872 #endif |
| 869 | 873 |
| 870 wm_shell_.reset(new WmShellAura); | 874 wm_shell_common_.reset(new WmShellCommon); |
| 875 wm_shell_.reset(new WmShellAura(wm_shell_common_.get())); |
| 871 scoped_overview_animation_settings_factory_.reset( | 876 scoped_overview_animation_settings_factory_.reset( |
| 872 new ScopedOverviewAnimationSettingsFactoryAura); | 877 new ScopedOverviewAnimationSettingsFactoryAura); |
| 873 window_positioner_.reset(new WindowPositioner(wm_shell_.get())); | 878 window_positioner_.reset(new WindowPositioner(wm_shell_.get())); |
| 874 | 879 |
| 875 if (!in_mus_) { | 880 if (!in_mus_) { |
| 876 native_cursor_manager_ = new AshNativeCursorManager; | 881 native_cursor_manager_ = new AshNativeCursorManager; |
| 877 #if defined(OS_CHROMEOS) | 882 #if defined(OS_CHROMEOS) |
| 878 cursor_manager_.reset( | 883 cursor_manager_.reset( |
| 879 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 884 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
| 880 #else | 885 #else |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 mouse_cursor_filter_.reset(new MouseCursorEventFilter()); | 1046 mouse_cursor_filter_.reset(new MouseCursorEventFilter()); |
| 1042 PrependPreTargetHandler(mouse_cursor_filter_.get()); | 1047 PrependPreTargetHandler(mouse_cursor_filter_.get()); |
| 1043 | 1048 |
| 1044 // Create Controllers that may need root window. | 1049 // Create Controllers that may need root window. |
| 1045 // TODO(oshima): Move as many controllers before creating | 1050 // TODO(oshima): Move as many controllers before creating |
| 1046 // RootWindowController as possible. | 1051 // RootWindowController as possible. |
| 1047 visibility_controller_.reset(new AshVisibilityController); | 1052 visibility_controller_.reset(new AshVisibilityController); |
| 1048 | 1053 |
| 1049 magnification_controller_.reset( | 1054 magnification_controller_.reset( |
| 1050 MagnificationController::CreateInstance()); | 1055 MagnificationController::CreateInstance()); |
| 1051 mru_window_tracker_.reset(new MruWindowTracker); | 1056 wm_shell_common_->CreateMruWindowTracker(); |
| 1052 | 1057 |
| 1053 partial_magnification_controller_.reset( | 1058 partial_magnification_controller_.reset( |
| 1054 new PartialMagnificationController()); | 1059 new PartialMagnificationController()); |
| 1055 | 1060 |
| 1056 autoclick_controller_.reset(AutoclickController::CreateInstance()); | 1061 autoclick_controller_.reset(AutoclickController::CreateInstance()); |
| 1057 | 1062 |
| 1058 high_contrast_controller_.reset(new HighContrastController); | 1063 high_contrast_controller_.reset(new HighContrastController); |
| 1059 video_detector_.reset(new VideoDetector); | 1064 video_detector_.reset(new VideoDetector); |
| 1060 window_selector_controller_.reset(new WindowSelectorController()); | 1065 window_selector_controller_.reset(new WindowSelectorController()); |
| 1061 window_cycle_controller_.reset(new WindowCycleController()); | 1066 window_cycle_controller_.reset(new WindowCycleController()); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 | 1254 |
| 1250 void Shell::OnWindowActivated( | 1255 void Shell::OnWindowActivated( |
| 1251 aura::client::ActivationChangeObserver::ActivationReason reason, | 1256 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1252 aura::Window* gained_active, | 1257 aura::Window* gained_active, |
| 1253 aura::Window* lost_active) { | 1258 aura::Window* lost_active) { |
| 1254 if (gained_active) | 1259 if (gained_active) |
| 1255 target_root_window_ = gained_active->GetRootWindow(); | 1260 target_root_window_ = gained_active->GetRootWindow(); |
| 1256 } | 1261 } |
| 1257 | 1262 |
| 1258 } // namespace ash | 1263 } // namespace ash |
| OLD | NEW |