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

Side by Side Diff: ash/common/wm_shell.cc

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Fix and workaround test issues. Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/common/wm_shell.h" 5 #include "ash/common/wm_shell.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accelerators/ash_focus_manager_factory.h" 10 #include "ash/common/accelerators/ash_focus_manager_factory.h"
11 #include "ash/common/accessibility_delegate.h" 11 #include "ash/common/accessibility_delegate.h"
12 #include "ash/common/focus_cycler.h" 12 #include "ash/common/focus_cycler.h"
13 #include "ash/common/keyboard/keyboard_ui.h" 13 #include "ash/common/keyboard/keyboard_ui.h"
14 #include "ash/common/new_window_delegate.h" 14 #include "ash/common/new_window_delegate.h"
15 #include "ash/common/palette_delegate.h" 15 #include "ash/common/palette_delegate.h"
16 #include "ash/common/session/session_state_delegate.h" 16 #include "ash/common/session/session_state_delegate.h"
17 #include "ash/common/shelf/app_list_shelf_item_delegate.h" 17 #include "ash/common/shelf/app_list_shelf_item_delegate.h"
18 #include "ash/common/shelf/shelf_controller.h"
18 #include "ash/common/shelf/shelf_delegate.h" 19 #include "ash/common/shelf/shelf_delegate.h"
19 #include "ash/common/shelf/shelf_model.h" 20 #include "ash/common/shelf/shelf_model.h"
20 #include "ash/common/shelf/shelf_window_watcher.h" 21 #include "ash/common/shelf/shelf_window_watcher.h"
21 #include "ash/common/shell_delegate.h" 22 #include "ash/common/shell_delegate.h"
22 #include "ash/common/shell_window_ids.h" 23 #include "ash/common/shell_window_ids.h"
23 #include "ash/common/system/brightness_control_delegate.h" 24 #include "ash/common/system/brightness_control_delegate.h"
24 #include "ash/common/system/keyboard_brightness_control_delegate.h" 25 #include "ash/common/system/keyboard_brightness_control_delegate.h"
25 #include "ash/common/system/toast/toast_manager.h" 26 #include "ash/common/system/toast/toast_manager.h"
26 #include "ash/common/system/tray/system_tray_controller.h" 27 #include "ash/common/system/tray/system_tray_controller.h"
27 #include "ash/common/system/tray/system_tray_delegate.h" 28 #include "ash/common/system/tray/system_tray_delegate.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 blocking_pool_ = pool; 70 blocking_pool_ = pool;
70 71
71 // Some delegates access WmShell during their construction. Create them here 72 // Some delegates access WmShell during their construction. Create them here
72 // instead of the WmShell constructor. 73 // instead of the WmShell constructor.
73 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); 74 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate());
74 media_delegate_.reset(delegate_->CreateMediaDelegate()); 75 media_delegate_.reset(delegate_->CreateMediaDelegate());
75 palette_delegate_ = delegate_->CreatePaletteDelegate(); 76 palette_delegate_ = delegate_->CreatePaletteDelegate();
76 toast_manager_.reset(new ToastManager); 77 toast_manager_.reset(new ToastManager);
77 78
78 // Create the app list item in the shelf data model. 79 // Create the app list item in the shelf data model.
79 AppListShelfItemDelegate::CreateAppListItemAndDelegate(shelf_model_.get()); 80 AppListShelfItemDelegate::CreateAppListItemAndDelegate(shelf_model());
80 81
81 // Install the custom factory early on so that views::FocusManagers for Tray, 82 // Install the custom factory early on so that views::FocusManagers for Tray,
82 // Shelf, and WallPaper could be created by the factory. 83 // Shelf, and WallPaper could be created by the factory.
83 views::FocusManagerFactory::Install(new AshFocusManagerFactory); 84 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
84 85
85 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); 86 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate());
86 87
87 wallpaper_controller_.reset(new WallpaperController(blocking_pool_)); 88 wallpaper_controller_.reset(new WallpaperController(blocking_pool_));
88 } 89 }
89 90
90 void WmShell::Shutdown() { 91 void WmShell::Shutdown() {
91 // These members access WmShell in their destructors. 92 // These members access WmShell in their destructors.
92 wallpaper_controller_.reset(); 93 wallpaper_controller_.reset();
93 accessibility_delegate_.reset(); 94 accessibility_delegate_.reset();
94 95
95 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 96 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
96 shelf_window_watcher_.reset(); 97 shelf_window_watcher_.reset();
97 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC 98 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
98 // shelf items in Chrome) so explicitly shutdown early. 99 // shelf items in Chrome) so explicitly shutdown early.
99 shelf_model_->DestroyItemDelegates(); 100 shelf_model()->DestroyItemDelegates();
100 // Must be destroyed before FocusClient. 101 // Must be destroyed before FocusClient.
101 shelf_delegate_.reset(); 102 shelf_delegate_.reset();
102 103
103 // Balances the Install() in Initialize(). 104 // Balances the Install() in Initialize().
104 views::FocusManagerFactory::Install(nullptr); 105 views::FocusManagerFactory::Install(nullptr);
105 } 106 }
106 107
108 ShelfModel* WmShell::shelf_model() {
109 return shelf_controller_->model();
110 }
111
107 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, 112 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen,
108 ui::MenuSourceType source_type) { 113 ui::MenuSourceType source_type) {
109 // Bail if there is no active user session or if the screen is locked. 114 // Bail if there is no active user session or if the screen is locked.
110 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || 115 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 ||
111 GetSessionStateDelegate()->IsScreenLocked()) { 116 GetSessionStateDelegate()->IsScreenLocked()) {
112 return; 117 return;
113 } 118 }
114 119
115 WmWindow* root = wm::GetRootWindowAt(location_in_screen); 120 WmWindow* root = wm::GetRootWindowAt(location_in_screen);
116 root->GetRootWindowController()->ShowContextMenu(location_in_screen, 121 root->GetRootWindowController()->ShowContextMenu(location_in_screen,
(...skipping 17 matching lines...) Expand all
134 139
135 void WmShell::CreateShelfDelegate() { 140 void WmShell::CreateShelfDelegate() {
136 // May be called multiple times as shelves are created and destroyed. 141 // May be called multiple times as shelves are created and destroyed.
137 if (shelf_delegate_) 142 if (shelf_delegate_)
138 return; 143 return;
139 // Must occur after SessionStateDelegate creation and user login because 144 // Must occur after SessionStateDelegate creation and user login because
140 // Chrome's implementation of ShelfDelegate assumes it can get information 145 // Chrome's implementation of ShelfDelegate assumes it can get information
141 // about multi-profile login state. 146 // about multi-profile login state.
142 DCHECK(GetSessionStateDelegate()); 147 DCHECK(GetSessionStateDelegate());
143 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); 148 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0);
144 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get())); 149 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model()));
145 shelf_window_watcher_.reset(new ShelfWindowWatcher(shelf_model_.get())); 150 shelf_window_watcher_.reset(new ShelfWindowWatcher(shelf_model()));
146 } 151 }
147 152
148 void WmShell::OnMaximizeModeStarted() { 153 void WmShell::OnMaximizeModeStarted() {
149 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted()); 154 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted());
150 } 155 }
151 156
152 void WmShell::OnMaximizeModeEnded() { 157 void WmShell::OnMaximizeModeEnded() {
153 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded()); 158 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded());
154 } 159 }
155 160
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 shelf_delegate_ = std::move(test_delegate); 222 shelf_delegate_ = std::move(test_delegate);
218 } 223 }
219 224
220 void WmShell::SetPaletteDelegateForTesting( 225 void WmShell::SetPaletteDelegateForTesting(
221 std::unique_ptr<PaletteDelegate> palette_delegate) { 226 std::unique_ptr<PaletteDelegate> palette_delegate) {
222 palette_delegate_ = std::move(palette_delegate); 227 palette_delegate_ = std::move(palette_delegate);
223 } 228 }
224 229
225 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) 230 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate)
226 : delegate_(std::move(shell_delegate)), 231 : delegate_(std::move(shell_delegate)),
227 focus_cycler_(new FocusCycler), 232 focus_cycler_(base::MakeUnique<FocusCycler>()),
228 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), 233 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()),
229 shelf_model_(new ShelfModel), // Must create before ShelfDelegate. 234 shelf_controller_(base::MakeUnique<ShelfController>()),
230 system_tray_controller_( 235 system_tray_controller_(base::MakeUnique<SystemTrayController>(
231 new SystemTrayController(delegate_->GetShellConnector())), 236 delegate_->GetShellConnector())),
232 system_tray_notifier_(new SystemTrayNotifier), 237 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()),
233 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), 238 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()),
234 window_cycle_controller_(new WindowCycleController), 239 window_cycle_controller_(base::MakeUnique<WindowCycleController>()),
235 window_selector_controller_(new WindowSelectorController) { 240 window_selector_controller_(
241 base::MakeUnique<WindowSelectorController>()) {
236 #if defined(OS_CHROMEOS) 242 #if defined(OS_CHROMEOS)
237 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); 243 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos);
238 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); 244 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController);
239 #endif 245 #endif
240 } 246 }
241 247
242 WmShell::~WmShell() {} 248 WmShell::~WmShell() {}
243 249
244 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { 250 WmRootWindowController* WmShell::GetPrimaryRootWindowController() {
245 return GetPrimaryRootWindow()->GetRootWindowController(); 251 return GetPrimaryRootWindow()->GetRootWindowController();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 void WmShell::DeleteToastManager() { 380 void WmShell::DeleteToastManager() {
375 toast_manager_.reset(); 381 toast_manager_.reset();
376 } 382 }
377 383
378 void WmShell::SetAcceleratorController( 384 void WmShell::SetAcceleratorController(
379 std::unique_ptr<AcceleratorController> accelerator_controller) { 385 std::unique_ptr<AcceleratorController> accelerator_controller) {
380 accelerator_controller_ = std::move(accelerator_controller); 386 accelerator_controller_ = std::move(accelerator_controller);
381 } 387 }
382 388
383 } // namespace ash 389 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698