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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 #include "ash/wm/system_modal_container_event_filter.h" | 110 #include "ash/wm/system_modal_container_event_filter.h" |
111 #include "ash/wm/system_modal_container_layout_manager.h" | 111 #include "ash/wm/system_modal_container_layout_manager.h" |
112 #include "ash/wm/toplevel_window_event_handler.h" | 112 #include "ash/wm/toplevel_window_event_handler.h" |
113 #include "ash/wm/video_detector.h" | 113 #include "ash/wm/video_detector.h" |
114 #include "ash/wm/window_animations.h" | 114 #include "ash/wm/window_animations.h" |
115 #include "ash/wm/window_cycle_controller.h" | 115 #include "ash/wm/window_cycle_controller.h" |
116 #include "ash/wm/window_positioner.h" | 116 #include "ash/wm/window_positioner.h" |
117 #include "ash/wm/window_properties.h" | 117 #include "ash/wm/window_properties.h" |
118 #include "ash/wm/window_util.h" | 118 #include "ash/wm/window_util.h" |
119 #include "ash/wm/workspace_controller.h" | 119 #include "ash/wm/workspace_controller.h" |
120 #include "ash/wm_window.h" | |
121 #include "base/bind.h" | 120 #include "base/bind.h" |
122 #include "base/bind_helpers.h" | 121 #include "base/bind_helpers.h" |
123 #include "base/command_line.h" | 122 #include "base/command_line.h" |
124 #include "base/memory/ptr_util.h" | 123 #include "base/memory/ptr_util.h" |
125 #include "base/sys_info.h" | 124 #include "base/sys_info.h" |
126 #include "base/threading/sequenced_worker_pool.h" | 125 #include "base/threading/sequenced_worker_pool.h" |
127 #include "base/trace_event/trace_event.h" | 126 #include "base/trace_event/trace_event.h" |
128 #include "chromeos/audio/audio_a11y_controller.h" | 127 #include "chromeos/audio/audio_a11y_controller.h" |
129 #include "chromeos/chromeos_switches.h" | 128 #include "chromeos/chromeos_switches.h" |
130 #include "chromeos/dbus/dbus_thread_manager.h" | 129 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // static | 250 // static |
252 RootWindowController* Shell::GetPrimaryRootWindowController() { | 251 RootWindowController* Shell::GetPrimaryRootWindowController() { |
253 CHECK(HasInstance()); | 252 CHECK(HasInstance()); |
254 return GetRootWindowController(GetPrimaryRootWindow()); | 253 return GetRootWindowController(GetPrimaryRootWindow()); |
255 } | 254 } |
256 | 255 |
257 // static | 256 // static |
258 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { | 257 Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
259 CHECK(HasInstance()); | 258 CHECK(HasInstance()); |
260 RootWindowControllerList root_window_controllers; | 259 RootWindowControllerList root_window_controllers; |
261 for (WmWindow* root_window : instance_->shell_port_->GetAllRootWindows()) | 260 for (aura::Window* root_window : |
262 root_window_controllers.push_back(root_window->GetRootWindowController()); | 261 instance_->shell_port_->GetAllRootWindows()) { |
| 262 root_window_controllers.push_back( |
| 263 RootWindowController::ForWindow(root_window)); |
| 264 } |
263 return root_window_controllers; | 265 return root_window_controllers; |
264 } | 266 } |
265 | 267 |
266 // static | 268 // static |
267 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( | 269 RootWindowController* Shell::GetRootWindowControllerWithDisplayId( |
268 int64_t display_id) { | 270 int64_t display_id) { |
269 CHECK(HasInstance()); | 271 CHECK(HasInstance()); |
270 aura::Window* root_window = | 272 aura::Window* root_window = |
271 instance_->shell_port_->GetRootWindowForDisplayId(display_id); | 273 instance_->shell_port_->GetRootWindowForDisplayId(display_id); |
272 return GetRootWindowController(root_window); | 274 return GetRootWindowController(root_window); |
(...skipping 10 matching lines...) Expand all Loading... |
283 CHECK(Shell::HasInstance()); | 285 CHECK(Shell::HasInstance()); |
284 Shell* shell = Shell::Get(); | 286 Shell* shell = Shell::Get(); |
285 if (shell->scoped_root_window_for_new_windows_) | 287 if (shell->scoped_root_window_for_new_windows_) |
286 return shell->scoped_root_window_for_new_windows_; | 288 return shell->scoped_root_window_for_new_windows_; |
287 return shell->root_window_for_new_windows_; | 289 return shell->root_window_for_new_windows_; |
288 } | 290 } |
289 | 291 |
290 // static | 292 // static |
291 aura::Window::Windows Shell::GetAllRootWindows() { | 293 aura::Window::Windows Shell::GetAllRootWindows() { |
292 CHECK(HasInstance()); | 294 CHECK(HasInstance()); |
293 aura::Window::Windows windows; | 295 return instance_->shell_port_->GetAllRootWindows(); |
294 for (WmWindow* window : instance_->shell_port_->GetAllRootWindows()) | |
295 windows.push_back(window->aura_window()); | |
296 return windows; | |
297 } | 296 } |
298 | 297 |
299 // static | 298 // static |
300 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { | 299 aura::Window* Shell::GetContainer(aura::Window* root_window, int container_id) { |
301 return root_window->GetChildById(container_id); | 300 return root_window->GetChildById(container_id); |
302 } | 301 } |
303 | 302 |
304 // static | 303 // static |
305 const aura::Window* Shell::GetContainer(const aura::Window* root_window, | 304 const aura::Window* Shell::GetContainer(const aura::Window* root_window, |
306 int container_id) { | 305 int container_id) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 378 |
380 ShelfModel* Shell::shelf_model() { | 379 ShelfModel* Shell::shelf_model() { |
381 return shelf_controller_->model(); | 380 return shelf_controller_->model(); |
382 } | 381 } |
383 | 382 |
384 ::wm::ActivationClient* Shell::activation_client() { | 383 ::wm::ActivationClient* Shell::activation_client() { |
385 return focus_controller_.get(); | 384 return focus_controller_.get(); |
386 } | 385 } |
387 | 386 |
388 void Shell::UpdateShelfVisibility() { | 387 void Shell::UpdateShelfVisibility() { |
389 for (WmWindow* root : shell_port_->GetAllRootWindows()) | 388 for (auto* root_window_controller : GetAllRootWindowControllers()) |
390 root->GetRootWindowController()->shelf()->UpdateVisibilityState(); | 389 root_window_controller->shelf()->UpdateVisibilityState(); |
391 } | 390 } |
392 | 391 |
393 PrefService* Shell::GetActiveUserPrefService() const { | 392 PrefService* Shell::GetActiveUserPrefService() const { |
394 if (shell_port_->GetAshConfig() == Config::MASH) | 393 if (shell_port_->GetAshConfig() == Config::MASH) |
395 return pref_service_.get(); | 394 return pref_service_.get(); |
396 | 395 |
397 return shell_delegate_->GetActiveUserPrefService(); | 396 return shell_delegate_->GetActiveUserPrefService(); |
398 } | 397 } |
399 | 398 |
400 WebNotificationTray* Shell::GetWebNotificationTray() { | 399 WebNotificationTray* Shell::GetWebNotificationTray() { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 472 |
474 bool Shell::IsAppListVisible() const { | 473 bool Shell::IsAppListVisible() const { |
475 return app_list_->IsVisible(); | 474 return app_list_->IsVisible(); |
476 } | 475 } |
477 | 476 |
478 bool Shell::GetAppListTargetVisibility() const { | 477 bool Shell::GetAppListTargetVisibility() const { |
479 return app_list_->GetTargetVisibility(); | 478 return app_list_->GetTargetVisibility(); |
480 } | 479 } |
481 | 480 |
482 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { | 481 void Shell::UpdateAfterLoginStatusChange(LoginStatus status) { |
483 for (WmWindow* root_window : shell_port_->GetAllRootWindows()) { | 482 for (auto* root_window_controller : GetAllRootWindowControllers()) |
484 root_window->GetRootWindowController()->UpdateAfterLoginStatusChange( | 483 root_window_controller->UpdateAfterLoginStatusChange(status); |
485 status); | |
486 } | |
487 } | 484 } |
488 | 485 |
489 void Shell::NotifyMaximizeModeStarted() { | 486 void Shell::NotifyMaximizeModeStarted() { |
490 for (auto& observer : shell_observers_) | 487 for (auto& observer : shell_observers_) |
491 observer.OnMaximizeModeStarted(); | 488 observer.OnMaximizeModeStarted(); |
492 } | 489 } |
493 | 490 |
494 void Shell::NotifyMaximizeModeEnding() { | 491 void Shell::NotifyMaximizeModeEnding() { |
495 for (auto& observer : shell_observers_) | 492 for (auto& observer : shell_observers_) |
496 observer.OnMaximizeModeEnding(); | 493 observer.OnMaximizeModeEnding(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 maximize_mode_controller_.reset(); | 653 maximize_mode_controller_.reset(); |
657 | 654 |
658 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 655 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
659 // layout. | 656 // layout. |
660 DeactivateKeyboard(); | 657 DeactivateKeyboard(); |
661 | 658 |
662 toast_manager_.reset(); | 659 toast_manager_.reset(); |
663 | 660 |
664 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 661 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
665 // to deinitialize the shelf first, as it is initialized after the delegate. | 662 // to deinitialize the shelf first, as it is initialized after the delegate. |
666 for (WmWindow* root : shell_port_->GetAllRootWindows()) | 663 for (auto* root_window_controller : GetAllRootWindowControllers()) |
667 root->GetRootWindowController()->shelf()->ShutdownShelfWidget(); | 664 root_window_controller->shelf()->ShutdownShelfWidget(); |
668 tray_bluetooth_helper_.reset(); | 665 tray_bluetooth_helper_.reset(); |
669 DeleteSystemTrayDelegate(); | 666 DeleteSystemTrayDelegate(); |
670 | 667 |
671 // Drag-and-drop must be canceled prior to close all windows. | 668 // Drag-and-drop must be canceled prior to close all windows. |
672 drag_drop_controller_.reset(); | 669 drag_drop_controller_.reset(); |
673 | 670 |
674 // Controllers who have WindowObserver added must be deleted | 671 // Controllers who have WindowObserver added must be deleted |
675 // before |window_tree_host_manager_| is deleted. | 672 // before |window_tree_host_manager_| is deleted. |
676 | 673 |
677 // VideoActivityNotifier must be deleted before |video_detector_| is | 674 // VideoActivityNotifier must be deleted before |video_detector_| is |
(...skipping 482 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_window : shell_port_->GetAllRootWindows()) { |
1171 aura::Window* root_window = wm_root_window->aura_window(); | |
1172 RootWindowController* controller = GetRootWindowController(root_window); | 1168 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_window->children().empty()) { |
1177 aura::Window* child = root_window->children()[0]; | 1173 aura::Window* child = root_window->children()[0]; |
1178 delete child; | 1174 delete child; |
1179 } | 1175 } |
1180 } | 1176 } |
1181 } | 1177 } |
(...skipping 83 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 |