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

Side by Side Diff: chrome/browser/chromeos/chrome_interface_factory.cc

Issue 2474653003: PreferencesManager (Closed)
Patch Set: PreferencesConnectionManager Created 4 years, 1 month 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
OLDNEW
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 "chrome/browser/chromeos/chrome_interface_factory.h" 5 #include "chrome/browser/chromeos/chrome_interface_factory.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/mojo_interface_factory.h" 9 #include "ash/common/mojo_interface_factory.h"
10 #include "ash/public/interfaces/new_window.mojom.h" 10 #include "ash/public/interfaces/new_window.mojom.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 16 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
17 #include "chrome/browser/prefs/preferences_connection_manager.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h" 20 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"
20 #include "chrome/browser/ui/ash/ash_util.h" 21 #include "chrome/browser/ui/ash/ash_util.h"
21 #include "chrome/browser/ui/ash/chrome_new_window_client.h" 22 #include "chrome/browser/ui/ash/chrome_new_window_client.h"
22 #include "chrome/browser/ui/ash/keyboard_ui_service.h" 23 #include "chrome/browser/ui/ash/keyboard_ui_service.h"
23 #include "chrome/browser/ui/ash/system_tray_client.h" 24 #include "chrome/browser/ui/ash/system_tray_client.h"
24 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 25 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
25 #include "chrome/browser/ui/browser_commands.h" 26 #include "chrome/browser/ui/browser_commands.h"
26 #include "chrome/browser/ui/browser_finder.h" 27 #include "chrome/browser/ui/browser_finder.h"
27 #include "content/public/common/service_manager_connection.h" 28 #include "content/public/common/service_manager_connection.h"
28 #include "mash/public/interfaces/launchable.mojom.h" 29 #include "mash/public/interfaces/launchable.mojom.h"
29 #include "mojo/public/cpp/bindings/binding_set.h" 30 #include "mojo/public/cpp/bindings/binding_set.h"
31 #include "services/preferences/public/interfaces/preferences.mojom.h"
30 #include "services/service_manager/public/cpp/connection.h" 32 #include "services/service_manager/public/cpp/connection.h"
31 #include "services/service_manager/public/cpp/interface_registry.h" 33 #include "services/service_manager/public/cpp/interface_registry.h"
32 #include "ui/app_list/presenter/app_list_presenter.mojom.h" 34 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
33 #include "ui/keyboard/keyboard.mojom.h" 35 #include "ui/keyboard/keyboard.mojom.h"
34 36
35 namespace chromeos { 37 namespace chromeos {
36 38
37 namespace { 39 namespace {
38 40
39 class ChromeLaunchable : public mash::mojom::Launchable { 41 class ChromeLaunchable : public mash::mojom::Launchable {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 launchable_->ProcessRequest(std::move(request)); 118 launchable_->ProcessRequest(std::move(request));
117 } 119 }
118 120
119 void BindRequest(ash::mojom::NewWindowClientRequest request) { 121 void BindRequest(ash::mojom::NewWindowClientRequest request) {
120 if (!new_window_client_) 122 if (!new_window_client_)
121 new_window_client_.reset(new ChromeNewWindowClient); 123 new_window_client_.reset(new ChromeNewWindowClient);
122 new_window_client_bindings_.AddBinding(new_window_client_.get(), 124 new_window_client_bindings_.AddBinding(new_window_client_.get(),
123 std::move(request)); 125 std::move(request));
124 } 126 }
125 127
128 void BindRequest(prefs::mojom::PreferencesManagerRequest request) {
129 if (!preferences_connection_manager_)
130 preferences_connection_manager_ =
131 base::MakeUnique<chrome::PreferencesConnectionManager>();
132 preferences_connection_manager_->ProcessRequest(std::move(request));
133 }
134
126 void BindRequest(ash::mojom::SystemTrayClientRequest request) { 135 void BindRequest(ash::mojom::SystemTrayClientRequest request) {
127 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(), 136 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(),
128 std::move(request)); 137 std::move(request));
129 } 138 }
130 139
131 void BindRequest(ash::mojom::WallpaperManagerRequest request) { 140 void BindRequest(ash::mojom::WallpaperManagerRequest request) {
132 WallpaperManager::Get()->BindRequest(std::move(request)); 141 WallpaperManager::Get()->BindRequest(std::move(request));
133 } 142 }
134 143
135 void BindRequest(ash::mojom::VolumeControllerRequest request) { 144 void BindRequest(ash::mojom::VolumeControllerRequest request) {
(...skipping 10 matching lines...) Expand all
146 } 155 }
147 156
148 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 157 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
149 158
150 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 159 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
151 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 160 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
152 std::unique_ptr<ChromeLaunchable> launchable_; 161 std::unique_ptr<ChromeLaunchable> launchable_;
153 std::unique_ptr<ChromeNewWindowClient> new_window_client_; 162 std::unique_ptr<ChromeNewWindowClient> new_window_client_;
154 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_; 163 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_;
155 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_; 164 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_;
165 std::unique_ptr<chrome::PreferencesConnectionManager>
166 preferences_connection_manager_;
156 std::unique_ptr<VolumeController> volume_controller_; 167 std::unique_ptr<VolumeController> volume_controller_;
157 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 168 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
158 mojo::BindingSet<app_list::mojom::AppListPresenter> 169 mojo::BindingSet<app_list::mojom::AppListPresenter>
159 app_list_presenter_bindings_; 170 app_list_presenter_bindings_;
160 171
161 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 172 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
162 }; 173 };
163 174
164 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 175 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
165 LAZY_INSTANCE_INITIALIZER; 176 LAZY_INSTANCE_INITIALIZER;
166 177
167 } // namespace 178 } // namespace
168 179
169 ChromeInterfaceFactory::ChromeInterfaceFactory() 180 ChromeInterfaceFactory::ChromeInterfaceFactory()
170 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 181 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
171 182
172 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 183 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
173 184
174 bool ChromeInterfaceFactory::OnConnect( 185 bool ChromeInterfaceFactory::OnConnect(
175 const service_manager::Identity& remote_identity, 186 const service_manager::Identity& remote_identity,
176 service_manager::InterfaceRegistry* registry, 187 service_manager::InterfaceRegistry* registry,
177 service_manager::Connector* connector) { 188 service_manager::Connector* connector) {
178 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 189 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
179 main_thread_task_runner_); 190 main_thread_task_runner_);
180 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 191 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
181 main_thread_task_runner_); 192 main_thread_task_runner_);
182 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>( 193 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>(
183 registry, main_thread_task_runner_); 194 registry, main_thread_task_runner_);
195 FactoryImpl::AddFactory<prefs::mojom::PreferencesManager>(
196 registry, main_thread_task_runner_);
184 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>( 197 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>(
185 registry, main_thread_task_runner_); 198 registry, main_thread_task_runner_);
186 FactoryImpl::AddFactory<ash::mojom::VolumeController>( 199 FactoryImpl::AddFactory<ash::mojom::VolumeController>(
187 registry, main_thread_task_runner_); 200 registry, main_thread_task_runner_);
188 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 201 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
189 registry, main_thread_task_runner_); 202 registry, main_thread_task_runner_);
190 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 203 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
191 registry, main_thread_task_runner_); 204 registry, main_thread_task_runner_);
192 205
193 // In classic ash, the browser process provides ash services to itself. 206 // In classic ash, the browser process provides ash services to itself.
194 if (!chrome::IsRunningInMash()) { 207 if (!chrome::IsRunningInMash()) {
195 ash::mojo_interface_factory::RegisterInterfaces(registry, 208 ash::mojo_interface_factory::RegisterInterfaces(registry,
196 main_thread_task_runner_); 209 main_thread_task_runner_);
197 } 210 }
198 211
199 return true; 212 return true;
200 } 213 }
201 214
202 } // namespace chromeos 215 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698