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

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

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: 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 #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/chromeos/power/shutdown_client_impl.h"
20 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h" 21 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"
23 #include "chrome/browser/ui/ash/ash_util.h" 22 #include "chrome/browser/ui/ash/ash_util.h"
24 #include "chrome/browser/ui/ash/chrome_new_window_client.h" 23 #include "chrome/browser/ui/ash/chrome_new_window_client.h"
25 #include "chrome/browser/ui/ash/keyboard_ui_service.h" 24 #include "chrome/browser/ui/ash/keyboard_ui_service.h"
26 #include "chrome/browser/ui/ash/system_tray_client.h" 25 #include "chrome/browser/ui/ash/system_tray_client.h"
27 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 26 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
28 #include "chrome/browser/ui/browser_commands.h" 27 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_finder.h" 28 #include "chrome/browser/ui/browser_finder.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 launchable_->ProcessRequest(std::move(request)); 118 launchable_->ProcessRequest(std::move(request));
120 } 119 }
121 120
122 void BindRequest(ash::mojom::NewWindowClientRequest request) { 121 void BindRequest(ash::mojom::NewWindowClientRequest request) {
123 if (!new_window_client_) 122 if (!new_window_client_)
124 new_window_client_.reset(new ChromeNewWindowClient); 123 new_window_client_.reset(new ChromeNewWindowClient);
125 new_window_client_bindings_.AddBinding(new_window_client_.get(), 124 new_window_client_bindings_.AddBinding(new_window_client_.get(),
126 std::move(request)); 125 std::move(request));
127 } 126 }
128 127
129 void BindRequest(ash::mojom::ShutdownClientRequest request) {
130 if (!shutdown_client_)
131 shutdown_client_ = base::MakeUnique<ShutdownClientImpl>();
132 shutdown_client_bindings_.AddBinding(shutdown_client_.get(),
133 std::move(request));
134 }
135
136 void BindRequest(ash::mojom::SystemTrayClientRequest request) { 128 void BindRequest(ash::mojom::SystemTrayClientRequest request) {
137 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(), 129 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(),
138 std::move(request)); 130 std::move(request));
139 } 131 }
140 132
141 void BindRequest(ash::mojom::WallpaperManagerRequest request) { 133 void BindRequest(ash::mojom::WallpaperManagerRequest request) {
142 WallpaperManager::Get()->BindRequest(std::move(request)); 134 WallpaperManager::Get()->BindRequest(std::move(request));
143 } 135 }
144 136
145 void BindRequest(ash::mojom::VolumeControllerRequest request) { 137 void BindRequest(ash::mojom::VolumeControllerRequest request) {
146 if (!volume_controller_) 138 if (!volume_controller_)
147 volume_controller_ = base::MakeUnique<VolumeController>(); 139 volume_controller_ = base::MakeUnique<VolumeController>();
148 volume_controller_->BindRequest(std::move(request)); 140 volume_controller_->BindRequest(std::move(request));
149 } 141 }
150 142
151 void BindRequest(app_list::mojom::AppListPresenterRequest request) { 143 void BindRequest(app_list::mojom::AppListPresenterRequest request) {
152 if (!app_list_presenter_service_) 144 if (!app_list_presenter_service_)
153 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>(); 145 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>();
154 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(), 146 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
155 std::move(request)); 147 std::move(request));
156 } 148 }
157 149
158 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 150 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
159 151
160 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 152 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
161 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 153 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
162 std::unique_ptr<ChromeLaunchable> launchable_; 154 std::unique_ptr<ChromeLaunchable> launchable_;
163 std::unique_ptr<ChromeNewWindowClient> new_window_client_; 155 std::unique_ptr<ChromeNewWindowClient> new_window_client_;
164 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_; 156 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_;
165 std::unique_ptr<ShutdownClientImpl> shutdown_client_;
166 mojo::BindingSet<ash::mojom::ShutdownClient> shutdown_client_bindings_;
167 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_; 157 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_;
168 std::unique_ptr<VolumeController> volume_controller_; 158 std::unique_ptr<VolumeController> volume_controller_;
169 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 159 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
170 mojo::BindingSet<app_list::mojom::AppListPresenter> 160 mojo::BindingSet<app_list::mojom::AppListPresenter>
171 app_list_presenter_bindings_; 161 app_list_presenter_bindings_;
172 162
173 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 163 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
174 }; 164 };
175 165
176 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 166 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
177 LAZY_INSTANCE_INITIALIZER; 167 LAZY_INSTANCE_INITIALIZER;
178 168
179 } // namespace 169 } // namespace
180 170
181 ChromeInterfaceFactory::ChromeInterfaceFactory() 171 ChromeInterfaceFactory::ChromeInterfaceFactory()
182 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 172 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
183 173
184 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 174 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
185 175
186 bool ChromeInterfaceFactory::OnConnect( 176 bool ChromeInterfaceFactory::OnConnect(
187 const service_manager::Identity& remote_identity, 177 const service_manager::Identity& remote_identity,
188 service_manager::InterfaceRegistry* registry, 178 service_manager::InterfaceRegistry* registry,
189 service_manager::Connector* connector) { 179 service_manager::Connector* connector) {
180 // TODO(jamescook): Only register the interfaces needed for a particular
181 // |remote_identity|. For example, a connection from service:ash needs these,
182 // but a connection from service:content_gpu does not.
James Cook 2016/11/12 01:32:18 I talked to rockot@ -- this doesn't hurt anything
190 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 183 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
191 main_thread_task_runner_); 184 main_thread_task_runner_);
192 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 185 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
193 main_thread_task_runner_); 186 main_thread_task_runner_);
194 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>( 187 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>(
195 registry, main_thread_task_runner_); 188 registry, main_thread_task_runner_);
196 FactoryImpl::AddFactory<ash::mojom::ShutdownClient>(registry,
197 main_thread_task_runner_);
198 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>( 189 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>(
199 registry, main_thread_task_runner_); 190 registry, main_thread_task_runner_);
200 FactoryImpl::AddFactory<ash::mojom::VolumeController>( 191 FactoryImpl::AddFactory<ash::mojom::VolumeController>(
201 registry, main_thread_task_runner_); 192 registry, main_thread_task_runner_);
202 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 193 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
203 registry, main_thread_task_runner_); 194 registry, main_thread_task_runner_);
204 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 195 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
205 registry, main_thread_task_runner_); 196 registry, main_thread_task_runner_);
206 197
207 // In classic ash, the browser process provides ash services to itself. 198 // In classic ash, the browser process provides ash services to itself.
208 if (!chrome::IsRunningInMash()) { 199 if (!chrome::IsRunningInMash()) {
209 ash::mojo_interface_factory::RegisterInterfaces(registry, 200 ash::mojo_interface_factory::RegisterInterfaces(registry,
210 main_thread_task_runner_); 201 main_thread_task_runner_);
211 } 202 }
212 203
213 return true; 204 return true;
214 } 205 }
215 206
216 } // namespace chromeos 207 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698