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