OLD | NEW |
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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void WmShell::CreateShelf() { | 146 void WmShell::CreateShelf() { |
147 // Must occur after SessionStateDelegate creation and user login. | 147 // Must occur after SessionStateDelegate creation and user login. |
148 DCHECK(GetSessionStateDelegate()); | 148 DCHECK(GetSessionStateDelegate()); |
149 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); | 149 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); |
150 CreateShelfDelegate(); | 150 CreateShelfDelegate(); |
151 | 151 |
152 for (WmWindow* root_window : GetAllRootWindows()) | 152 for (WmWindow* root_window : GetAllRootWindows()) |
153 root_window->GetRootWindowController()->CreateShelf(); | 153 root_window->GetRootWindowController()->CreateShelf(); |
154 } | 154 } |
155 | 155 |
156 void WmShell::ShowShelf() { | |
157 for (WmWindow* root_window : GetAllRootWindows()) | |
158 root_window->GetRootWindowController()->ShowShelf(); | |
159 } | |
160 | |
161 void WmShell::CreateShelfDelegate() { | 156 void WmShell::CreateShelfDelegate() { |
162 // May be called multiple times as shelves are created and destroyed. | 157 // May be called multiple times as shelves are created and destroyed. |
163 if (shelf_delegate_) | 158 if (shelf_delegate_) |
164 return; | 159 return; |
165 // Must occur after SessionStateDelegate creation and user login because | 160 // Must occur after SessionStateDelegate creation and user login because |
166 // Chrome's implementation of ShelfDelegate assumes it can get information | 161 // Chrome's implementation of ShelfDelegate assumes it can get information |
167 // about multi-profile login state. | 162 // about multi-profile login state. |
168 DCHECK(GetSessionStateDelegate()); | 163 DCHECK(GetSessionStateDelegate()); |
169 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); | 164 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); |
170 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model())); | 165 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model())); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 session_controller_(base::MakeUnique<SessionController>()), | 262 session_controller_(base::MakeUnique<SessionController>()), |
268 shelf_controller_(base::MakeUnique<ShelfController>()), | 263 shelf_controller_(base::MakeUnique<ShelfController>()), |
269 shutdown_controller_(base::MakeUnique<ShutdownController>()), | 264 shutdown_controller_(base::MakeUnique<ShutdownController>()), |
270 system_tray_controller_(base::MakeUnique<SystemTrayController>()), | 265 system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
271 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), | 266 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), |
272 vpn_list_(base::MakeUnique<VpnList>()), | 267 vpn_list_(base::MakeUnique<VpnList>()), |
273 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), | 268 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), |
274 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), | 269 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
275 window_selector_controller_( | 270 window_selector_controller_( |
276 base::MakeUnique<WindowSelectorController>()) { | 271 base::MakeUnique<WindowSelectorController>()) { |
| 272 session_controller_->AddSessionStateObserver(this); |
277 | 273 |
278 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; | 274 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; |
279 // Can be null in tests. | 275 // Can be null in tests. |
280 if (!delegate_->GetShellConnector()) | 276 if (!delegate_->GetShellConnector()) |
281 return; | 277 return; |
282 delegate_->GetShellConnector()->BindInterface(prefs::mojom::kServiceName, | 278 delegate_->GetShellConnector()->BindInterface(prefs::mojom::kServiceName, |
283 &pref_manager_ptr); | 279 &pref_manager_ptr); |
284 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); | 280 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); |
285 } | 281 } |
286 | 282 |
287 WmShell::~WmShell() {} | 283 WmShell::~WmShell() { |
| 284 session_controller_->RemoveSessionStateObserver(this); |
| 285 } |
288 | 286 |
289 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { | 287 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { |
290 return GetPrimaryRootWindow()->GetRootWindowController(); | 288 return GetPrimaryRootWindow()->GetRootWindowController(); |
291 } | 289 } |
292 | 290 |
293 WmWindow* WmShell::GetRootWindowForNewWindows() { | 291 WmWindow* WmShell::GetRootWindowForNewWindows() { |
294 if (scoped_root_window_for_new_windows_) | 292 if (scoped_root_window_for_new_windows_) |
295 return scoped_root_window_for_new_windows_; | 293 return scoped_root_window_for_new_windows_; |
296 return root_window_for_new_windows_; | 294 return root_window_for_new_windows_; |
297 } | 295 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 409 |
412 void WmShell::DeleteToastManager() { | 410 void WmShell::DeleteToastManager() { |
413 toast_manager_.reset(); | 411 toast_manager_.reset(); |
414 } | 412 } |
415 | 413 |
416 void WmShell::SetAcceleratorController( | 414 void WmShell::SetAcceleratorController( |
417 std::unique_ptr<AcceleratorController> accelerator_controller) { | 415 std::unique_ptr<AcceleratorController> accelerator_controller) { |
418 accelerator_controller_ = std::move(accelerator_controller); | 416 accelerator_controller_ = std::move(accelerator_controller); |
419 } | 417 } |
420 | 418 |
| 419 void WmShell::SessionStateChanged(session_manager::SessionState state) { |
| 420 // Create the shelf when a session becomes active. It's safe to do this |
| 421 // multiple times (e.g. initial login vs. multiprofile add session). |
| 422 if (state == session_manager::SessionState::ACTIVE) |
| 423 CreateShelf(); |
| 424 } |
| 425 |
421 } // namespace ash | 426 } // namespace ash |
OLD | NEW |