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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 void WmShell::CreateShelf() { | 144 void WmShell::CreateShelf() { |
145 // Must occur after SessionStateDelegate creation and user login. | 145 // Must occur after SessionStateDelegate creation and user login. |
146 DCHECK(GetSessionStateDelegate()); | 146 DCHECK(GetSessionStateDelegate()); |
147 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); | 147 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); |
148 CreateShelfDelegate(); | 148 CreateShelfDelegate(); |
149 | 149 |
150 for (WmWindow* root_window : GetAllRootWindows()) | 150 for (WmWindow* root_window : GetAllRootWindows()) |
151 root_window->GetRootWindowController()->CreateShelf(); | 151 root_window->GetRootWindowController()->CreateShelf(); |
152 } | 152 } |
153 | 153 |
154 void WmShell::ShowShelf() { | |
155 for (WmWindow* root_window : GetAllRootWindows()) | |
156 root_window->GetRootWindowController()->ShowShelf(); | |
157 } | |
158 | |
159 void WmShell::CreateShelfDelegate() { | 154 void WmShell::CreateShelfDelegate() { |
160 // May be called multiple times as shelves are created and destroyed. | 155 // May be called multiple times as shelves are created and destroyed. |
161 if (shelf_delegate_) | 156 if (shelf_delegate_) |
162 return; | 157 return; |
163 // Must occur after SessionStateDelegate creation and user login because | 158 // Must occur after SessionStateDelegate creation and user login because |
164 // Chrome's implementation of ShelfDelegate assumes it can get information | 159 // Chrome's implementation of ShelfDelegate assumes it can get information |
165 // about multi-profile login state. | 160 // about multi-profile login state. |
166 DCHECK(GetSessionStateDelegate()); | 161 DCHECK(GetSessionStateDelegate()); |
167 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); | 162 DCHECK_GT(GetSessionStateDelegate()->NumberOfLoggedInUsers(), 0); |
168 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model())); | 163 shelf_delegate_.reset(delegate_->CreateShelfDelegate(shelf_model())); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), | 260 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), |
266 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), | 261 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), |
267 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), | 262 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
268 window_selector_controller_( | 263 window_selector_controller_( |
269 base::MakeUnique<WindowSelectorController>()) { | 264 base::MakeUnique<WindowSelectorController>()) { |
270 #if defined(OS_CHROMEOS) | 265 #if defined(OS_CHROMEOS) |
271 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | 266 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); |
272 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | 267 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); |
273 vpn_list_ = base::MakeUnique<VpnList>(); | 268 vpn_list_ = base::MakeUnique<VpnList>(); |
274 #endif | 269 #endif |
| 270 session_controller_->AddSessionStateObserver(this); |
275 } | 271 } |
276 | 272 |
277 WmShell::~WmShell() {} | 273 WmShell::~WmShell() { |
| 274 session_controller_->RemoveSessionStateObserver(this); |
| 275 } |
278 | 276 |
279 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { | 277 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { |
280 return GetPrimaryRootWindow()->GetRootWindowController(); | 278 return GetPrimaryRootWindow()->GetRootWindowController(); |
281 } | 279 } |
282 | 280 |
283 WmWindow* WmShell::GetRootWindowForNewWindows() { | 281 WmWindow* WmShell::GetRootWindowForNewWindows() { |
284 if (scoped_root_window_for_new_windows_) | 282 if (scoped_root_window_for_new_windows_) |
285 return scoped_root_window_for_new_windows_; | 283 return scoped_root_window_for_new_windows_; |
286 return root_window_for_new_windows_; | 284 return root_window_for_new_windows_; |
287 } | 285 } |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 | 406 |
409 void WmShell::DeleteToastManager() { | 407 void WmShell::DeleteToastManager() { |
410 toast_manager_.reset(); | 408 toast_manager_.reset(); |
411 } | 409 } |
412 | 410 |
413 void WmShell::SetAcceleratorController( | 411 void WmShell::SetAcceleratorController( |
414 std::unique_ptr<AcceleratorController> accelerator_controller) { | 412 std::unique_ptr<AcceleratorController> accelerator_controller) { |
415 accelerator_controller_ = std::move(accelerator_controller); | 413 accelerator_controller_ = std::move(accelerator_controller); |
416 } | 414 } |
417 | 415 |
| 416 void WmShell::SessionStateChanged(session_manager::SessionState state) { |
| 417 // Create the shelf when a session becomes active. It's safe to do this |
| 418 // multiple times (e.g. initial login vs. multiprofile add session). |
| 419 if (state == session_manager::SessionState::ACTIVE) |
| 420 CreateShelf(); |
| 421 } |
| 422 |
418 } // namespace ash | 423 } // namespace ash |
OLD | NEW |