| 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/accelerators/magnifier_key_scroller.h" | 13 #include "ash/accelerators/magnifier_key_scroller.h" |
| 14 #include "ash/accelerators/spoken_feedback_toggler.h" | 14 #include "ash/accelerators/spoken_feedback_toggler.h" |
| 15 #include "ash/app_list/app_list_delegate_impl.h" | 15 #include "ash/app_list/app_list_delegate_impl.h" |
| 16 #include "ash/aura/wm_shell_aura.h" | 16 #include "ash/aura/wm_shell_aura.h" |
| 17 #include "ash/autoclick/autoclick_controller.h" | 17 #include "ash/autoclick/autoclick_controller.h" |
| 18 #include "ash/common/accelerators/accelerator_controller.h" | 18 #include "ash/common/accelerators/accelerator_controller.h" |
| 19 #include "ash/common/accelerators/ash_focus_manager_factory.h" |
| 20 #include "ash/common/accessibility_delegate.h" |
| 19 #include "ash/common/ash_constants.h" | 21 #include "ash/common/ash_constants.h" |
| 22 #include "ash/common/devtools/ash_devtools_css_agent.h" |
| 23 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
| 20 #include "ash/common/frame/custom_frame_view_ash.h" | 24 #include "ash/common/frame/custom_frame_view_ash.h" |
| 21 #include "ash/common/gpu_support.h" | 25 #include "ash/common/gpu_support.h" |
| 22 #include "ash/common/keyboard/keyboard_ui.h" | 26 #include "ash/common/keyboard/keyboard_ui.h" |
| 23 #include "ash/common/login_status.h" | 27 #include "ash/common/login_status.h" |
| 28 #include "ash/common/palette_delegate.h" |
| 24 #include "ash/common/session/session_state_delegate.h" | 29 #include "ash/common/session/session_state_delegate.h" |
| 25 #include "ash/common/shelf/app_list_shelf_item_delegate.h" | 30 #include "ash/common/shelf/app_list_shelf_item_delegate.h" |
| 26 #include "ash/common/shelf/shelf_delegate.h" | 31 #include "ash/common/shelf/shelf_delegate.h" |
| 27 #include "ash/common/shelf/shelf_item_delegate.h" | 32 #include "ash/common/shelf/shelf_item_delegate.h" |
| 28 #include "ash/common/shelf/shelf_model.h" | 33 #include "ash/common/shelf/shelf_model.h" |
| 29 #include "ash/common/shelf/wm_shelf.h" | 34 #include "ash/common/shelf/wm_shelf.h" |
| 30 #include "ash/common/shell_delegate.h" | 35 #include "ash/common/shell_delegate.h" |
| 31 #include "ash/common/shell_observer.h" | 36 #include "ash/common/shell_observer.h" |
| 32 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_controller
.h" | 37 #include "ash/common/system/chromeos/bluetooth/bluetooth_notification_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" |
| 35 #include "ash/common/system/status_area_widget.h" | 40 #include "ash/common/system/status_area_widget.h" |
| 41 #include "ash/common/system/toast/toast_manager.h" |
| 36 #include "ash/common/system/tray/system_tray_delegate.h" | 42 #include "ash/common/system/tray/system_tray_delegate.h" |
| 43 #include "ash/common/wallpaper/wallpaper_controller.h" |
| 37 #include "ash/common/wallpaper/wallpaper_delegate.h" | 44 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 38 #include "ash/common/wm/container_finder.h" | 45 #include "ash/common/wm/container_finder.h" |
| 39 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 46 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 40 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 47 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 41 #include "ash/common/wm/mru_window_tracker.h" | 48 #include "ash/common/wm/mru_window_tracker.h" |
| 42 #include "ash/common/wm/root_window_finder.h" | 49 #include "ash/common/wm/root_window_finder.h" |
| 43 #include "ash/common/wm/system_modal_container_layout_manager.h" | 50 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 44 #include "ash/common/wm/window_positioner.h" | 51 #include "ash/common/wm/window_positioner.h" |
| 45 #include "ash/common/wm/workspace_controller.h" | 52 #include "ash/common/wm/workspace_controller.h" |
| 46 #include "ash/common/wm_shell.h" | 53 #include "ash/common/wm_shell.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 #include "base/bind_helpers.h" | 103 #include "base/bind_helpers.h" |
| 97 #include "base/command_line.h" | 104 #include "base/command_line.h" |
| 98 #include "base/memory/ptr_util.h" | 105 #include "base/memory/ptr_util.h" |
| 99 #include "base/sys_info.h" | 106 #include "base/sys_info.h" |
| 100 #include "base/threading/sequenced_worker_pool.h" | 107 #include "base/threading/sequenced_worker_pool.h" |
| 101 #include "base/trace_event/trace_event.h" | 108 #include "base/trace_event/trace_event.h" |
| 102 #include "chromeos/audio/audio_a11y_controller.h" | 109 #include "chromeos/audio/audio_a11y_controller.h" |
| 103 #include "chromeos/chromeos_switches.h" | 110 #include "chromeos/chromeos_switches.h" |
| 104 #include "chromeos/dbus/dbus_thread_manager.h" | 111 #include "chromeos/dbus/dbus_thread_manager.h" |
| 105 #include "chromeos/system/devicemode.h" | 112 #include "chromeos/system/devicemode.h" |
| 113 #include "components/ui_devtools/devtools_server.h" |
| 106 #include "services/service_manager/public/cpp/connector.h" | 114 #include "services/service_manager/public/cpp/connector.h" |
| 107 #include "services/ui/public/interfaces/constants.mojom.h" | 115 #include "services/ui/public/interfaces/constants.mojom.h" |
| 108 #include "ui/aura/client/aura_constants.h" | 116 #include "ui/aura/client/aura_constants.h" |
| 109 #include "ui/aura/env.h" | 117 #include "ui/aura/env.h" |
| 110 #include "ui/aura/layout_manager.h" | 118 #include "ui/aura/layout_manager.h" |
| 111 #include "ui/aura/mus/user_activity_forwarder.h" | 119 #include "ui/aura/mus/user_activity_forwarder.h" |
| 112 #include "ui/aura/window.h" | 120 #include "ui/aura/window.h" |
| 113 #include "ui/aura/window_event_dispatcher.h" | 121 #include "ui/aura/window_event_dispatcher.h" |
| 114 #include "ui/base/ui_base_switches.h" | 122 #include "ui/base/ui_base_switches.h" |
| 115 #include "ui/base/user_activity/user_activity_detector.h" | 123 #include "ui/base/user_activity/user_activity_detector.h" |
| 116 #include "ui/chromeos/user_activity_power_manager_notifier.h" | 124 #include "ui/chromeos/user_activity_power_manager_notifier.h" |
| 117 #include "ui/compositor/layer.h" | 125 #include "ui/compositor/layer.h" |
| 118 #include "ui/compositor/layer_animator.h" | 126 #include "ui/compositor/layer_animator.h" |
| 119 #include "ui/display/display.h" | 127 #include "ui/display/display.h" |
| 120 #include "ui/display/manager/chromeos/display_change_observer.h" | 128 #include "ui/display/manager/chromeos/display_change_observer.h" |
| 121 #include "ui/display/manager/chromeos/display_configurator.h" | 129 #include "ui/display/manager/chromeos/display_configurator.h" |
| 122 #include "ui/display/manager/display_manager.h" | 130 #include "ui/display/manager/display_manager.h" |
| 123 #include "ui/display/screen.h" | 131 #include "ui/display/screen.h" |
| 124 #include "ui/events/event_target_iterator.h" | 132 #include "ui/events/event_target_iterator.h" |
| 125 #include "ui/gfx/geometry/insets.h" | 133 #include "ui/gfx/geometry/insets.h" |
| 126 #include "ui/gfx/image/image_skia.h" | 134 #include "ui/gfx/image/image_skia.h" |
| 127 #include "ui/keyboard/keyboard_controller.h" | 135 #include "ui/keyboard/keyboard_controller.h" |
| 128 #include "ui/keyboard/keyboard_switches.h" | 136 #include "ui/keyboard/keyboard_switches.h" |
| 129 #include "ui/keyboard/keyboard_util.h" | 137 #include "ui/keyboard/keyboard_util.h" |
| 130 #include "ui/views/corewm/tooltip_aura.h" | 138 #include "ui/views/corewm/tooltip_aura.h" |
| 131 #include "ui/views/corewm/tooltip_controller.h" | 139 #include "ui/views/corewm/tooltip_controller.h" |
| 140 #include "ui/views/focus/focus_manager_factory.h" |
| 132 #include "ui/views/widget/native_widget_aura.h" | 141 #include "ui/views/widget/native_widget_aura.h" |
| 133 #include "ui/views/widget/widget.h" | 142 #include "ui/views/widget/widget.h" |
| 134 #include "ui/wm/core/accelerator_filter.h" | 143 #include "ui/wm/core/accelerator_filter.h" |
| 135 #include "ui/wm/core/compound_event_filter.h" | 144 #include "ui/wm/core/compound_event_filter.h" |
| 136 #include "ui/wm/core/focus_controller.h" | 145 #include "ui/wm/core/focus_controller.h" |
| 137 #include "ui/wm/core/shadow_controller.h" | 146 #include "ui/wm/core/shadow_controller.h" |
| 138 #include "ui/wm/core/visibility_controller.h" | 147 #include "ui/wm/core/visibility_controller.h" |
| 139 #include "ui/wm/core/window_modality_controller.h" | 148 #include "ui/wm/core/window_modality_controller.h" |
| 140 | 149 |
| 141 #if defined(USE_X11) | 150 #if defined(USE_X11) |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 virtual_keyboard_controller_.reset(); | 551 virtual_keyboard_controller_.reset(); |
| 543 | 552 |
| 544 // Destroy maximize mode controller early on since it has some observers which | 553 // Destroy maximize mode controller early on since it has some observers which |
| 545 // need to be removed. | 554 // need to be removed. |
| 546 wm_shell_->DeleteMaximizeModeController(); | 555 wm_shell_->DeleteMaximizeModeController(); |
| 547 | 556 |
| 548 // Destroy the keyboard before closing the shelf, since it will invoke a shelf | 557 // Destroy the keyboard before closing the shelf, since it will invoke a shelf |
| 549 // layout. | 558 // layout. |
| 550 DeactivateKeyboard(); | 559 DeactivateKeyboard(); |
| 551 | 560 |
| 552 // Destroy toasts | 561 toast_manager_.reset(); |
| 553 wm_shell_->DeleteToastManager(); | |
| 554 | 562 |
| 555 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure | 563 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure |
| 556 // to deinitialize the shelf first, as it is initialized after the delegate. | 564 // to deinitialize the shelf first, as it is initialized after the delegate. |
| 557 for (WmWindow* root : wm_shell_->GetAllRootWindows()) | 565 for (WmWindow* root : wm_shell_->GetAllRootWindows()) |
| 558 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); | 566 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); |
| 559 wm_shell_->DeleteSystemTrayDelegate(); | 567 wm_shell_->DeleteSystemTrayDelegate(); |
| 560 | 568 |
| 561 // Drag-and-drop must be canceled prior to close all windows. | 569 // Drag-and-drop must be canceled prior to close all windows. |
| 562 drag_drop_controller_.reset(); | 570 drag_drop_controller_.reset(); |
| 563 | 571 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 // This also deletes all RootWindows. Note that we invoke Shutdown() on | 620 // This also deletes all RootWindows. Note that we invoke Shutdown() on |
| 613 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since | 621 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since |
| 614 // destruction | 622 // destruction |
| 615 // of its owned RootWindowControllers relies on the value. | 623 // of its owned RootWindowControllers relies on the value. |
| 616 ScreenAsh::CreateScreenForShutdown(); | 624 ScreenAsh::CreateScreenForShutdown(); |
| 617 display_configuration_controller_.reset(); | 625 display_configuration_controller_.reset(); |
| 618 | 626 |
| 619 // AppListDelegateImpl depends upon AppList. | 627 // AppListDelegateImpl depends upon AppList. |
| 620 app_list_delegate_impl_.reset(); | 628 app_list_delegate_impl_.reset(); |
| 621 | 629 |
| 630 // These members access Shell in their destructors. |
| 631 wallpaper_controller_.reset(); |
| 632 accessibility_delegate_.reset(); |
| 633 |
| 634 // Balances the Install() in Initialize(). |
| 635 views::FocusManagerFactory::Install(nullptr); |
| 636 |
| 622 wm_shell_->Shutdown(); | 637 wm_shell_->Shutdown(); |
| 623 // Depends on |focus_controller_|, so must be destroyed before. | 638 // Depends on |focus_controller_|, so must be destroyed before. |
| 624 window_tree_host_manager_.reset(); | 639 window_tree_host_manager_.reset(); |
| 625 focus_controller_->RemoveObserver(this); | 640 focus_controller_->RemoveObserver(this); |
| 626 focus_controller_.reset(); | 641 focus_controller_.reset(); |
| 627 screen_position_controller_.reset(); | 642 screen_position_controller_.reset(); |
| 628 | 643 |
| 629 keyboard::KeyboardController::ResetInstance(nullptr); | 644 keyboard::KeyboardController::ResetInstance(nullptr); |
| 630 | 645 |
| 631 display_color_manager_.reset(); | 646 display_color_manager_.reset(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 648 // Needs to happen right before |instance_| is reset. | 663 // Needs to happen right before |instance_| is reset. |
| 649 wm_shell_.reset(); | 664 wm_shell_.reset(); |
| 650 | 665 |
| 651 DCHECK(instance_ == this); | 666 DCHECK(instance_ == this); |
| 652 instance_ = nullptr; | 667 instance_ = nullptr; |
| 653 } | 668 } |
| 654 | 669 |
| 655 void Shell::Init(const ShellInitParams& init_params) { | 670 void Shell::Init(const ShellInitParams& init_params) { |
| 656 const bool is_mash = wm_shell_->IsRunningInMash(); | 671 const bool is_mash = wm_shell_->IsRunningInMash(); |
| 657 | 672 |
| 658 wm_shell_->Initialize(init_params.blocking_pool); | 673 blocking_pool_ = init_params.blocking_pool; |
| 674 |
| 675 // Some delegates access WmShell during their construction. Create them here |
| 676 // instead of the WmShell constructor. |
| 677 accessibility_delegate_.reset( |
| 678 wm_shell_->delegate()->CreateAccessibilityDelegate()); |
| 679 palette_delegate_ = wm_shell_->delegate()->CreatePaletteDelegate(); |
| 680 toast_manager_ = base::MakeUnique<ToastManager>(); |
| 681 |
| 682 // Create the app list item in the shelf data model. |
| 683 AppListShelfItemDelegate::CreateAppListItemAndDelegate( |
| 684 wm_shell_->shelf_model()); |
| 685 |
| 686 // Install the custom factory early on so that views::FocusManagers for Tray, |
| 687 // Shelf, and WallPaper could be created by the factory. |
| 688 views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 689 |
| 690 wallpaper_controller_ = base::MakeUnique<WallpaperController>(blocking_pool_); |
| 691 |
| 692 // Start devtools server |
| 693 devtools_server_ = ui::devtools::UiDevToolsServer::Create(nullptr); |
| 694 if (devtools_server_) { |
| 695 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>(); |
| 696 auto css_backend = |
| 697 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get()); |
| 698 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>( |
| 699 "Ash", devtools_server_.get()); |
| 700 devtools_client->AddAgent(std::move(dom_backend)); |
| 701 devtools_client->AddAgent(std::move(css_backend)); |
| 702 devtools_server_->AttachClient(std::move(devtools_client)); |
| 703 } |
| 659 | 704 |
| 660 if (is_mash) | 705 if (is_mash) |
| 661 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); | 706 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); |
| 662 | 707 |
| 663 // TODO(sky): move creation to WmShell. | 708 // TODO(sky): move creation to WmShell. |
| 664 if (!is_mash) | 709 if (!is_mash) |
| 665 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); | 710 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); |
| 666 | 711 |
| 667 scoped_overview_animation_settings_factory_.reset( | 712 scoped_overview_animation_settings_factory_.reset( |
| 668 new ScopedOverviewAnimationSettingsFactoryAura); | 713 new ScopedOverviewAnimationSettingsFactoryAura); |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 void Shell::OnWindowActivated( | 1070 void Shell::OnWindowActivated( |
| 1026 aura::client::ActivationChangeObserver::ActivationReason reason, | 1071 aura::client::ActivationChangeObserver::ActivationReason reason, |
| 1027 aura::Window* gained_active, | 1072 aura::Window* gained_active, |
| 1028 aura::Window* lost_active) { | 1073 aura::Window* lost_active) { |
| 1029 WmWindow* gained_active_wm = WmWindow::Get(gained_active); | 1074 WmWindow* gained_active_wm = WmWindow::Get(gained_active); |
| 1030 if (gained_active_wm) | 1075 if (gained_active_wm) |
| 1031 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); | 1076 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); |
| 1032 } | 1077 } |
| 1033 | 1078 |
| 1034 } // namespace ash | 1079 } // namespace ash |
| OLD | NEW |