| 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 |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 244 } |
| 245 | 245 |
| 246 // static | 246 // static |
| 247 void Shell::DeleteInstance() { | 247 void Shell::DeleteInstance() { |
| 248 delete instance_; | 248 delete instance_; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // static | 251 // static |
| 252 RootWindowController* Shell::GetPrimaryRootWindowController() { | 252 RootWindowController* Shell::GetPrimaryRootWindowController() { |
| 253 CHECK(HasInstance()); | 253 CHECK(HasInstance()); |
| 254 return GetRootWindowController(GetPrimaryRootWindow()); | 254 return RootWindowController::ForWindow(GetPrimaryRootWindow()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // static | 257 // static |
| 258 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { | 258 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
| 259 CHECK(HasInstance()); | 259 CHECK(HasInstance()); |
| 260 RootWindowControllerList root_window_controllers; | 260 RootWindowControllerList root_window_controllers; |
| 261 for (WmWindow* root_window : instance_->shell_port_->GetAllRootWindows()) | 261 for (aura::Window* root : GetAllRootWindows()) |
| 262 root_window_controllers.push_back(root_window->GetRootWindowController()); | 262 root_window_controllers.push_back(RootWindowController::ForWindow(root)); |
| 263 return root_window_controllers; | 263 return root_window_controllers; |
| 264 } | 264 } |
| 265 | 265 |
| 266 // static | 266 // static |
| 267 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( | 267 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( |
| 268 int64_t display_id) { | 268 int64_t display_id) { |
| 269 CHECK(HasInstance()); | 269 CHECK(HasInstance()); |
| 270 aura::Window* root_window = | 270 aura::Window* root_window = |
| 271 instance_->shell_port_->GetRootWindowForDisplayId(display_id); | 271 instance_->shell_port_->GetRootWindowForDisplayId(display_id); |
| 272 return GetRootWindowController(root_window); | 272 return RootWindowController::ForWindow(root_window); |
| 273 } | 273 } |
| 274 | 274 |
| 275 // static | 275 // static |
| 276 aura::Window* Shell::GetPrimaryRootWindow() { | 276 aura::Window* Shell::GetPrimaryRootWindow() { |
| 277 CHECK(HasInstance()); | 277 CHECK(HasInstance()); |
| 278 return instance_->shell_port_->GetPrimaryRootWindow(); | 278 return instance_->shell_port_->GetPrimaryRootWindow(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 // static | 281 // static |
| 282 aura::Window* Shell::GetRootWindowForNewWindows() { | 282 aura::Window* Shell::GetRootWindowForNewWindows() { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 ShelfModel* Shell::shelf_model() { | 380 ShelfModel* Shell::shelf_model() { |
| 381 return shelf_controller_->model(); | 381 return shelf_controller_->model(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 ::wm::ActivationClient* Shell::activation_client() { | 384 ::wm::ActivationClient* Shell::activation_client() { |
| 385 return focus_controller_.get(); | 385 return focus_controller_.get(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void Shell::UpdateShelfVisibility() { | 388 void Shell::UpdateShelfVisibility() { |
| 389 for (WmWindow* root : shell_port_->GetAllRootWindows()) | 389 for (aura::Window* root : GetAllRootWindows()) |
| 390 root->GetRootWindowController()->shelf()->UpdateVisibilityState(); | 390 Shelf::ForWindow(root)->UpdateVisibilityState(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 PrefService* Shell::GetActiveUserPrefService() const { | 393 PrefService* Shell::GetActiveUserPrefService() const { |
| 394 if (shell_port_->GetAshConfig() == Config::MASH) | 394 if (shell_port_->GetAshConfig() == Config::MASH) |
| 395 return pref_service_.get(); | 395 return pref_service_.get(); |
| 396 | 396 |
| 397 return shell_delegate_->GetActiveUserPrefService(); | 397 return shell_delegate_->GetActiveUserPrefService(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 WebNotificationTray* Shell::GetWebNotificationTray() { | 400 WebNotificationTray* Shell::GetWebNotificationTray() { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 473 |
| 474 bool Shell::IsAppListVisible() const { | 474 bool Shell::IsAppListVisible() const { |
| 475 return app_list_->IsVisible(); | 475 return app_list_->IsVisible(); |
| 476 } | 476 } |
| 477 | 477 |
| 478 bool Shell::GetAppListTargetVisibility() const { | 478 bool Shell::GetAppListTargetVisibility() const { |
| 479 return app_list_->GetTargetVisibility(); | 479 return app_list_->GetTargetVisibility(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { |
| 483 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 483 for (RootWindowController* controller : GetAllRootWindowControllers()) |
| 484 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 484 controller->UpdateAfterLoginStatusChange(status); |
| 485 status); | |
| 486 } | |
| 487 } | 485 } |
| 488 | 486 |
| 489 void Shell::NotifyMaximizeModeStarted() { | 487 void Shell::NotifyMaximizeModeStarted() { |
| 490 for (auto& observer : shell_observers_) | 488 for (auto& observer : shell_observers_) |
| 491 observer.OnMaximizeModeStarted(); | 489 observer.OnMaximizeModeStarted(); |
| 492 } | 490 } |
| 493 | 491 |
| 494 void Shell::NotifyMaximizeModeEnding() { | 492 void Shell::NotifyMaximizeModeEnding() { |
| 495 for (auto& observer : shell_observers_) | 493 for (auto& observer : shell_observers_) |
| 496 observer.OnMaximizeModeEnding(); | 494 observer.OnMaximizeModeEnding(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 maximize_mode_controller_.reset(); | 654 maximize_mode_controller_.reset(); |
| 657 | 655 |
| 658 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 656 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 659 // layout. | 657 // layout. |
| 660 DeactivateKeyboard(); | 658 DeactivateKeyboard(); |
| 661 | 659 |
| 662 toast_manager_.reset(); | 660 toast_manager_.reset(); |
| 663 | 661 |
| 664 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 662 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 665 // to deinitialize the shelf first, as it is initialized after the delegate. | 663 // to deinitialize the shelf first, as it is initialized after the delegate. |
| 666 for (WmWindow* root : shell_port_->GetAllRootWindows()) | 664 for (aura::Window* root : GetAllRootWindows()) |
| 667 root->GetRootWindowController()->shelf()->ShutdownShelfWidget(); | 665 Shelf::ForWindow(root)->ShutdownShelfWidget(); |
| 668 tray_bluetooth_helper_.reset(); | 666 tray_bluetooth_helper_.reset(); |
| 669 DeleteSystemTrayDelegate(); | 667 DeleteSystemTrayDelegate(); |
| 670 | 668 |
| 671 // Drag-and-drop must be canceled prior to close all windows. | 669 // Drag-and-drop must be canceled prior to close all windows. |
| 672 drag_drop_controller_.reset(); | 670 drag_drop_controller_.reset(); |
| 673 | 671 |
| 674 // Controllers who have WindowObserver added must be deleted | 672 // Controllers who have WindowObserver added must be deleted |
| 675 // before |window_tree_host_manager_| is deleted. | 673 // before |window_tree_host_manager_| is deleted. |
| 676 | 674 |
| 677 // VideoActivityNotifier must be deleted before |video_detector_| is | 675 // VideoActivityNotifier must be deleted before |video_detector_| is |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 mouse_cursor_filter_.reset(); | 712 mouse_cursor_filter_.reset(); |
| 715 modality_filter_.reset(); | 713 modality_filter_.reset(); |
| 716 | 714 |
| 717 touch_transformer_controller_.reset(); | 715 touch_transformer_controller_.reset(); |
| 718 audio_a11y_controller_.reset(); | 716 audio_a11y_controller_.reset(); |
| 719 laser_pointer_controller_.reset(); | 717 laser_pointer_controller_.reset(); |
| 720 partial_magnification_controller_.reset(); | 718 partial_magnification_controller_.reset(); |
| 721 | 719 |
| 722 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 720 // This also deletes all RootWindows. Note that we invoke Shutdown() on |
| 723 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 721 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
| 724 // destruction | 722 // destruction of its owned RootWindowControllers relies on the value. |
| 725 // of its owned RootWindowControllers relies on the value. | |
| 726 ScreenAsh::CreateScreenForShutdown(); | 723 ScreenAsh::CreateScreenForShutdown(); |
| 727 display_configuration_controller_.reset(); | 724 display_configuration_controller_.reset(); |
| 728 | 725 |
| 729 // AppListDelegateImpl depends upon AppList. | 726 // AppListDelegateImpl depends upon AppList. |
| 730 app_list_delegate_impl_.reset(); | 727 app_list_delegate_impl_.reset(); |
| 731 | 728 |
| 732 // These members access Shell in their destructors. | 729 // These members access Shell in their destructors. |
| 733 wallpaper_controller_.reset(); | 730 wallpaper_controller_.reset(); |
| 734 accessibility_delegate_.reset(); | 731 accessibility_delegate_.reset(); |
| 735 | 732 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 } | 1157 } |
| 1161 | 1158 |
| 1162 void Shell::DeleteSystemTrayDelegate() { | 1159 void Shell::DeleteSystemTrayDelegate() { |
| 1163 DCHECK(system_tray_delegate_); | 1160 DCHECK(system_tray_delegate_); |
| 1164 // Accesses ShellPort in its destructor. | 1161 // Accesses ShellPort in its destructor. |
| 1165 logout_confirmation_controller_.reset(); | 1162 logout_confirmation_controller_.reset(); |
| 1166 system_tray_delegate_.reset(); | 1163 system_tray_delegate_.reset(); |
| 1167 } | 1164 } |
| 1168 | 1165 |
| 1169 void Shell::CloseAllRootWindowChildWindows() { | 1166 void Shell::CloseAllRootWindowChildWindows() { |
| 1170 for (WmWindow* wm_root_window : shell_port_->GetAllRootWindows()) { | 1167 for (aura::Window* root : GetAllRootWindows()) { |
| 1171 aura::Window* root_window = wm_root_window->aura_window(); | 1168 RootWindowController* controller = RootWindowController::ForWindow(root); |
| 1172 RootWindowController* controller = GetRootWindowController(root_window); | |
| 1173 if (controller) { | 1169 if (controller) { |
| 1174 controller->CloseChildWindows(); | 1170 controller->CloseChildWindows(); |
| 1175 } else { | 1171 } else { |
| 1176 while (!root_window->children().empty()) { | 1172 while (!root->children().empty()) { |
| 1177 aura::Window* child = root_window->children()[0]; | 1173 aura::Window* child = root->children()[0]; |
| 1178 delete child; | 1174 delete child; |
| 1179 } | 1175 } |
| 1180 } | 1176 } |
| 1181 } | 1177 } |
| 1182 } | 1178 } |
| 1183 | 1179 |
| 1184 bool Shell::CanWindowReceiveEvents(aura::Window* window) { | 1180 bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 1185 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 1181 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 1186 for (RootWindowController* controller : controllers) { | 1182 for (RootWindowController* controller : controllers) { |
| 1187 if (controller->CanWindowReceiveEvents(window)) | 1183 if (controller->CanWindowReceiveEvents(window)) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 void Shell::OnPrefServiceInitialized( | 1261 void Shell::OnPrefServiceInitialized( |
| 1266 std::unique_ptr<::PrefService> pref_service) { | 1262 std::unique_ptr<::PrefService> pref_service) { |
| 1267 if (!instance_) | 1263 if (!instance_) |
| 1268 return; | 1264 return; |
| 1269 // |pref_service_| is null if can't connect to Chrome (as happens when | 1265 // |pref_service_| is null if can't connect to Chrome (as happens when |
| 1270 // running mash outside of chrome --mash and chrome isn't built). | 1266 // running mash outside of chrome --mash and chrome isn't built). |
| 1271 pref_service_ = std::move(pref_service); | 1267 pref_service_ = std::move(pref_service); |
| 1272 } | 1268 } |
| 1273 | 1269 |
| 1274 } // namespace ash | 1270 } // namespace ash |
| OLD | NEW |