| 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_delegate.h" | 11 #include "ash/accelerators/accelerator_delegate.h" |
| 12 #include "ash/accelerators/magnifier_key_scroller.h" | 12 #include "ash/accelerators/magnifier_key_scroller.h" |
| 13 #include "ash/accelerators/spoken_feedback_toggler.h" | 13 #include "ash/accelerators/spoken_feedback_toggler.h" |
| 14 #include "ash/app_list/app_list_delegate_impl.h" | 14 #include "ash/app_list/app_list_delegate_impl.h" |
| 15 #include "ash/aura/wm_shell_aura.h" | 15 #include "ash/aura/wm_shell_aura.h" |
| 16 #include "ash/autoclick/autoclick_controller.h" | 16 #include "ash/autoclick/autoclick_controller.h" |
| 17 #include "ash/common/accelerators/accelerator_controller.h" | 17 #include "ash/common/accelerators/accelerator_controller.h" |
| 18 #include "ash/common/accelerators/ash_focus_manager_factory.h" | 18 #include "ash/common/accelerators/ash_focus_manager_factory.h" |
| 19 #include "ash/common/accessibility_delegate.h" | 19 #include "ash/common/accessibility_delegate.h" |
| 20 #include "ash/common/ash_constants.h" | 20 #include "ash/common/ash_constants.h" |
| 21 #include "ash/common/cast_config_controller.h" | 21 #include "ash/common/cast_config_controller.h" |
| 22 #include "ash/common/devtools/ash_devtools_css_agent.h" | 22 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 23 #include "ash/common/devtools/ash_devtools_dom_agent.h" | 23 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
| 24 #include "ash/common/focus_cycler.h" | 24 #include "ash/common/focus_cycler.h" |
| 25 #include "ash/common/frame/custom_frame_view_ash.h" | 25 #include "ash/common/frame/custom_frame_view_ash.h" |
| 26 #include "ash/common/gpu_support.h" | 26 #include "ash/common/gpu_support.h" |
| 27 #include "ash/common/keyboard/keyboard_ui.h" | 27 #include "ash/common/keyboard/keyboard_ui.h" |
| 28 #include "ash/common/login_status.h" | 28 #include "ash/common/login_status.h" |
| 29 #include "ash/common/media_controller.h" |
| 30 #include "ash/common/new_window_controller.h" |
| 29 #include "ash/common/palette_delegate.h" | 31 #include "ash/common/palette_delegate.h" |
| 30 #include "ash/common/session/session_state_delegate.h" | 32 #include "ash/common/session/session_state_delegate.h" |
| 31 #include "ash/common/shelf/wm_shelf.h" | 33 #include "ash/common/shelf/wm_shelf.h" |
| 32 #include "ash/common/shell_delegate.h" | 34 #include "ash/common/shell_delegate.h" |
| 33 #include "ash/common/shell_observer.h" | 35 #include "ash/common/shell_observer.h" |
| 34 #include "ash/common/system/brightness_control_delegate.h" | 36 #include "ash/common/system/brightness_control_delegate.h" |
| 35 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" | 37 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" |
| 36 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" | 38 #include "ash/common/system/chromeos/bluetooth/tray_bluetooth_helper.h" |
| 37 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" | 39 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
| 38 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | 40 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 39 #include "ash/common/system/chromeos/network/sms_observer.h" | 41 #include "ash/common/system/chromeos/network/sms_observer.h" |
| 40 #include "ash/common/system/chromeos/power/power_status.h" | 42 #include "ash/common/system/chromeos/power/power_status.h" |
| 41 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 43 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
| 42 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 44 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 43 #include "ash/common/system/locale/locale_notification_controller.h" | 45 #include "ash/common/system/locale/locale_notification_controller.h" |
| 44 #include "ash/common/system/status_area_widget.h" | 46 #include "ash/common/system/status_area_widget.h" |
| 45 #include "ash/common/system/toast/toast_manager.h" | 47 #include "ash/common/system/toast/toast_manager.h" |
| 46 #include "ash/common/system/tray/system_tray_controller.h" | 48 #include "ash/common/system/tray/system_tray_controller.h" |
| 47 #include "ash/common/system/tray/system_tray_delegate.h" | 49 #include "ash/common/system/tray/system_tray_delegate.h" |
| 48 #include "ash/common/system/tray/system_tray_notifier.h" | 50 #include "ash/common/system/tray/system_tray_notifier.h" |
| 49 #include "ash/common/wallpaper/wallpaper_controller.h" | 51 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 50 #include "ash/common/wallpaper/wallpaper_delegate.h" | 52 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 51 #include "ash/common/wm/container_finder.h" | 53 #include "ash/common/wm/container_finder.h" |
| 54 #include "ash/common/wm/immersive_context_ash.h" |
| 52 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 55 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 53 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 56 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 54 #include "ash/common/wm/mru_window_tracker.h" | 57 #include "ash/common/wm/mru_window_tracker.h" |
| 55 #include "ash/common/wm/root_window_finder.h" | 58 #include "ash/common/wm/root_window_finder.h" |
| 56 #include "ash/common/wm/system_modal_container_layout_manager.h" | 59 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 57 #include "ash/common/wm/window_positioner.h" | 60 #include "ash/common/wm/window_positioner.h" |
| 58 #include "ash/common/wm/workspace_controller.h" | 61 #include "ash/common/wm/workspace_controller.h" |
| 59 #include "ash/common/wm_shell.h" | 62 #include "ash/common/wm_shell.h" |
| 60 #include "ash/common/wm_window.h" | 63 #include "ash/common/wm_window.h" |
| 61 #include "ash/display/cursor_window_controller.h" | 64 #include "ash/display/cursor_window_controller.h" |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 //////////////////////////////////////////////////////////////////////////////// | 516 //////////////////////////////////////////////////////////////////////////////// |
| 514 // Shell, private: | 517 // Shell, private: |
| 515 | 518 |
| 516 Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, | 519 Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, |
| 517 std::unique_ptr<WmShell> wm_shell) | 520 std::unique_ptr<WmShell> wm_shell) |
| 518 : wm_shell_(std::move(wm_shell)), | 521 : wm_shell_(std::move(wm_shell)), |
| 519 brightness_control_delegate_( | 522 brightness_control_delegate_( |
| 520 base::MakeUnique<system::BrightnessControllerChromeos>()), | 523 base::MakeUnique<system::BrightnessControllerChromeos>()), |
| 521 cast_config_(base::MakeUnique<CastConfigController>()), | 524 cast_config_(base::MakeUnique<CastConfigController>()), |
| 522 focus_cycler_(base::MakeUnique<FocusCycler>()), | 525 focus_cycler_(base::MakeUnique<FocusCycler>()), |
| 526 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), |
| 523 keyboard_brightness_control_delegate_( | 527 keyboard_brightness_control_delegate_( |
| 524 base::MakeUnique<KeyboardBrightnessController>()), | 528 base::MakeUnique<KeyboardBrightnessController>()), |
| 525 locale_notification_controller_( | 529 locale_notification_controller_( |
| 526 base::MakeUnique<LocaleNotificationController>()), | 530 base::MakeUnique<LocaleNotificationController>()), |
| 531 media_controller_(base::MakeUnique<MediaController>()), |
| 532 new_window_controller_(base::MakeUnique<NewWindowController>()), |
| 527 shell_delegate_(std::move(shell_delegate)), | 533 shell_delegate_(std::move(shell_delegate)), |
| 528 system_tray_controller_(base::MakeUnique<SystemTrayController>()), | 534 system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
| 529 app_list_(base::MakeUnique<app_list::AppList>()), | 535 app_list_(base::MakeUnique<app_list::AppList>()), |
| 530 link_handler_model_factory_(nullptr), | 536 link_handler_model_factory_(nullptr), |
| 531 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), | 537 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), |
| 532 display_configurator_(new display::DisplayConfigurator()), | 538 display_configurator_(new display::DisplayConfigurator()), |
| 533 native_cursor_manager_(nullptr), | 539 native_cursor_manager_(nullptr), |
| 534 simulate_modal_window_open_for_testing_(false), | 540 simulate_modal_window_open_for_testing_(false), |
| 535 is_touch_hud_projection_enabled_(false) { | 541 is_touch_hud_projection_enabled_(false) { |
| 536 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 542 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 screen_orientation_controller_.reset(); | 598 screen_orientation_controller_.reset(); |
| 593 screen_layout_observer_.reset(); | 599 screen_layout_observer_.reset(); |
| 594 | 600 |
| 595 // Destroy the virtual keyboard controller before the maximize mode controller | 601 // Destroy the virtual keyboard controller before the maximize mode controller |
| 596 // since the latters destructor triggers events that the former is listening | 602 // since the latters destructor triggers events that the former is listening |
| 597 // to but no longer cares about. | 603 // to but no longer cares about. |
| 598 virtual_keyboard_controller_.reset(); | 604 virtual_keyboard_controller_.reset(); |
| 599 | 605 |
| 600 // Destroy maximize mode controller early on since it has some observers which | 606 // Destroy maximize mode controller early on since it has some observers which |
| 601 // need to be removed. | 607 // need to be removed. |
| 602 wm_shell_->DeleteMaximizeModeController(); | 608 maximize_mode_controller_.reset(); |
| 603 | 609 |
| 604 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 610 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 605 // layout. | 611 // layout. |
| 606 DeactivateKeyboard(); | 612 DeactivateKeyboard(); |
| 607 | 613 |
| 608 toast_manager_.reset(); | 614 toast_manager_.reset(); |
| 609 | 615 |
| 610 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 616 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 611 // to deinitialize the shelf first, as it is initialized after the delegate. | 617 // to deinitialize the shelf first, as it is initialized after the delegate. |
| 612 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 618 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 632 | 638 |
| 633 // Has to happen before ~MruWindowTracker. | 639 // Has to happen before ~MruWindowTracker. |
| 634 wm_shell_->DeleteWindowCycleController(); | 640 wm_shell_->DeleteWindowCycleController(); |
| 635 wm_shell_->DeleteWindowSelectorController(); | 641 wm_shell_->DeleteWindowSelectorController(); |
| 636 | 642 |
| 637 CloseAllRootWindowChildWindows(); | 643 CloseAllRootWindowChildWindows(); |
| 638 | 644 |
| 639 // MruWindowTracker must be destroyed after all windows have been deleted to | 645 // MruWindowTracker must be destroyed after all windows have been deleted to |
| 640 // avoid a possible crash when Shell is destroyed from a non-normal shutdown | 646 // avoid a possible crash when Shell is destroyed from a non-normal shutdown |
| 641 // path. (crbug.com/485438). | 647 // path. (crbug.com/485438). |
| 642 wm_shell_->DeleteMruWindowTracker(); | 648 mru_window_tracker_.reset(); |
| 643 | 649 |
| 644 // These need a valid Shell instance to clean up properly, so explicitly | 650 // These need a valid Shell instance to clean up properly, so explicitly |
| 645 // delete them before invalidating the instance. | 651 // delete them before invalidating the instance. |
| 646 // Alphabetical. TODO(oshima): sort. | 652 // Alphabetical. TODO(oshima): sort. |
| 647 magnification_controller_.reset(); | 653 magnification_controller_.reset(); |
| 648 tooltip_controller_.reset(); | 654 tooltip_controller_.reset(); |
| 649 event_client_.reset(); | 655 event_client_.reset(); |
| 650 toplevel_window_event_handler_.reset(); | 656 toplevel_window_event_handler_.reset(); |
| 651 visibility_controller_.reset(); | 657 visibility_controller_.reset(); |
| 652 | 658 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 | 764 |
| 759 if (is_mash) | 765 if (is_mash) |
| 760 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); | 766 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); |
| 761 | 767 |
| 762 // TODO(sky): move creation to WmShell. | 768 // TODO(sky): move creation to WmShell. |
| 763 if (!is_mash) | 769 if (!is_mash) |
| 764 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 770 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); |
| 765 | 771 |
| 766 scoped_overview_animation_settings_factory_.reset( | 772 scoped_overview_animation_settings_factory_.reset( |
| 767 new ScopedOverviewAnimationSettingsFactoryAura); | 773 new ScopedOverviewAnimationSettingsFactoryAura); |
| 768 window_positioner_.reset(new WindowPositioner(wm_shell_.get())); | 774 window_positioner_ = base::MakeUnique<WindowPositioner>(); |
| 769 | 775 |
| 770 if (!is_mash) { | 776 if (!is_mash) { |
| 771 native_cursor_manager_ = new AshNativeCursorManager; | 777 native_cursor_manager_ = new AshNativeCursorManager; |
| 772 cursor_manager_.reset( | 778 cursor_manager_.reset( |
| 773 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 779 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
| 774 } | 780 } |
| 775 | 781 |
| 776 shell_delegate_->PreInit(); | 782 shell_delegate_->PreInit(); |
| 777 bool display_initialized = true; | 783 bool display_initialized = true; |
| 778 if (!is_mash) { | 784 if (!is_mash) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 resolution_notification_controller_.reset( | 863 resolution_notification_controller_.reset( |
| 858 new ResolutionNotificationController); | 864 new ResolutionNotificationController); |
| 859 } | 865 } |
| 860 | 866 |
| 861 if (cursor_manager_) { | 867 if (cursor_manager_) { |
| 862 cursor_manager_->SetDisplay( | 868 cursor_manager_->SetDisplay( |
| 863 display::Screen::GetScreen()->GetPrimaryDisplay()); | 869 display::Screen::GetScreen()->GetPrimaryDisplay()); |
| 864 } | 870 } |
| 865 | 871 |
| 866 accelerator_controller_ = wm_shell_->CreateAcceleratorController(); | 872 accelerator_controller_ = wm_shell_->CreateAcceleratorController(); |
| 867 wm_shell_->CreateMaximizeModeController(); | 873 maximize_mode_controller_ = base::MakeUnique<MaximizeModeController>(); |
| 868 | 874 |
| 869 if (!is_mash) { | 875 if (!is_mash) { |
| 870 AddPreTargetHandler( | 876 AddPreTargetHandler( |
| 871 window_tree_host_manager_->input_method_event_handler()); | 877 window_tree_host_manager_->input_method_event_handler()); |
| 872 } | 878 } |
| 873 | 879 |
| 874 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); | 880 magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler(); |
| 875 AddPreTargetHandler(magnifier_key_scroll_handler_.get()); | 881 AddPreTargetHandler(magnifier_key_scroll_handler_.get()); |
| 876 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); | 882 speech_feedback_handler_ = SpokenFeedbackToggler::CreateHandler(); |
| 877 AddPreTargetHandler(speech_feedback_handler_.get()); | 883 AddPreTargetHandler(speech_feedback_handler_.get()); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 946 |
| 941 // Create Controllers that may need root window. | 947 // Create Controllers that may need root window. |
| 942 // TODO(oshima): Move as many controllers before creating | 948 // TODO(oshima): Move as many controllers before creating |
| 943 // RootWindowController as possible. | 949 // RootWindowController as possible. |
| 944 visibility_controller_.reset(new AshVisibilityController); | 950 visibility_controller_.reset(new AshVisibilityController); |
| 945 | 951 |
| 946 laser_pointer_controller_.reset(new LaserPointerController()); | 952 laser_pointer_controller_.reset(new LaserPointerController()); |
| 947 partial_magnification_controller_.reset(new PartialMagnificationController()); | 953 partial_magnification_controller_.reset(new PartialMagnificationController()); |
| 948 | 954 |
| 949 magnification_controller_.reset(MagnificationController::CreateInstance()); | 955 magnification_controller_.reset(MagnificationController::CreateInstance()); |
| 950 wm_shell_->CreateMruWindowTracker(); | 956 mru_window_tracker_ = base::MakeUnique<MruWindowTracker>(); |
| 951 | 957 |
| 952 autoclick_controller_.reset(AutoclickController::CreateInstance()); | 958 autoclick_controller_.reset(AutoclickController::CreateInstance()); |
| 953 | 959 |
| 954 high_contrast_controller_.reset(new HighContrastController); | 960 high_contrast_controller_.reset(new HighContrastController); |
| 955 video_detector_.reset(new VideoDetector); | 961 video_detector_.reset(new VideoDetector); |
| 956 | 962 |
| 957 tooltip_controller_.reset(new views::corewm::TooltipController( | 963 tooltip_controller_.reset(new views::corewm::TooltipController( |
| 958 std::unique_ptr<views::corewm::Tooltip>(new views::corewm::TooltipAura))); | 964 std::unique_ptr<views::corewm::Tooltip>(new views::corewm::TooltipAura))); |
| 959 AddPreTargetHandler(tooltip_controller_.get()); | 965 AddPreTargetHandler(tooltip_controller_.get()); |
| 960 | 966 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 void Shell::OnWindowActivated( | 1142 void Shell::OnWindowActivated( |
| 1137 aura::client::ActivationChangeObserver::ActivationReason reason, | 1143 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1138 aura::Window* gained_active, | 1144 aura::Window* gained_active, |
| 1139 aura::Window* lost_active) { | 1145 aura::Window* lost_active) { |
| 1140 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1146 WmWindow* gained_active_wm = WmWindow::Get(gained_active); |
| 1141 if (gained_active_wm) | 1147 if (gained_active_wm) |
| 1142 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | 1148 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); |
| 1143 } | 1149 } |
| 1144 | 1150 |
| 1145 } // namespace ash | 1151 } // namespace ash |
| OLD | NEW |