Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(718)

Side by Side Diff: ash/shell.cc

Issue 2738133003: Promotes a handful of members from WmShell to Shell (Closed)
Patch Set: forward declare Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 virtual_keyboard_controller_.reset(); 552 virtual_keyboard_controller_.reset();
544 553
545 // Destroy maximize mode controller early on since it has some observers which 554 // Destroy maximize mode controller early on since it has some observers which
546 // need to be removed. 555 // need to be removed.
547 wm_shell_->DeleteMaximizeModeController(); 556 wm_shell_->DeleteMaximizeModeController();
548 557
549 // Destroy the keyboard before closing the shelf, since it will invoke a shelf 558 // Destroy the keyboard before closing the shelf, since it will invoke a shelf
550 // layout. 559 // layout.
551 DeactivateKeyboard(); 560 DeactivateKeyboard();
552 561
553 // Destroy toasts 562 toast_manager_.reset();
554 wm_shell_->DeleteToastManager();
555 563
556 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure 564 // Destroy SystemTrayDelegate before destroying the status area(s). Make sure
557 // to deinitialize the shelf first, as it is initialized after the delegate. 565 // to deinitialize the shelf first, as it is initialized after the delegate.
558 for (WmWindow* root : wm_shell_->GetAllRootWindows()) 566 for (WmWindow* root : wm_shell_->GetAllRootWindows())
559 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget(); 567 root->GetRootWindowController()->GetShelf()->ShutdownShelfWidget();
560 wm_shell_->DeleteSystemTrayDelegate(); 568 wm_shell_->DeleteSystemTrayDelegate();
561 569
562 // Drag-and-drop must be canceled prior to close all windows. 570 // Drag-and-drop must be canceled prior to close all windows.
563 drag_drop_controller_.reset(); 571 drag_drop_controller_.reset();
564 572
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 // This also deletes all RootWindows. Note that we invoke Shutdown() on 621 // This also deletes all RootWindows. Note that we invoke Shutdown() on
614 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since 622 // WindowTreeHostManager before resetting |window_tree_host_manager_|, since
615 // destruction 623 // destruction
616 // of its owned RootWindowControllers relies on the value. 624 // of its owned RootWindowControllers relies on the value.
617 ScreenAsh::CreateScreenForShutdown(); 625 ScreenAsh::CreateScreenForShutdown();
618 display_configuration_controller_.reset(); 626 display_configuration_controller_.reset();
619 627
620 // AppListDelegateImpl depends upon AppList. 628 // AppListDelegateImpl depends upon AppList.
621 app_list_delegate_impl_.reset(); 629 app_list_delegate_impl_.reset();
622 630
631 // These members access Shell in their destructors.
632 wallpaper_controller_.reset();
633 accessibility_delegate_.reset();
634
635 // Balances the Install() in Initialize().
636 views::FocusManagerFactory::Install(nullptr);
637
623 wm_shell_->Shutdown(); 638 wm_shell_->Shutdown();
624 // Depends on |focus_controller_|, so must be destroyed before. 639 // Depends on |focus_controller_|, so must be destroyed before.
625 window_tree_host_manager_.reset(); 640 window_tree_host_manager_.reset();
626 focus_controller_->RemoveObserver(this); 641 focus_controller_->RemoveObserver(this);
627 focus_controller_.reset(); 642 focus_controller_.reset();
628 screen_position_controller_.reset(); 643 screen_position_controller_.reset();
629 644
630 keyboard::KeyboardController::ResetInstance(nullptr); 645 keyboard::KeyboardController::ResetInstance(nullptr);
631 646
632 display_color_manager_.reset(); 647 display_color_manager_.reset();
(...skipping 16 matching lines...) Expand all
649 // Needs to happen right before |instance_| is reset. 664 // Needs to happen right before |instance_| is reset.
650 wm_shell_.reset(); 665 wm_shell_.reset();
651 666
652 DCHECK(instance_ == this); 667 DCHECK(instance_ == this);
653 instance_ = nullptr; 668 instance_ = nullptr;
654 } 669 }
655 670
656 void Shell::Init(const ShellInitParams& init_params) { 671 void Shell::Init(const ShellInitParams& init_params) {
657 const bool is_mash = wm_shell_->IsRunningInMash(); 672 const bool is_mash = wm_shell_->IsRunningInMash();
658 673
659 wm_shell_->Initialize(init_params.blocking_pool); 674 blocking_pool_ = init_params.blocking_pool;
675
676 // Some delegates access WmShell during their construction. Create them here
677 // instead of the WmShell constructor.
678 accessibility_delegate_.reset(
679 wm_shell_->delegate()->CreateAccessibilityDelegate());
680 palette_delegate_ = wm_shell_->delegate()->CreatePaletteDelegate();
681 toast_manager_ = base::MakeUnique<ToastManager>();
682
683 // Create the app list item in the shelf data model.
684 AppListShelfItemDelegate::CreateAppListItemAndDelegate(
685 wm_shell_->shelf_model());
686
687 // Install the custom factory early on so that views::FocusManagers for Tray,
688 // Shelf, and WallPaper could be created by the factory.
689 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
690
691 wallpaper_controller_ = base::MakeUnique<WallpaperController>(blocking_pool_);
692
693 // Start devtools server
694 devtools_server_ = ui::devtools::UiDevToolsServer::Create(nullptr);
695 if (devtools_server_) {
696 auto dom_backend = base::MakeUnique<devtools::AshDevToolsDOMAgent>();
697 auto css_backend =
698 base::MakeUnique<devtools::AshDevToolsCSSAgent>(dom_backend.get());
699 auto devtools_client = base::MakeUnique<ui::devtools::UiDevToolsClient>(
700 "Ash", devtools_server_.get());
701 devtools_client->AddAgent(std::move(dom_backend));
702 devtools_client->AddAgent(std::move(css_backend));
703 devtools_server_->AttachClient(std::move(devtools_client));
704 }
660 705
661 if (is_mash) 706 if (is_mash)
662 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>(); 707 app_list_delegate_impl_ = base::MakeUnique<AppListDelegateImpl>();
663 708
664 // TODO(sky): move creation to WmShell. 709 // TODO(sky): move creation to WmShell.
665 if (!is_mash) 710 if (!is_mash)
666 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>(); 711 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryAsh>();
667 712
668 scoped_overview_animation_settings_factory_.reset( 713 scoped_overview_animation_settings_factory_.reset(
669 new ScopedOverviewAnimationSettingsFactoryAura); 714 new ScopedOverviewAnimationSettingsFactoryAura);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 void Shell::OnWindowActivated( 1071 void Shell::OnWindowActivated(
1027 aura::client::ActivationChangeObserver::ActivationReason reason, 1072 aura::client::ActivationChangeObserver::ActivationReason reason,
1028 aura::Window* gained_active, 1073 aura::Window* gained_active,
1029 aura::Window* lost_active) { 1074 aura::Window* lost_active) {
1030 WmWindow* gained_active_wm = WmWindow::Get(gained_active); 1075 WmWindow* gained_active_wm = WmWindow::Get(gained_active);
1031 if (gained_active_wm) 1076 if (gained_active_wm)
1032 root_window_for_new_windows_ = gained_active_wm->GetRootWindow(); 1077 root_window_for_new_windows_ = gained_active_wm->GetRootWindow();
1033 } 1078 }
1034 1079
1035 } // namespace ash 1080 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698