| 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 30 matching lines...) Expand all Loading... |
| 41 #include "ash/common/wm/overview/window_selector_controller.h" | 41 #include "ash/common/wm/overview/window_selector_controller.h" |
| 42 #include "ash/common/wm/root_window_finder.h" | 42 #include "ash/common/wm/root_window_finder.h" |
| 43 #include "ash/common/wm/system_modal_container_layout_manager.h" | 43 #include "ash/common/wm/system_modal_container_layout_manager.h" |
| 44 #include "ash/common/wm/window_cycle_controller.h" | 44 #include "ash/common/wm/window_cycle_controller.h" |
| 45 #include "ash/common/wm_root_window_controller.h" | 45 #include "ash/common/wm_root_window_controller.h" |
| 46 #include "ash/common/wm_window.h" | 46 #include "ash/common/wm_window.h" |
| 47 #include "ash/public/cpp/shell_window_ids.h" | 47 #include "ash/public/cpp/shell_window_ids.h" |
| 48 #include "base/bind.h" | 48 #include "base/bind.h" |
| 49 #include "base/logging.h" | 49 #include "base/logging.h" |
| 50 #include "base/memory/ptr_util.h" | 50 #include "base/memory/ptr_util.h" |
| 51 #include "services/preferences/public/cpp/pref_observer_store.h" |
| 52 #include "services/preferences/public/interfaces/preferences.mojom.h" |
| 53 #include "services/service_manager/public/cpp/connector.h" |
| 51 #include "ui/app_list/presenter/app_list.h" | 54 #include "ui/app_list/presenter/app_list.h" |
| 52 #include "ui/app_list/presenter/app_list_presenter.h" | 55 #include "ui/app_list/presenter/app_list_presenter.h" |
| 53 #include "ui/display/display.h" | 56 #include "ui/display/display.h" |
| 54 #include "ui/views/focus/focus_manager_factory.h" | 57 #include "ui/views/focus/focus_manager_factory.h" |
| 55 | 58 |
| 56 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 57 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" | 60 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
| 58 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | 61 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
| 59 #include "ash/common/system/chromeos/network/vpn_list.h" | 62 #include "ash/common/system/chromeos/network/vpn_list.h" |
| 60 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 63 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 118 // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
| 116 shelf_window_watcher_.reset(); | 119 shelf_window_watcher_.reset(); |
| 117 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC | 120 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
| 118 // shelf items in Chrome) so explicitly shutdown early. | 121 // shelf items in Chrome) so explicitly shutdown early. |
| 119 shelf_model()->DestroyItemDelegates(); | 122 shelf_model()->DestroyItemDelegates(); |
| 120 // Must be destroyed before FocusClient. | 123 // Must be destroyed before FocusClient. |
| 121 shelf_delegate_.reset(); | 124 shelf_delegate_.reset(); |
| 122 | 125 |
| 123 // Balances the Install() in Initialize(). | 126 // Balances the Install() in Initialize(). |
| 124 views::FocusManagerFactory::Install(nullptr); | 127 views::FocusManagerFactory::Install(nullptr); |
| 128 |
| 129 // Removes itself as an observer of |pref_store_|. |
| 130 shelf_controller_.reset(); |
| 125 } | 131 } |
| 126 | 132 |
| 127 ShelfModel* WmShell::shelf_model() { | 133 ShelfModel* WmShell::shelf_model() { |
| 128 return shelf_controller_->model(); | 134 return shelf_controller_->model(); |
| 129 } | 135 } |
| 130 | 136 |
| 131 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, | 137 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, |
| 132 ui::MenuSourceType source_type) { | 138 ui::MenuSourceType source_type) { |
| 133 // Bail if there is no active user session or if the screen is locked. | 139 // Bail if there is no active user session or if the screen is locked. |
| 134 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || | 140 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), | 267 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), |
| 262 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), | 268 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
| 263 window_selector_controller_( | 269 window_selector_controller_( |
| 264 base::MakeUnique<WindowSelectorController>()) { | 270 base::MakeUnique<WindowSelectorController>()) { |
| 265 #if defined(OS_CHROMEOS) | 271 #if defined(OS_CHROMEOS) |
| 266 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | 272 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); |
| 267 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | 273 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); |
| 268 vpn_list_ = base::MakeUnique<VpnList>(); | 274 vpn_list_ = base::MakeUnique<VpnList>(); |
| 269 #endif | 275 #endif |
| 270 session_controller_->AddSessionStateObserver(this); | 276 session_controller_->AddSessionStateObserver(this); |
| 277 |
| 278 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; |
| 279 // Can be null in tests. |
| 280 if (!delegate_->GetShellConnector()) |
| 281 return; |
| 282 delegate_->GetShellConnector()->ConnectToInterface(prefs::mojom::kServiceName, |
| 283 &pref_manager_ptr); |
| 284 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); |
| 271 } | 285 } |
| 272 | 286 |
| 273 WmShell::~WmShell() { | 287 WmShell::~WmShell() { |
| 274 session_controller_->RemoveSessionStateObserver(this); | 288 session_controller_->RemoveSessionStateObserver(this); |
| 275 } | 289 } |
| 276 | 290 |
| 277 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { | 291 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { |
| 278 return GetPrimaryRootWindow()->GetRootWindowController(); | 292 return GetPrimaryRootWindow()->GetRootWindowController(); |
| 279 } | 293 } |
| 280 | 294 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 428 } |
| 415 | 429 |
| 416 void WmShell::SessionStateChanged(session_manager::SessionState state) { | 430 void WmShell::SessionStateChanged(session_manager::SessionState state) { |
| 417 // Create the shelf when a session becomes active. It's safe to do this | 431 // 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). | 432 // multiple times (e.g. initial login vs. multiprofile add session). |
| 419 if (state == session_manager::SessionState::ACTIVE) | 433 if (state == session_manager::SessionState::ACTIVE) |
| 420 CreateShelf(); | 434 CreateShelf(); |
| 421 } | 435 } |
| 422 | 436 |
| 423 } // namespace ash | 437 } // namespace ash |
| OLD | NEW |