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