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 28 matching lines...) Expand all Loading... |
39 #include "ash/common/wm/overview/window_selector_controller.h" | 39 #include "ash/common/wm/overview/window_selector_controller.h" |
40 #include "ash/common/wm/root_window_finder.h" | 40 #include "ash/common/wm/root_window_finder.h" |
41 #include "ash/common/wm/system_modal_container_layout_manager.h" | 41 #include "ash/common/wm/system_modal_container_layout_manager.h" |
42 #include "ash/common/wm/window_cycle_controller.h" | 42 #include "ash/common/wm/window_cycle_controller.h" |
43 #include "ash/common/wm_root_window_controller.h" | 43 #include "ash/common/wm_root_window_controller.h" |
44 #include "ash/common/wm_window.h" | 44 #include "ash/common/wm_window.h" |
45 #include "ash/public/cpp/shell_window_ids.h" | 45 #include "ash/public/cpp/shell_window_ids.h" |
46 #include "base/bind.h" | 46 #include "base/bind.h" |
47 #include "base/logging.h" | 47 #include "base/logging.h" |
48 #include "base/memory/ptr_util.h" | 48 #include "base/memory/ptr_util.h" |
| 49 #include "services/catalog/public/interfaces/constants.mojom.h" |
| 50 #include "services/preferences/public/cpp/pref_observer_store.h" |
| 51 #include "services/preferences/public/interfaces/preferences.mojom.h" |
| 52 #include "services/service_manager/public/cpp/connector.h" |
49 #include "ui/app_list/presenter/app_list_presenter.h" | 53 #include "ui/app_list/presenter/app_list_presenter.h" |
50 #include "ui/display/display.h" | 54 #include "ui/display/display.h" |
51 #include "ui/views/focus/focus_manager_factory.h" | 55 #include "ui/views/focus/focus_manager_factory.h" |
52 | 56 |
53 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) |
54 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" | 58 #include "ash/common/system/chromeos/brightness/brightness_controller_chromeos.h
" |
55 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" | 59 #include "ash/common/system/chromeos/keyboard_brightness_controller.h" |
56 #include "ash/common/system/chromeos/network/vpn_list.h" | 60 #include "ash/common/system/chromeos/network/vpn_list.h" |
57 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" | 61 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h" |
58 #endif | 62 #endif |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // ShelfWindowWatcher has window observers and a pointer to the shelf model. | 117 // ShelfWindowWatcher has window observers and a pointer to the shelf model. |
114 shelf_window_watcher_.reset(); | 118 shelf_window_watcher_.reset(); |
115 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC | 119 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC |
116 // shelf items in Chrome) so explicitly shutdown early. | 120 // shelf items in Chrome) so explicitly shutdown early. |
117 shelf_model()->DestroyItemDelegates(); | 121 shelf_model()->DestroyItemDelegates(); |
118 // Must be destroyed before FocusClient. | 122 // Must be destroyed before FocusClient. |
119 shelf_delegate_.reset(); | 123 shelf_delegate_.reset(); |
120 | 124 |
121 // Balances the Install() in Initialize(). | 125 // Balances the Install() in Initialize(). |
122 views::FocusManagerFactory::Install(nullptr); | 126 views::FocusManagerFactory::Install(nullptr); |
| 127 |
| 128 // Removes itself as an observer of |pref_store_|. |
| 129 shelf_controller_.reset(); |
123 } | 130 } |
124 | 131 |
125 ShelfModel* WmShell::shelf_model() { | 132 ShelfModel* WmShell::shelf_model() { |
126 return shelf_controller_->model(); | 133 return shelf_controller_->model(); |
127 } | 134 } |
128 | 135 |
129 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, | 136 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, |
130 ui::MenuSourceType source_type) { | 137 ui::MenuSourceType source_type) { |
131 // Bail if there is no active user session or if the screen is locked. | 138 // Bail if there is no active user session or if the screen is locked. |
132 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || | 139 if (GetSessionStateDelegate()->NumberOfLoggedInUsers() < 1 || |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), | 268 system_tray_notifier_(base::MakeUnique<SystemTrayNotifier>()), |
262 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), | 269 wallpaper_delegate_(delegate_->CreateWallpaperDelegate()), |
263 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), | 270 window_cycle_controller_(base::MakeUnique<WindowCycleController>()), |
264 window_selector_controller_( | 271 window_selector_controller_( |
265 base::MakeUnique<WindowSelectorController>()) { | 272 base::MakeUnique<WindowSelectorController>()) { |
266 #if defined(OS_CHROMEOS) | 273 #if defined(OS_CHROMEOS) |
267 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); | 274 brightness_control_delegate_.reset(new system::BrightnessControllerChromeos); |
268 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); | 275 keyboard_brightness_control_delegate_.reset(new KeyboardBrightnessController); |
269 vpn_list_ = base::MakeUnique<VpnList>(); | 276 vpn_list_ = base::MakeUnique<VpnList>(); |
270 #endif | 277 #endif |
| 278 delegate_->GetShellConnector()->ConnectToInterface( |
| 279 catalog::mojom::kServiceName, &catalog_); |
| 280 catalog_->GetEntriesProvidingCapability( |
| 281 prefs::mojom::kServiceName, |
| 282 base::Bind(&WmShell::OnGotCatalogEntries, base::Unretained(this))); |
271 } | 283 } |
272 | 284 |
273 WmShell::~WmShell() {} | 285 WmShell::~WmShell() {} |
274 | 286 |
275 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { | 287 WmRootWindowController* WmShell::GetPrimaryRootWindowController() { |
276 return GetPrimaryRootWindow()->GetRootWindowController(); | 288 return GetPrimaryRootWindow()->GetRootWindowController(); |
277 } | 289 } |
278 | 290 |
279 WmWindow* WmShell::GetRootWindowForNewWindows() { | 291 WmWindow* WmShell::GetRootWindowForNewWindows() { |
280 if (scoped_root_window_for_new_windows_) | 292 if (scoped_root_window_for_new_windows_) |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 416 |
405 void WmShell::DeleteToastManager() { | 417 void WmShell::DeleteToastManager() { |
406 toast_manager_.reset(); | 418 toast_manager_.reset(); |
407 } | 419 } |
408 | 420 |
409 void WmShell::SetAcceleratorController( | 421 void WmShell::SetAcceleratorController( |
410 std::unique_ptr<AcceleratorController> accelerator_controller) { | 422 std::unique_ptr<AcceleratorController> accelerator_controller) { |
411 accelerator_controller_ = std::move(accelerator_controller); | 423 accelerator_controller_ = std::move(accelerator_controller); |
412 } | 424 } |
413 | 425 |
| 426 void WmShell::OnGotCatalogEntries( |
| 427 std::vector<catalog::mojom::EntryPtr> entries) { |
| 428 DCHECK(!entries.empty()); |
| 429 // TODO(jonross): Update this if we end up with more than one |
| 430 // PreferencesManager service. |
| 431 prefs::mojom::PreferencesManagerPtr pref_manager_ptr; |
| 432 delegate_->GetShellConnector()->ConnectToInterface((*entries.begin())->name, |
| 433 &pref_manager_ptr); |
| 434 pref_store_ = new preferences::PrefObserverStore(std::move(pref_manager_ptr)); |
| 435 } |
| 436 |
414 } // namespace ash | 437 } // namespace ash |
OLD | NEW |