Chromium Code Reviews| 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_controller_delegate_aura.h" | 11 #include "ash/accelerators/accelerator_controller_delegate_aura.h" |
| 12 #include "ash/accelerators/accelerator_delegate.h" | 12 #include "ash/accelerators/accelerator_delegate.h" |
| 13 #include "ash/aura/wm_shell_aura.h" | 13 #include "ash/aura/wm_shell_aura.h" |
| 14 #include "ash/aura/wm_window_aura.h" | 14 #include "ash/aura/wm_window_aura.h" |
| 15 #include "ash/autoclick/autoclick_controller.h" | 15 #include "ash/autoclick/autoclick_controller.h" |
| 16 #include "ash/common/accelerators/accelerator_controller.h" | 16 #include "ash/common/accelerators/accelerator_controller.h" |
| 17 #include "ash/common/ash_switches.h" | 17 #include "ash/common/ash_switches.h" |
| 18 #include "ash/common/frame/custom_frame_view_ash.h" | 18 #include "ash/common/frame/custom_frame_view_ash.h" |
| 19 #include "ash/common/gpu_support.h" | 19 #include "ash/common/gpu_support.h" |
| 20 #include "ash/common/keyboard/keyboard_ui.h" | 20 #include "ash/common/keyboard/keyboard_ui.h" |
| 21 #include "ash/common/login_status.h" | 21 #include "ash/common/login_status.h" |
| 22 #include "ash/common/session/session_state_delegate.h" | 22 #include "ash/common/session/session_state_delegate.h" |
| 23 #include "ash/common/shelf/app_list_shelf_item_delegate.h" | 23 #include "ash/common/shelf/app_list_shelf_item_delegate.h" |
| 24 #include "ash/common/shelf/shelf_delegate.h" | 24 #include "ash/common/shelf/shelf_delegate.h" |
| 25 #include "ash/common/shelf/shelf_item_delegate.h" | 25 #include "ash/common/shelf/shelf_item_delegate.h" |
| 26 #include "ash/common/shelf/shelf_model.h" | 26 #include "ash/common/shelf/shelf_model.h" |
| 27 #include "ash/common/shelf/shelf_widget.h" | 27 #include "ash/common/shelf/wm_shelf.h" |
| 28 #include "ash/common/shell_delegate.h" | 28 #include "ash/common/shell_delegate.h" |
| 29 #include "ash/common/shell_window_ids.h" | 29 #include "ash/common/shell_window_ids.h" |
| 30 #include "ash/common/system/locale/locale_notification_controller.h" | 30 #include "ash/common/system/locale/locale_notification_controller.h" |
| 31 #include "ash/common/system/status_area_widget.h" | 31 #include "ash/common/system/status_area_widget.h" |
| 32 #include "ash/common/system/tray/system_tray_delegate.h" | 32 #include "ash/common/system/tray/system_tray_delegate.h" |
| 33 #include "ash/common/wallpaper/wallpaper_delegate.h" | 33 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 34 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 34 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 35 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 35 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 36 #include "ash/common/wm/mru_window_tracker.h" | 36 #include "ash/common/wm/mru_window_tracker.h" |
| 37 #include "ash/common/wm/root_window_finder.h" | 37 #include "ash/common/wm/root_window_finder.h" |
| 38 #include "ash/common/wm/window_positioner.h" | 38 #include "ash/common/wm/window_positioner.h" |
| 39 #include "ash/common/wm/workspace_controller.h" | 39 #include "ash/common/wm/workspace_controller.h" |
| 40 #include "ash/common/wm_root_window_controller.h" | |
| 40 #include "ash/common/wm_shell.h" | 41 #include "ash/common/wm_shell.h" |
| 41 #include "ash/display/cursor_window_controller.h" | 42 #include "ash/display/cursor_window_controller.h" |
| 42 #include "ash/display/display_configuration_controller.h" | 43 #include "ash/display/display_configuration_controller.h" |
| 43 #include "ash/display/display_manager.h" | 44 #include "ash/display/display_manager.h" |
| 44 #include "ash/display/event_transformation_handler.h" | 45 #include "ash/display/event_transformation_handler.h" |
| 45 #include "ash/display/mouse_cursor_event_filter.h" | 46 #include "ash/display/mouse_cursor_event_filter.h" |
| 46 #include "ash/display/screen_position_controller.h" | 47 #include "ash/display/screen_position_controller.h" |
| 47 #include "ash/display/window_tree_host_manager.h" | 48 #include "ash/display/window_tree_host_manager.h" |
| 48 #include "ash/drag_drop/drag_drop_controller.h" | 49 #include "ash/drag_drop/drag_drop_controller.h" |
| 49 #include "ash/first_run/first_run_helper_impl.h" | 50 #include "ash/first_run/first_run_helper_impl.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 keyboard::KeyboardController::ResetInstance(nullptr); | 399 keyboard::KeyboardController::ResetInstance(nullptr); |
| 399 } | 400 } |
| 400 | 401 |
| 401 void Shell::ShowShelf() { | 402 void Shell::ShowShelf() { |
| 402 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 403 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 403 for (RootWindowControllerList::iterator iter = controllers.begin(); | 404 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 404 iter != controllers.end(); ++iter) | 405 iter != controllers.end(); ++iter) |
| 405 (*iter)->ShowShelf(); | 406 (*iter)->ShowShelf(); |
| 406 } | 407 } |
| 407 | 408 |
| 408 void Shell::ShutdownShelf() { | |
| 409 RootWindowControllerList controllers = GetAllRootWindowControllers(); | |
| 410 for (RootWindowControllerList::iterator iter = controllers.begin(); | |
| 411 iter != controllers.end(); ++iter) { | |
| 412 if ((*iter)->shelf_widget()) | |
| 413 (*iter)->shelf_widget()->Shutdown(); | |
| 414 } | |
| 415 } | |
| 416 | |
| 417 #if defined(OS_CHROMEOS) | 409 #if defined(OS_CHROMEOS) |
| 418 bool Shell::ShouldSaveDisplaySettings() { | 410 bool Shell::ShouldSaveDisplaySettings() { |
| 419 return !( | 411 return !( |
| 420 screen_orientation_controller_->ignore_display_configuration_updates() || | 412 screen_orientation_controller_->ignore_display_configuration_updates() || |
| 421 resolution_notification_controller_->DoesNotificationTimeout()); | 413 resolution_notification_controller_->DoesNotificationTimeout()); |
| 422 } | 414 } |
| 423 #endif | 415 #endif |
| 424 | 416 |
| 425 void Shell::UpdateShelfVisibility() { | 417 void Shell::UpdateShelfVisibility() { |
| 426 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 418 for (WmWindow* root : wm_shell_->GetAllRootWindows()) { |
|
msw
2016/08/31 23:01:39
optional nit: no curlies
James Cook
2016/08/31 23:33:45
Done.
| |
| 427 for (RootWindowControllerList::iterator iter = controllers.begin(); | 419 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); |
| 428 iter != controllers.end(); ++iter) | 420 } |
| 429 if ((*iter)->shelf_widget()) | |
| 430 (*iter)->UpdateShelfVisibility(); | |
| 431 } | 421 } |
| 432 | 422 |
| 433 void Shell::CreateModalBackground(aura::Window* window) { | 423 void Shell::CreateModalBackground(aura::Window* window) { |
| 434 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 424 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 435 for (RootWindowControllerList::iterator iter = controllers.begin(); | 425 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 436 iter != controllers.end(); ++iter) | 426 iter != controllers.end(); ++iter) |
| 437 (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); | 427 (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); |
| 438 } | 428 } |
| 439 | 429 |
| 440 void Shell::OnModalWindowRemoved(aura::Window* removed) { | 430 void Shell::OnModalWindowRemoved(aura::Window* removed) { |
| 441 RootWindowControllerList controllers = GetAllRootWindowControllers(); | 431 RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 442 bool activated = false; | 432 bool activated = false; |
| 443 for (RootWindowControllerList::iterator iter = controllers.begin(); | 433 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 444 iter != controllers.end() && !activated; ++iter) { | 434 iter != controllers.end() && !activated; ++iter) { |
| 445 activated = (*iter) | 435 activated = (*iter) |
| 446 ->GetSystemModalLayoutManager(removed) | 436 ->GetSystemModalLayoutManager(removed) |
| 447 ->ActivateNextModalWindow(); | 437 ->ActivateNextModalWindow(); |
| 448 } | 438 } |
| 449 if (!activated) { | 439 if (!activated) { |
| 450 for (RootWindowControllerList::iterator iter = controllers.begin(); | 440 for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 451 iter != controllers.end(); ++iter) | 441 iter != controllers.end(); ++iter) |
| 452 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); | 442 (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
| 453 } | 443 } |
| 454 } | 444 } |
| 455 | 445 |
| 456 WebNotificationTray* Shell::GetWebNotificationTray() { | 446 WebNotificationTray* Shell::GetWebNotificationTray() { |
| 457 return GetPrimaryRootWindowController() | 447 return GetPrimaryRootWindowController() |
| 458 ->shelf_widget() | 448 ->GetStatusAreaWidget() |
| 459 ->status_area_widget() | |
| 460 ->web_notification_tray(); | 449 ->web_notification_tray(); |
| 461 } | 450 } |
| 462 | 451 |
| 463 bool Shell::HasPrimaryStatusArea() { | 452 bool Shell::HasPrimaryStatusArea() { |
| 464 ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf_widget(); | 453 return !!GetPrimaryRootWindowController()->GetStatusAreaWidget(); |
| 465 return shelf && shelf->status_area_widget(); | |
| 466 } | 454 } |
| 467 | 455 |
| 468 SystemTray* Shell::GetPrimarySystemTray() { | 456 SystemTray* Shell::GetPrimarySystemTray() { |
| 469 return GetPrimaryRootWindowController()->GetSystemTray(); | 457 return GetPrimaryRootWindowController()->GetSystemTray(); |
| 470 } | 458 } |
| 471 | 459 |
| 472 void Shell::SetTouchHudProjectionEnabled(bool enabled) { | 460 void Shell::SetTouchHudProjectionEnabled(bool enabled) { |
| 473 if (is_touch_hud_projection_enabled_ == enabled) | 461 if (is_touch_hud_projection_enabled_ == enabled) |
| 474 return; | 462 return; |
| 475 | 463 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 | 565 |
| 578 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 566 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 579 // layout. | 567 // layout. |
| 580 DeactivateKeyboard(); | 568 DeactivateKeyboard(); |
| 581 | 569 |
| 582 // Destroy toasts | 570 // Destroy toasts |
| 583 wm_shell_->DeleteToastManager(); | 571 wm_shell_->DeleteToastManager(); |
| 584 | 572 |
| 585 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 573 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 586 // to deinitialize the shelf first, as it is initialized after the delegate. | 574 // to deinitialize the shelf first, as it is initialized after the delegate. |
| 587 ShutdownShelf(); | 575 for (WmWindow* root : wm_shell_->GetAllRootWindows()) { |
|
msw
2016/08/31 23:01:39
optional nit: no curlies
James Cook
2016/08/31 23:33:45
Done.
| |
| 576 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); | |
| 577 } | |
| 588 wm_shell_->DeleteSystemTrayDelegate(); | 578 wm_shell_->DeleteSystemTrayDelegate(); |
| 589 | 579 |
| 590 locale_notification_controller_.reset(); | 580 locale_notification_controller_.reset(); |
| 591 | 581 |
| 592 // Drag-and-drop must be canceled prior to close all windows. | 582 // Drag-and-drop must be canceled prior to close all windows. |
| 593 drag_drop_controller_.reset(); | 583 drag_drop_controller_.reset(); |
| 594 | 584 |
| 595 // Controllers who have WindowObserver added must be deleted | 585 // Controllers who have WindowObserver added must be deleted |
| 596 // before |window_tree_host_manager_| is deleted. | 586 // before |window_tree_host_manager_| is deleted. |
| 597 | 587 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { | 1024 std::unique_ptr<ui::EventTargetIterator> Shell::GetChildIterator() const { |
| 1035 return std::unique_ptr<ui::EventTargetIterator>(); | 1025 return std::unique_ptr<ui::EventTargetIterator>(); |
| 1036 } | 1026 } |
| 1037 | 1027 |
| 1038 ui::EventTargeter* Shell::GetEventTargeter() { | 1028 ui::EventTargeter* Shell::GetEventTargeter() { |
| 1039 NOTREACHED(); | 1029 NOTREACHED(); |
| 1040 return nullptr; | 1030 return nullptr; |
| 1041 } | 1031 } |
| 1042 | 1032 |
| 1043 } // namespace ash | 1033 } // namespace ash |
| OLD | NEW |