Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: ash/shell.cc

Issue 2772673002: mash: switch to the new pref service (Closed)
Patch Set: Address review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/shell.h ('k') | chrome/app/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell.h" 5 #include "ash/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 #include "base/bind_helpers.h" 117 #include "base/bind_helpers.h"
118 #include "base/command_line.h" 118 #include "base/command_line.h"
119 #include "base/memory/ptr_util.h" 119 #include "base/memory/ptr_util.h"
120 #include "base/sys_info.h" 120 #include "base/sys_info.h"
121 #include "base/threading/sequenced_worker_pool.h" 121 #include "base/threading/sequenced_worker_pool.h"
122 #include "base/trace_event/trace_event.h" 122 #include "base/trace_event/trace_event.h"
123 #include "chromeos/audio/audio_a11y_controller.h" 123 #include "chromeos/audio/audio_a11y_controller.h"
124 #include "chromeos/chromeos_switches.h" 124 #include "chromeos/chromeos_switches.h"
125 #include "chromeos/dbus/dbus_thread_manager.h" 125 #include "chromeos/dbus/dbus_thread_manager.h"
126 #include "chromeos/system/devicemode.h" 126 #include "chromeos/system/devicemode.h"
127 #include "components/prefs/pref_registry_simple.h"
128 #include "components/prefs/pref_service.h"
127 #include "components/ui_devtools/devtools_server.h" 129 #include "components/ui_devtools/devtools_server.h"
128 #include "services/preferences/public/cpp/pref_client_store.h" 130 #include "services/preferences/public/cpp/pref_service_factory.h"
129 #include "services/preferences/public/interfaces/preferences.mojom.h" 131 #include "services/preferences/public/interfaces/preferences.mojom.h"
130 #include "services/service_manager/public/cpp/connector.h" 132 #include "services/service_manager/public/cpp/connector.h"
131 #include "services/ui/public/interfaces/constants.mojom.h" 133 #include "services/ui/public/interfaces/constants.mojom.h"
132 #include "ui/app_list/presenter/app_list.h" 134 #include "ui/app_list/presenter/app_list.h"
133 #include "ui/aura/client/aura_constants.h" 135 #include "ui/aura/client/aura_constants.h"
134 #include "ui/aura/env.h" 136 #include "ui/aura/env.h"
135 #include "ui/aura/layout_manager.h" 137 #include "ui/aura/layout_manager.h"
136 #include "ui/aura/mus/user_activity_forwarder.h" 138 #include "ui/aura/mus/user_activity_forwarder.h"
137 #include "ui/aura/window.h" 139 #include "ui/aura/window.h"
138 #include "ui/aura/window_event_dispatcher.h" 140 #include "ui/aura/window_event_dispatcher.h"
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // ShelfWindowWatcher has window observers and a pointer to the shelf model. 723 // ShelfWindowWatcher has window observers and a pointer to the shelf model.
722 shelf_window_watcher_.reset(); 724 shelf_window_watcher_.reset();
723 725
724 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC 726 // ShelfItemDelegate subclasses it owns have complex cleanup to run (e.g. ARC
725 // shelf items in Chrome) so explicitly shutdown early. 727 // shelf items in Chrome) so explicitly shutdown early.
726 shelf_model()->DestroyItemDelegates(); 728 shelf_model()->DestroyItemDelegates();
727 729
728 // Must be destroyed before FocusController. 730 // Must be destroyed before FocusController.
729 shelf_delegate_.reset(); 731 shelf_delegate_.reset();
730 732
731 // Removes itself as an observer of |pref_store_|. 733 // Removes itself as an observer of |pref_service_|.
732 shelf_controller_.reset(); 734 shelf_controller_.reset();
733 735
734 wm_shell_->Shutdown(); 736 wm_shell_->Shutdown();
735 737
736 // Depends on |focus_controller_|, so must be destroyed before. 738 // Depends on |focus_controller_|, so must be destroyed before.
737 window_tree_host_manager_.reset(); 739 window_tree_host_manager_.reset();
738 focus_controller_->RemoveObserver(this); 740 focus_controller_->RemoveObserver(this);
739 focus_controller_.reset(); 741 focus_controller_.reset();
740 screen_position_controller_.reset(); 742 screen_position_controller_.reset();
741 743
(...skipping 11 matching lines...) Expand all
753 755
754 PowerStatus::Shutdown(); 756 PowerStatus::Shutdown();
755 757
756 // Ensure that DBusThreadManager outlives this Shell. 758 // Ensure that DBusThreadManager outlives this Shell.
757 DCHECK(chromeos::DBusThreadManager::IsInitialized()); 759 DCHECK(chromeos::DBusThreadManager::IsInitialized());
758 760
759 // Needs to happen right before |instance_| is reset. 761 // Needs to happen right before |instance_| is reset.
760 wm_shell_.reset(); 762 wm_shell_.reset();
761 session_controller_->RemoveSessionStateObserver(this); 763 session_controller_->RemoveSessionStateObserver(this);
762 wallpaper_delegate_.reset(); 764 wallpaper_delegate_.reset();
763 pref_store_ = nullptr; 765 pref_service_ = nullptr;
764 shell_delegate_.reset(); 766 shell_delegate_.reset();
765 767
766 DCHECK(instance_ == this); 768 DCHECK(instance_ == this);
767 instance_ = nullptr; 769 instance_ = nullptr;
768 } 770 }
769 771
770 void Shell::Init(const ShellInitParams& init_params) { 772 void Shell::Init(const ShellInitParams& init_params) {
771 const bool is_mash = wm_shell_->IsRunningInMash(); 773 const bool is_mash = wm_shell_->IsRunningInMash();
772 774
773 blocking_pool_ = init_params.blocking_pool; 775 blocking_pool_ = init_params.blocking_pool;
774 776
775 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate(); 777 wallpaper_delegate_ = shell_delegate_->CreateWallpaperDelegate();
776 778
777 // Can be null in tests. 779 // Can be null in tests.
778 if (shell_delegate_->GetShellConnector()) { 780 if (wm_shell_->IsRunningInMash() && shell_delegate_->GetShellConnector()) {
779 prefs::mojom::PreferencesServiceFactoryPtr pref_factory_ptr; 781 prefs::ConnectToPrefService(
780 shell_delegate_->GetShellConnector()->BindInterface( 782 shell_delegate_->GetShellConnector(),
781 prefs::mojom::kServiceName, &pref_factory_ptr); 783 make_scoped_refptr(new PrefRegistrySimple()),
782 pref_store_ = new preferences::PrefClientStore(std::move(pref_factory_ptr)); 784 base::Bind(&Shell::OnPrefServiceInitialized, base::Unretained(this)),
785 prefs::mojom::kForwarderServiceName);
783 } 786 }
784 787
785 // Some delegates access WmShell during their construction. Create them here 788 // Some delegates access WmShell during their construction. Create them here
786 // instead of the WmShell constructor. 789 // instead of the WmShell constructor.
787 accessibility_delegate_.reset(shell_delegate_->CreateAccessibilityDelegate()); 790 accessibility_delegate_.reset(shell_delegate_->CreateAccessibilityDelegate());
788 palette_delegate_ = shell_delegate_->CreatePaletteDelegate(); 791 palette_delegate_ = shell_delegate_->CreatePaletteDelegate();
789 toast_manager_ = base::MakeUnique<ToastManager>(); 792 toast_manager_ = base::MakeUnique<ToastManager>();
790 793
791 // Install the custom factory early on so that views::FocusManagers for Tray, 794 // Install the custom factory early on so that views::FocusManagers for Tray,
792 // Shelf, and WallPaper could be created by the factory. 795 // Shelf, and WallPaper could be created by the factory.
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } 1222 }
1220 1223
1221 // Only trigger an update in mash because with classic ash chrome calls 1224 // Only trigger an update in mash because with classic ash chrome calls
1222 // UpdateAfterLoginStatusChange() directly. 1225 // UpdateAfterLoginStatusChange() directly.
1223 if (wm_shell_->IsRunningInMash()) { 1226 if (wm_shell_->IsRunningInMash()) {
1224 // TODO(jamescook): Should this call Shell::OnLoginStatusChanged() too? 1227 // TODO(jamescook): Should this call Shell::OnLoginStatusChanged() too?
1225 UpdateAfterLoginStatusChange(session_controller_->GetLoginStatus()); 1228 UpdateAfterLoginStatusChange(session_controller_->GetLoginStatus());
1226 } 1229 }
1227 } 1230 }
1228 1231
1232 void Shell::OnPrefServiceInitialized(
1233 std::unique_ptr<::PrefService> pref_service) {
1234 if (!instance_)
1235 return;
1236 DCHECK(pref_service);
1237 pref_service_ = std::move(pref_service);
1238 }
1239
1229 } // namespace ash 1240 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell.h ('k') | chrome/app/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698