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

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

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Sync and rebase. 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"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 blocking_pool_ = pool; 69 blocking_pool_ = pool;
70 70
71 // Some delegates access WmShell during their construction. Create them here 71 // Some delegates access WmShell during their construction. Create them here
72 // instead of the WmShell constructor. 72 // instead of the WmShell constructor.
73 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate()); 73 accessibility_delegate_.reset(delegate_->CreateAccessibilityDelegate());
74 media_delegate_.reset(delegate_->CreateMediaDelegate()); 74 media_delegate_.reset(delegate_->CreateMediaDelegate());
75 palette_delegate_ = delegate_->CreatePaletteDelegate(); 75 palette_delegate_ = delegate_->CreatePaletteDelegate();
76 toast_manager_.reset(new ToastManager); 76 toast_manager_.reset(new ToastManager);
77 77
78 // Create the app list item in the shelf data model. 78 // Create the app list item in the shelf data model.
79 AppListShelfItemDelegate::CreateAppListItemAndDelegate(shelf_model_.get()); 79 AppListShelfItemDelegate::CreateAppListItemAndDelegate(shelf_model());
80 80
81 // Install the custom factory early on so that views::FocusManagers for Tray, 81 // Install the custom factory early on so that views::FocusManagers for Tray,
82 // Shelf, and WallPaper could be created by the factory. 82 // Shelf, and WallPaper could be created by the factory.
83 views::FocusManagerFactory::Install(new AshFocusManagerFactory); 83 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
84 84
85 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate()); 85 new_window_delegate_.reset(delegate_->CreateNewWindowDelegate());
86 86
87 wallpaper_controller_.reset(new WallpaperController(blocking_pool_)); 87 wallpaper_controller_.reset(new WallpaperController(blocking_pool_));
88 } 88 }
89 89
90 void WmShell::Shutdown() { 90 void WmShell::Shutdown() {
91 // These members access WmShell in their destructors. 91 // These members access WmShell in their destructors.
92 wallpaper_controller_.reset(); 92 wallpaper_controller_.reset();
93 accessibility_delegate_.reset(); 93 accessibility_delegate_.reset();
94 94
95 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 95 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
96 shelf_window_watcher_.reset(); 96 shelf_window_watcher_.reset();
97 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC 97 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
98 // shelf items in Chrome) so explicitly shutdown early. 98 // shelf items in Chrome) so explicitly shutdown early.
99 shelf_model_->DestroyItemDelegates(); 99 shelf_model()->DestroyItemDelegates();
100 // Must be destroyed before FocusClient. 100 // Must be destroyed before FocusClient.
101 shelf_delegate_.reset(); 101 shelf_delegate_.reset();
102 102
103 // Balances the Install() in Initialize(). 103 // Balances the Install() in Initialize().
104 views::FocusManagerFactory::Install(nullptr); 104 views::FocusManagerFactory::Install(nullptr);
105 } 105 }
106 106
107 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, 107 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen,
108 ui::MenuSourceType source_type) { 108 ui::MenuSourceType source_type) {
109 // Bail if there is no active user session or if the screen is locked. 109 // Bail if there is no active user session or if the screen is locked.
110 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || 110 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 ||
111 GetSessionStateDelegate()->IsScreenLocked()) { 111 GetSessionStateDelegate()->IsScreenLocked()) {
112 return; 112 return;
113 } 113 }
114 114
115 WmWindow* root = wm::GetRootWindowAt(location_in_screen); 115 WmWindow* root = wm::GetRootWindowAt(location_in_screen);
116 root->GetRootWindowController()->ShowContextMenu(location_in_screen, 116 root->GetRootWindowController()->ShowContextMenu(location_in_screen,
117 source_type); 117 source_type);
118 } 118 }
119 119
120 void WmShell::CreateShelfDelegate() { 120 void WmShell::CreateShelfDelegate() {
121 // May be called multiple times as shelves are created and destroyed. 121 // May be called multiple times as shelves are created and destroyed.
122 if (shelf_delegate_) 122 if (shelf_delegate_)
123 return; 123 return;
124 // Must occur after SessionStateDelegate creation and user login because 124 // Must occur after SessionStateDelegate creation and user login because
125 // Chrome's implementation of ShelfDelegate assumes it can get information 125 // Chrome's implementation of ShelfDelegate assumes it can get information
126 // about multi-profile login state. 126 // about multi-profile login state.
127 DCHECK(GetSessionStateDelegate()); 127 DCHECK(GetSessionStateDelegate());
128 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); 128 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0);
129 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model_.get())); 129 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model()));
130 shelf_window_watcher_.reset(new ShelfWindowWatcher(shelf_model_.get())); 130 shelf_window_watcher_.reset(new ShelfWindowWatcher(shelf_model()));
131 } 131 }
132 132
133 void WmShell::OnMaximizeModeStarted() { 133 void WmShell::OnMaximizeModeStarted() {
134 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted()); 134 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeStarted());
135 } 135 }
136 136
137 void WmShell::OnMaximizeModeEnded() { 137 void WmShell::OnMaximizeModeEnded() {
138 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded()); 138 FOR_EACH_OBSERVER(ShellObserver, shell_observers_, OnMaximizeModeEnded());
139 } 139 }
140 140
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 void WmShell::SetPaletteDelegateForTesting( 198 void WmShell::SetPaletteDelegateForTesting(
199 std::unique_ptr<PaletteDelegate> palette_delegate) { 199 std::unique_ptr<PaletteDelegate> palette_delegate) {
200 palette_delegate_ = std::move(palette_delegate); 200 palette_delegate_ = std::move(palette_delegate);
201 } 201 }
202 202
203 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) 203 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate)
204 : delegate_(std::move(shell_delegate)), 204 : delegate_(std::move(shell_delegate)),
205 focus_cycler_(new FocusCycler), 205 focus_cycler_(new FocusCycler),
206 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), 206 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()),
207 shelf_model_(new ShelfModel), // Must create before ShelfDelegate. 207 shelf_controller_(new ShelfController), // Model needed by ShelfDelegate.
sky 2016/10/07 16:10:17 MakeUnique?
msw 2016/10/07 22:45:57 Done.
208 system_tray_controller_( 208 system_tray_controller_(
209 new SystemTrayController(delegate_->GetShellConnector())), 209 new SystemTrayController(delegate_->GetShellConnector())),
210 system_tray_notifier_(new SystemTrayNotifier), 210 system_tray_notifier_(new SystemTrayNotifier),
211 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), 211 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()),
212 window_cycle_controller_(new WindowCycleController), 212 window_cycle_controller_(new WindowCycleController),
213 window_selector_controller_(new WindowSelectorController) { 213 window_selector_controller_(new WindowSelectorController) {
214 #if defined(OS_CHROMEOS) 214 #if defined(OS_CHROMEOS)
215 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); 215 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos);
216 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); 216 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController);
217 #endif 217 #endif
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 void WmShell::DeleteToastManager() { 352 void WmShell::DeleteToastManager() {
353 toast_manager_.reset(); 353 toast_manager_.reset();
354 } 354 }
355 355
356 void WmShell::SetAcceleratorController( 356 void WmShell::SetAcceleratorController(
357 std::unique_ptr<AcceleratorController> accelerator_controller) { 357 std::unique_ptr<AcceleratorController> accelerator_controller) {
358 accelerator_controller_ = std::move(accelerator_controller); 358 accelerator_controller_ = std::move(accelerator_controller);
359 } 359 }
360 360
361 } // namespace ash 361 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698