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" |
11 #include "ash/common/accessibility_delegate.h" | 11 #include "ash/common/accessibility_delegate.h" |
12 #include "ash/common/cast_config_controller.h" | 12 #include "ash/common/cast_config_controller.h" |
13 #include "ash/common/devtools/ash_devtools_css_agent.h" | 13 #include "ash/common/devtools/ash_devtools_css_agent.h" |
14 #include "ash/common/devtools/ash_devtools_dom_agent.h" | 14 #include "ash/common/devtools/ash_devtools_dom_agent.h" |
15 #include "ash/common/focus_cycler.h" | 15 #include "ash/common/focus_cycler.h" |
16 #include "ash/common/keyboard/keyboard_ui.h" | 16 #include "ash/common/keyboard/keyboard_ui.h" |
17 #include "ash/common/media_controller.h" | 17 #include "ash/common/media_controller.h" |
18 #include "ash/common/new_window_controller.h" | 18 #include "ash/common/new_window_controller.h" |
19 #include "ash/common/palette_delegate.h" | 19 #include "ash/common/palette_delegate.h" |
20 #include "ash/common/session/session_controller.h" | 20 #include "ash/common/session/session_controller.h" |
21 #include "ash/common/session/session_state_delegate.h" | 21 #include "ash/common/session/session_state_delegate.h" |
22 #include "ash/common/shelf/app_list_shelf_item_delegate.h" | 22 #include "ash/common/shelf/app_list_shelf_item_delegate.h" |
23 #include "ash/common/shelf/shelf_controller.h" | 23 #include "ash/common/shelf/shelf_controller.h" |
24 #include "ash/common/shelf/shelf_delegate.h" | 24 #include "ash/common/shelf/shelf_delegate.h" |
25 #include "ash/common/shelf/shelf_model.h" | 25 #include "ash/common/shelf/shelf_model.h" |
26 #include "ash/common/shelf/shelf_window_watcher.h" | 26 #include "ash/common/shelf/shelf_window_watcher.h" |
27 #include "ash/common/shell_delegate.h" | 27 #include "ash/common/shell_delegate.h" |
28 #include "ash/common/shutdown_controller.h" | 28 #include "ash/common/shutdown_controller.h" |
29 #include "ash/common/system/brightness_control_delegate.h" | 29 #include "ash/common/system/brightness_control_delegate.h" |
| 30 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
| 31 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 32 #include "ash/common/system/chromeos/network/vpn_list.h" |
| 33 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
30 #include "ash/common/system/keyboard_brightness_control_delegate.h" | 34 #include "ash/common/system/keyboard_brightness_control_delegate.h" |
31 #include "ash/common/system/locale/locale_notification_controller.h" | 35 #include "ash/common/system/locale/locale_notification_controller.h" |
32 #include "ash/common/system/toast/toast_manager.h" | 36 #include "ash/common/system/toast/toast_manager.h" |
33 #include "ash/common/system/tray/system_tray_controller.h" | 37 #include "ash/common/system/tray/system_tray_controller.h" |
34 #include "ash/common/system/tray/system_tray_delegate.h" | 38 #include "ash/common/system/tray/system_tray_delegate.h" |
35 #include "ash/common/system/tray/system_tray_notifier.h" | 39 #include "ash/common/system/tray/system_tray_notifier.h" |
36 #include "ash/common/wallpaper/wallpaper_controller.h" | 40 #include "ash/common/wallpaper/wallpaper_controller.h" |
37 #include "ash/common/wallpaper/wallpaper_delegate.h" | 41 #include "ash/common/wallpaper/wallpaper_delegate.h" |
38 #include "ash/common/wm/immersive_context_ash.h" | 42 #include "ash/common/wm/immersive_context_ash.h" |
39 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 43 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
40 #include "ash/common/wm/mru_window_tracker.h" | 44 #include "ash/common/wm/mru_window_tracker.h" |
41 #include "ash/common/wm/overview/window_selector_controller.h" | 45 #include "ash/common/wm/overview/window_selector_controller.h" |
42 #include "ash/common/wm/root_window_finder.h" | 46 #include "ash/common/wm/root_window_finder.h" |
43 #include "ash/common/wm/system_modal_container_layout_manager.h" | 47 #include "ash/common/wm/system_modal_container_layout_manager.h" |
44 #include "ash/common/wm/window_cycle_controller.h" | 48 #include "ash/common/wm/window_cycle_controller.h" |
45 #include "ash/common/wm_root_window_controller.h" | 49 #include "ash/common/wm_root_window_controller.h" |
46 #include "ash/common/wm_window.h" | 50 #include "ash/common/wm_window.h" |
47 #include "ash/public/cpp/shell_window_ids.h" | 51 #include "ash/public/cpp/shell_window_ids.h" |
48 #include "base/bind.h" | 52 #include "base/bind.h" |
49 #include "base/logging.h" | 53 #include "base/logging.h" |
50 #include "base/memory/ptr_util.h" | 54 #include "base/memory/ptr_util.h" |
51 #include "services/preferences/public/cpp/pref_observer_store.h" | 55 #include "services/preferences/public/cpp/pref_observer_store.h" |
52 #include "services/preferences/public/interfaces/preferences.mojom.h" | 56 #include "services/preferences/public/interfaces/preferences.mojom.h" |
53 #include "services/service_manager/public/cpp/connector.h" | 57 #include "services/service_manager/public/cpp/connector.h" |
54 #include "ui/app_list/presenter/app_list.h" | 58 #include "ui/app_list/presenter/app_list.h" |
55 #include "ui/display/display.h" | 59 #include "ui/display/display.h" |
56 #include "ui/views/focus/focus_manager_factory.h" | 60 #include "ui/views/focus/focus_manager_factory.h" |
57 | 61 |
58 #if defined(OS_CHROMEOS) | |
59 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" | |
60 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | |
61 #include "ash/common/system/chromeos/network/vpn_list.h" | |
62 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | |
63 #endif | |
64 | |
65 namespace ash { | 62 namespace ash { |
66 | 63 |
67 // static | 64 // static |
68 WmShell* WmShell::instance_ = nullptr; | 65 WmShell* WmShell::instance_ = nullptr; |
69 | 66 |
70 // static | 67 // static |
71 void WmShell::Set(WmShell* instance) { | 68 void WmShell::Set(WmShell* instance) { |
72 instance_ = instance; | 69 instance_ = instance; |
73 } | 70 } |
74 | 71 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 241 } |
245 | 242 |
246 void WmShell::SetPaletteDelegateForTesting( | 243 void WmShell::SetPaletteDelegateForTesting( |
247 std::unique_ptr<PaletteDelegate> palette_delegate) { | 244 std::unique_ptr<PaletteDelegate> palette_delegate) { |
248 palette_delegate_ = std::move(palette_delegate); | 245 palette_delegate_ = std::move(palette_delegate); |
249 } | 246 } |
250 | 247 |
251 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) | 248 WmShell::WmShell(std::unique_ptr<ShellDelegate> shell_delegate) |
252 : delegate_(std::move(shell_delegate)), | 249 : delegate_(std::move(shell_delegate)), |
253 app_list_(base::MakeUnique<app_list::AppList>()), | 250 app_list_(base::MakeUnique<app_list::AppList>()), |
| 251 brightness_control_delegate_( |
| 252 base::MakeUnique<system::BrightnessControllerChromeos>()), |
254 cast_config_(base::MakeUnique<CastConfigController>()), | 253 cast_config_(base::MakeUnique<CastConfigController>()), |
255 focus_cycler_(base::MakeUnique<FocusCycler>()), | 254 focus_cycler_(base::MakeUnique<FocusCycler>()), |
256 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), | 255 immersive_context_(base::MakeUnique<ImmersiveContextAsh>()), |
| 256 keyboard_brightness_control_delegate_( |
| 257 base::MakeUnique<KeyboardBrightnessController>()), |
257 locale_notification_controller_( | 258 locale_notification_controller_( |
258 base::MakeUnique<LocaleNotificationController>()), | 259 base::MakeUnique<LocaleNotificationController>()), |
259 media_controller_(base::MakeUnique<MediaController>()), | 260 media_controller_(base::MakeUnique<MediaController>()), |
260 new_window_controller_(base::MakeUnique<NewWindowController>()), | 261 new_window_controller_(base::MakeUnique<NewWindowController>()), |
261 session_controller_(base::MakeUnique<SessionController>()), | 262 session_controller_(base::MakeUnique<SessionController>()), |
262 shelf_controller_(base::MakeUnique<ShelfController>()), | 263 shelf_controller_(base::MakeUnique<ShelfController>()), |
263 shutdown_controller_(base::MakeUnique<ShutdownController>()), | 264 shutdown_controller_(base::MakeUnique<ShutdownController>()), |
264 system_tray_controller_(base::MakeUnique<SystemTrayController>()), | 265 system_tray_controller_(base::MakeUnique<SystemTrayController>()), |
265 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), | 266 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), |
| 267 vpn_list_(base::MakeUnique<VpnList>()), |
266 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), | 268 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), |
267 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), | 269 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
268 window_selector_controller_( | 270 window_selector_controller_( |
269 base::MakeUnique<WindowSelectorController>()) { | 271 base::MakeUnique<WindowSelectorController>()) { |
270 #if defined(OS_CHROMEOS) | |
271 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | |
272 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | |
273 vpn_list_ = base::MakeUnique<VpnList>(); | |
274 #endif | |
275 session_controller_->AddSessionStateObserver(this); | 272 session_controller_->AddSessionStateObserver(this); |
276 | 273 |
277 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; | 274 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; |
278 // Can be null in tests. | 275 // Can be null in tests. |
279 if (!delegate_->GetShellConnector()) | 276 if (!delegate_->GetShellConnector()) |
280 return; | 277 return; |
281 delegate_->GetShellConnector()->ConnectToInterface(prefs::mojom::kServiceName, | 278 delegate_->GetShellConnector()->ConnectToInterface(prefs::mojom::kServiceName, |
282 &pref_manager_ptr); | 279 &pref_manager_ptr); |
283 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); | 280 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); |
284 } | 281 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 363 |
367 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { | 364 void WmShell::SetKeyboardUI(std::unique_ptr<KeyboardUI> keyboard_ui) { |
368 keyboard_ui_ = std::move(keyboard_ui); | 365 keyboard_ui_ = std::move(keyboard_ui); |
369 } | 366 } |
370 | 367 |
371 void WmShell::SetSystemTrayDelegate( | 368 void WmShell::SetSystemTrayDelegate( |
372 std::unique_ptr<SystemTrayDelegate> delegate) { | 369 std::unique_ptr<SystemTrayDelegate> delegate) { |
373 DCHECK(delegate); | 370 DCHECK(delegate); |
374 system_tray_delegate_ = std::move(delegate); | 371 system_tray_delegate_ = std::move(delegate); |
375 system_tray_delegate_->Initialize(); | 372 system_tray_delegate_->Initialize(); |
376 #if defined(OS_CHROMEOS) | |
377 // Accesses WmShell in its constructor. | 373 // Accesses WmShell in its constructor. |
378 logout_confirmation_controller_.reset(new LogoutConfirmationController( | 374 logout_confirmation_controller_.reset(new LogoutConfirmationController( |
379 base::Bind(&SystemTrayController::SignOut, | 375 base::Bind(&SystemTrayController::SignOut, |
380 base::Unretained(system_tray_controller_.get())))); | 376 base::Unretained(system_tray_controller_.get())))); |
381 #endif | |
382 } | 377 } |
383 | 378 |
384 void WmShell::DeleteSystemTrayDelegate() { | 379 void WmShell::DeleteSystemTrayDelegate() { |
385 DCHECK(system_tray_delegate_); | 380 DCHECK(system_tray_delegate_); |
386 #if defined(OS_CHROMEOS) | |
387 // Accesses WmShell in its destructor. | 381 // Accesses WmShell in its destructor. |
388 logout_confirmation_controller_.reset(); | 382 logout_confirmation_controller_.reset(); |
389 #endif | |
390 system_tray_delegate_.reset(); | 383 system_tray_delegate_.reset(); |
391 } | 384 } |
392 | 385 |
393 void WmShell::DeleteWindowCycleController() { | 386 void WmShell::DeleteWindowCycleController() { |
394 window_cycle_controller_.reset(); | 387 window_cycle_controller_.reset(); |
395 } | 388 } |
396 | 389 |
397 void WmShell::DeleteWindowSelectorController() { | 390 void WmShell::DeleteWindowSelectorController() { |
398 window_selector_controller_.reset(); | 391 window_selector_controller_.reset(); |
399 } | 392 } |
(...skipping 24 matching lines...) Expand all Loading... |
424 } | 417 } |
425 | 418 |
426 void WmShell::SessionStateChanged(session_manager::SessionState state) { | 419 void WmShell::SessionStateChanged(session_manager::SessionState state) { |
427 // Create the shelf when a session becomes active. It's safe to do this | 420 // Create the shelf when a session becomes active. It's safe to do this |
428 // multiple times (e.g. initial login vs. multiprofile add session). | 421 // multiple times (e.g. initial login vs. multiprofile add session). |
429 if (state == session_manager::SessionState::ACTIVE) | 422 if (state == session_manager::SessionState::ACTIVE) |
430 CreateShelf(); | 423 CreateShelf(); |
431 } | 424 } |
432 | 425 |
433 } // namespace ash | 426 } // namespace ash |
OLD | NEW |