| 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/devtools/ash_devtools_css_agent.h" | 22 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 22 #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" |
| 23 #include "ash/common/frame/custom_frame_view_ash.h" | 25 #include "ash/common/frame/custom_frame_view_ash.h" |
| 24 #include "ash/common/gpu_support.h" | 26 #include "ash/common/gpu_support.h" |
| 25 #include "ash/common/keyboard/keyboard_ui.h" | 27 #include "ash/common/keyboard/keyboard_ui.h" |
| 26 #include "ash/common/login_status.h" | 28 #include "ash/common/login_status.h" |
| 27 #include "ash/common/palette_delegate.h" | 29 #include "ash/common/palette_delegate.h" |
| 28 #include "ash/common/session/session_state_delegate.h" | 30 #include "ash/common/session/session_state_delegate.h" |
| 29 #include "ash/common/shelf/wm_shelf.h" | 31 #include "ash/common/shelf/wm_shelf.h" |
| 30 #include "ash/common/shell_delegate.h" | 32 #include "ash/common/shell_delegate.h" |
| 31 #include "ash/common/shell_observer.h" | 33 #include "ash/common/shell_observer.h" |
| 34 #include "ash/common/system/brightness_control_delegate.h" |
| 32 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" | 35 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" |
| 36 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
| 37 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 33 #include "ash/common/system/chromeos/network/sms_observer.h" | 38 #include "ash/common/system/chromeos/network/sms_observer.h" |
| 34 #include "ash/common/system/chromeos/power/power_status.h" | 39 #include "ash/common/system/chromeos/power/power_status.h" |
| 40 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
| 41 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
| 42 #include "ash/common/system/locale/locale_notification_controller.h" |
| 35 #include "ash/common/system/status_area_widget.h" | 43 #include "ash/common/system/status_area_widget.h" |
| 36 #include "ash/common/system/toast/toast_manager.h" | 44 #include "ash/common/system/toast/toast_manager.h" |
| 45 #include "ash/common/system/tray/system_tray_controller.h" |
| 37 #include "ash/common/system/tray/system_tray_delegate.h" | 46 #include "ash/common/system/tray/system_tray_delegate.h" |
| 47 #include "ash/common/system/tray/system_tray_notifier.h" |
| 38 #include "ash/common/wallpaper/wallpaper_controller.h" | 48 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 39 #include "ash/common/wallpaper/wallpaper_delegate.h" | 49 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 40 #include "ash/common/wm/container_finder.h" | 50 #include "ash/common/wm/container_finder.h" |
| 41 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 51 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 42 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 52 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 43 #include "ash/common/wm/mru_window_tracker.h" | 53 #include "ash/common/wm/mru_window_tracker.h" |
| 44 #include "ash/common/wm/root_window_finder.h" | 54 #include "ash/common/wm/root_window_finder.h" |
| 45 #include "ash/common/wm/system_modal_container_layout_manager.h" | 55 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 46 #include "ash/common/wm/window_positioner.h" | 56 #include "ash/common/wm/window_positioner.h" |
| 47 #include "ash/common/wm/workspace_controller.h" | 57 #include "ash/common/wm/workspace_controller.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 342 } |
| 333 | 343 |
| 334 void Shell::CreateKeyboard() { | 344 void Shell::CreateKeyboard() { |
| 335 InitKeyboard(); | 345 InitKeyboard(); |
| 336 GetPrimaryRootWindowController()->ActivateKeyboard( | 346 GetPrimaryRootWindowController()->ActivateKeyboard( |
| 337 keyboard::KeyboardController::GetInstance()); | 347 keyboard::KeyboardController::GetInstance()); |
| 338 } | 348 } |
| 339 | 349 |
| 340 void Shell::DeactivateKeyboard() { | 350 void Shell::DeactivateKeyboard() { |
| 341 // TODO(jamescook): Move keyboard create and hide into WmShell. | 351 // TODO(jamescook): Move keyboard create and hide into WmShell. |
| 342 wm_shell_->keyboard_ui()->Hide(); | 352 keyboard_ui_->Hide(); |
| 343 if (keyboard::KeyboardController::GetInstance()) { | 353 if (keyboard::KeyboardController::GetInstance()) { |
| 344 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 354 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 345 for (RootWindowControllerList::iterator iter = controllers.begin(); | 355 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 346 iter != controllers.end(); ++iter) { | 356 iter != controllers.end(); ++iter) { |
| 347 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); | 357 (*iter)->DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); |
| 348 } | 358 } |
| 349 } | 359 } |
| 350 keyboard::KeyboardController::ResetInstance(nullptr); | 360 keyboard::KeyboardController::ResetInstance(nullptr); |
| 351 } | 361 } |
| 352 | 362 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 for (auto& observer : shell_observers_) | 508 for (auto& observer : shell_observers_) |
| 499 observer.OnShelfAutoHideBehaviorChanged(root_window); | 509 observer.OnShelfAutoHideBehaviorChanged(root_window); |
| 500 } | 510 } |
| 501 | 511 |
| 502 //////////////////////////////////////////////////////////////////////////////// | 512 //////////////////////////////////////////////////////////////////////////////// |
| 503 // Shell, private: | 513 // Shell, private: |
| 504 | 514 |
| 505 Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, | 515 Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate, |
| 506 std::unique_ptr<WmShell> wm_shell) | 516 std::unique_ptr<WmShell> wm_shell) |
| 507 : wm_shell_(std::move(wm_shell)), | 517 : wm_shell_(std::move(wm_shell)), |
| 518 brightness_control_delegate_( |
| 519 base::MakeUnique<system::BrightnessControllerChromeos>()), |
| 520 cast_config_(base::MakeUnique<CastConfigController>()), |
| 521 focus_cycler_(base::MakeUnique<FocusCycler>()), |
| 522 keyboard_brightness_control_delegate_( |
| 523 base::MakeUnique<KeyboardBrightnessController>()), |
| 524 locale_notification_controller_( |
| 525 base::MakeUnique<LocaleNotificationController>()), |
| 508 shell_delegate_(std::move(shell_delegate)), | 526 shell_delegate_(std::move(shell_delegate)), |
| 527 system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
| 509 app_list_(base::MakeUnique<app_list::AppList>()), | 528 app_list_(base::MakeUnique<app_list::AppList>()), |
| 510 link_handler_model_factory_(nullptr), | 529 link_handler_model_factory_(nullptr), |
| 511 display_configurator_(new display::DisplayConfigurator()), | 530 display_configurator_(new display::DisplayConfigurator()), |
| 512 native_cursor_manager_(nullptr), | 531 native_cursor_manager_(nullptr), |
| 513 simulate_modal_window_open_for_testing_(false), | 532 simulate_modal_window_open_for_testing_(false), |
| 514 is_touch_hud_projection_enabled_(false) { | 533 is_touch_hud_projection_enabled_(false) { |
| 515 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 534 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
| 516 // state on WmShellAura. http://crbug.com/671246. | 535 // state on WmShellAura. http://crbug.com/671246. |
| 517 | 536 |
| 518 if (!wm_shell_->IsRunningInMash()) { | 537 if (!wm_shell_->IsRunningInMash()) { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 602 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 584 // layout. | 603 // layout. |
| 585 DeactivateKeyboard(); | 604 DeactivateKeyboard(); |
| 586 | 605 |
| 587 toast_manager_.reset(); | 606 toast_manager_.reset(); |
| 588 | 607 |
| 589 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 608 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 590 // to deinitialize the shelf first, as it is initialized after the delegate. | 609 // to deinitialize the shelf first, as it is initialized after the delegate. |
| 591 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 610 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| 592 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); | 611 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); |
| 593 wm_shell_->DeleteSystemTrayDelegate(); | 612 DeleteSystemTrayDelegate(); |
| 594 | 613 |
| 595 // Drag-and-drop must be canceled prior to close all windows. | 614 // Drag-and-drop must be canceled prior to close all windows. |
| 596 drag_drop_controller_.reset(); | 615 drag_drop_controller_.reset(); |
| 597 | 616 |
| 598 // Controllers who have WindowObserver added must be deleted | 617 // Controllers who have WindowObserver added must be deleted |
| 599 // before |window_tree_host_manager_| is deleted. | 618 // before |window_tree_host_manager_| is deleted. |
| 600 | 619 |
| 601 // VideoActivityNotifier must be deleted before |video_detector_| is | 620 // VideoActivityNotifier must be deleted before |video_detector_| is |
| 602 // deleted because it's observing video activity through | 621 // deleted because it's observing video activity through |
| 603 // VideoDetector::Observer interface. | 622 // VideoDetector::Observer interface. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 event_client_.reset(new EventClientImpl); | 963 event_client_.reset(new EventClientImpl); |
| 945 | 964 |
| 946 session_state_delegate_.reset(shell_delegate_->CreateSessionStateDelegate()); | 965 session_state_delegate_.reset(shell_delegate_->CreateSessionStateDelegate()); |
| 947 // Must occur after Shell has installed its early pre-target handlers (for | 966 // Must occur after Shell has installed its early pre-target handlers (for |
| 948 // example, WindowModalityController). | 967 // example, WindowModalityController). |
| 949 wm_shell_->CreatePointerWatcherAdapter(); | 968 wm_shell_->CreatePointerWatcherAdapter(); |
| 950 | 969 |
| 951 resize_shadow_controller_.reset(new ResizeShadowController()); | 970 resize_shadow_controller_.reset(new ResizeShadowController()); |
| 952 shadow_controller_.reset(new ::wm::ShadowController(focus_controller_.get())); | 971 shadow_controller_.reset(new ::wm::ShadowController(focus_controller_.get())); |
| 953 | 972 |
| 954 wm_shell_->SetSystemTrayDelegate( | 973 SetSystemTrayDelegate( |
| 955 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); | 974 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); |
| 956 | 975 |
| 957 // Create AshTouchTransformController before | 976 // Create AshTouchTransformController before |
| 958 // WindowTreeHostManager::InitDisplays() | 977 // WindowTreeHostManager::InitDisplays() |
| 959 // since AshTouchTransformController listens on | 978 // since AshTouchTransformController listens on |
| 960 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). | 979 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
| 961 if (!is_mash) { | 980 if (!is_mash) { |
| 962 touch_transformer_controller_.reset(new AshTouchTransformController( | 981 touch_transformer_controller_.reset(new AshTouchTransformController( |
| 963 display_configurator_.get(), display_manager_.get())); | 982 display_configurator_.get(), display_manager_.get())); |
| 964 } | 983 } |
| 965 | 984 |
| 966 if (!is_mash) | 985 keyboard_ui_ = wm_shell_->CreateKeyboardUI(); |
| 967 wm_shell_->SetKeyboardUI(KeyboardUI::Create()); | |
| 968 | 986 |
| 969 wm_shell_->InitHosts(init_params); | 987 wm_shell_->InitHosts(init_params); |
| 970 | 988 |
| 971 // Needs to be created after InitDisplays() since it may cause the virtual | 989 // Needs to be created after InitDisplays() since it may cause the virtual |
| 972 // keyboard to be deployed. | 990 // keyboard to be deployed. |
| 973 if (!is_mash) | 991 if (!is_mash) |
| 974 virtual_keyboard_controller_.reset(new VirtualKeyboardController); | 992 virtual_keyboard_controller_.reset(new VirtualKeyboardController); |
| 975 | 993 |
| 976 audio_a11y_controller_.reset(new chromeos::AudioA11yController); | 994 audio_a11y_controller_.reset(new chromeos::AudioA11yController); |
| 977 | 995 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1042 aura::client::SetCursorClient(root_window, cursor_manager_.get()); | 1060 aura::client::SetCursorClient(root_window, cursor_manager_.get()); |
| 1043 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); | 1061 aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
| 1044 aura::client::SetEventClient(root_window, event_client_.get()); | 1062 aura::client::SetEventClient(root_window, event_client_.get()); |
| 1045 | 1063 |
| 1046 aura::client::SetWindowMoveClient(root_window, | 1064 aura::client::SetWindowMoveClient(root_window, |
| 1047 toplevel_window_event_handler_.get()); | 1065 toplevel_window_event_handler_.get()); |
| 1048 root_window->AddPreTargetHandler(toplevel_window_event_handler_.get()); | 1066 root_window->AddPreTargetHandler(toplevel_window_event_handler_.get()); |
| 1049 root_window->AddPostTargetHandler(toplevel_window_event_handler_.get()); | 1067 root_window->AddPostTargetHandler(toplevel_window_event_handler_.get()); |
| 1050 } | 1068 } |
| 1051 | 1069 |
| 1070 void Shell::SetSystemTrayDelegate( |
| 1071 std::unique_ptr<SystemTrayDelegate> delegate) { |
| 1072 DCHECK(delegate); |
| 1073 system_tray_delegate_ = std::move(delegate); |
| 1074 system_tray_delegate_->Initialize(); |
| 1075 // Accesses WmShell in its constructor. |
| 1076 logout_confirmation_controller_.reset(new LogoutConfirmationController( |
| 1077 base::Bind(&SystemTrayController::SignOut, |
| 1078 base::Unretained(system_tray_controller_.get())))); |
| 1079 } |
| 1080 |
| 1081 void Shell::DeleteSystemTrayDelegate() { |
| 1082 DCHECK(system_tray_delegate_); |
| 1083 // Accesses WmShell in its destructor. |
| 1084 logout_confirmation_controller_.reset(); |
| 1085 system_tray_delegate_.reset(); |
| 1086 } |
| 1087 |
| 1052 void Shell::CloseAllRootWindowChildWindows() { | 1088 void Shell::CloseAllRootWindowChildWindows() { |
| 1053 for (WmWindow* wm_root_window : wm_shell_->GetAllRootWindows()) { | 1089 for (WmWindow* wm_root_window : wm_shell_->GetAllRootWindows()) { |
| 1054 aura::Window* root_window = wm_root_window->aura_window(); | 1090 aura::Window* root_window = wm_root_window->aura_window(); |
| 1055 RootWindowController* controller = GetRootWindowController(root_window); | 1091 RootWindowController* controller = GetRootWindowController(root_window); |
| 1056 if (controller) { | 1092 if (controller) { |
| 1057 controller->CloseChildWindows(); | 1093 controller->CloseChildWindows(); |
| 1058 } else { | 1094 } else { |
| 1059 while (!root_window->children().empty()) { | 1095 while (!root_window->children().empty()) { |
| 1060 aura::Window* child = root_window->children()[0]; | 1096 aura::Window* child = root_window->children()[0]; |
| 1061 delete child; | 1097 delete child; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 void Shell::OnWindowActivated( | 1132 void Shell::OnWindowActivated( |
| 1097 aura::client::ActivationChangeObserver::ActivationReason reason, | 1133 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1098 aura::Window* gained_active, | 1134 aura::Window* gained_active, |
| 1099 aura::Window* lost_active) { | 1135 aura::Window* lost_active) { |
| 1100 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1136 WmWindow* gained_active_wm = WmWindow::Get(gained_active); |
| 1101 if (gained_active_wm) | 1137 if (gained_active_wm) |
| 1102 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | 1138 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); |
| 1103 } | 1139 } |
| 1104 | 1140 |
| 1105 } // namespace ash | 1141 } // namespace ash |
| OLD | NEW |