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