blob: 10aec6ab035ae40b5c6c6327a4f0d334b535a68e [file] [log] [blame]
James Cookb0bf8e82017-04-09 17:01:441// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ash/mojo_interface_factory.h"
6
7#include <utility>
8
9#include "ash/accelerators/accelerator_controller.h"
10#include "ash/cast_config_controller.h"
Scott Violetd64dac12017-06-02 21:50:0811#include "ash/display/ash_display_controller.h"
xiaoyinh2bbdd102017-05-18 23:29:4212#include "ash/login/lock_screen_controller.h"
James Cookb0bf8e82017-04-09 17:01:4413#include "ash/media_controller.h"
14#include "ash/new_window_controller.h"
15#include "ash/session/session_controller.h"
16#include "ash/shelf/shelf_controller.h"
17#include "ash/shell.h"
18#include "ash/shell_delegate.h"
19#include "ash/shutdown_controller.h"
20#include "ash/system/locale/locale_notification_controller.h"
21#include "ash/system/network/vpn_list.h"
afakhryee3e2fa2017-06-15 17:45:4122#include "ash/system/night_light/night_light_controller.h"
James Cookb0bf8e82017-04-09 17:01:4423#include "ash/system/tray/system_tray_controller.h"
tbarzicc78da1ff92017-05-08 20:46:1524#include "ash/tray_action/tray_action.h"
James Cookb0bf8e82017-04-09 17:01:4425#include "ash/wallpaper/wallpaper_controller.h"
oshima341337af2017-05-26 23:34:2326#include "ash/wm/maximize_mode/maximize_mode_controller.h"
James Cookb0bf8e82017-04-09 17:01:4427#include "base/bind.h"
Gabriel Charette5ff87ce2017-05-16 18:03:4528#include "base/single_thread_task_runner.h"
bena5c972c2017-05-04 01:38:4329#include "services/service_manager/public/cpp/bind_source_info.h"
James Cookb0bf8e82017-04-09 17:01:4430#include "services/service_manager/public/cpp/binder_registry.h"
31#include "ui/app_list/presenter/app_list.h"
32
33namespace ash {
34
35namespace {
36
37void BindAcceleratorControllerRequestOnMainThread(
bena5c972c2017-05-04 01:38:4338 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:4439 mojom::AcceleratorControllerRequest request) {
40 Shell::Get()->accelerator_controller()->BindRequest(std::move(request));
41}
42
bena5c972c2017-05-04 01:38:4343void BindAppListRequestOnMainThread(
44 const service_manager::BindSourceInfo& source_info,
45 app_list::mojom::AppListRequest request) {
James Cookb0bf8e82017-04-09 17:01:4446 Shell::Get()->app_list()->BindRequest(std::move(request));
47}
48
Scott Violetd64dac12017-06-02 21:50:0849void BindAshDisplayControllerRequestOnMainThread(
50 const service_manager::BindSourceInfo& source_info,
51 mojom::AshDisplayControllerRequest request) {
52 Shell::Get()->ash_display_controller()->BindRequest(std::move(request));
53}
54
bena5c972c2017-05-04 01:38:4355void BindCastConfigOnMainThread(
56 const service_manager::BindSourceInfo& source_info,
57 mojom::CastConfigRequest request) {
James Cookb0bf8e82017-04-09 17:01:4458 Shell::Get()->cast_config()->BindRequest(std::move(request));
59}
60
61void BindLocaleNotificationControllerOnMainThread(
bena5c972c2017-05-04 01:38:4362 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:4463 mojom::LocaleNotificationControllerRequest request) {
64 Shell::Get()->locale_notification_controller()->BindRequest(
65 std::move(request));
66}
67
xiaoyinh2bbdd102017-05-18 23:29:4268void BindLockScreenRequestOnMainThread(
69 const service_manager::BindSourceInfo& source_info,
70 mojom::LockScreenRequest request) {
71 Shell::Get()->lock_screen_controller()->BindRequest(std::move(request));
72}
73
James Cookb0bf8e82017-04-09 17:01:4474void BindMediaControllerRequestOnMainThread(
bena5c972c2017-05-04 01:38:4375 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:4476 mojom::MediaControllerRequest request) {
77 Shell::Get()->media_controller()->BindRequest(std::move(request));
78}
79
80void BindNewWindowControllerRequestOnMainThread(
bena5c972c2017-05-04 01:38:4381 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:4482 mojom::NewWindowControllerRequest request) {
83 Shell::Get()->new_window_controller()->BindRequest(std::move(request));
84}
85
afakhryee3e2fa2017-06-15 17:45:4186void BindNightLightControllerRequestOnMainThread(
87 const service_manager::BindSourceInfo& source_info,
88 mojom::NightLightControllerRequest request) {
89 Shell::Get()->night_light_controller()->BindRequest(std::move(request));
90}
91
James Cookb0bf8e82017-04-09 17:01:4492void BindSessionControllerRequestOnMainThread(
bena5c972c2017-05-04 01:38:4393 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:4494 mojom::SessionControllerRequest request) {
95 Shell::Get()->session_controller()->BindRequest(std::move(request));
96}
97
bena5c972c2017-05-04 01:38:4398void BindShelfRequestOnMainThread(
99 const service_manager::BindSourceInfo& source_info,
100 mojom::ShelfControllerRequest request) {
James Cookb0bf8e82017-04-09 17:01:44101 Shell::Get()->shelf_controller()->BindRequest(std::move(request));
102}
103
104void BindShutdownControllerRequestOnMainThread(
bena5c972c2017-05-04 01:38:43105 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:44106 mojom::ShutdownControllerRequest request) {
107 Shell::Get()->shutdown_controller()->BindRequest(std::move(request));
108}
109
bena5c972c2017-05-04 01:38:43110void BindSystemTrayRequestOnMainThread(
111 const service_manager::BindSourceInfo& source_info,
112 mojom::SystemTrayRequest request) {
James Cookb0bf8e82017-04-09 17:01:44113 Shell::Get()->system_tray_controller()->BindRequest(std::move(request));
114}
115
bena5c972c2017-05-04 01:38:43116void BindTouchViewRequestOnMainThread(
117 const service_manager::BindSourceInfo& source_info,
118 mojom::TouchViewManagerRequest request) {
oshima341337af2017-05-26 23:34:23119 Shell::Get()->maximize_mode_controller()->BindRequest(std::move(request));
James Cookb0bf8e82017-04-09 17:01:44120}
121
tbarzicc78da1ff92017-05-08 20:46:15122void BindTrayActionRequestOnMainThread(
123 const service_manager::BindSourceInfo& source_info,
124 mojom::TrayActionRequest request) {
125 Shell::Get()->tray_action()->BindRequest(std::move(request));
126}
127
bena5c972c2017-05-04 01:38:43128void BindVpnListRequestOnMainThread(
129 const service_manager::BindSourceInfo& source_info,
130 mojom::VpnListRequest request) {
James Cookb0bf8e82017-04-09 17:01:44131 Shell::Get()->vpn_list()->BindRequest(std::move(request));
132}
133
134void BindWallpaperRequestOnMainThread(
bena5c972c2017-05-04 01:38:43135 const service_manager::BindSourceInfo& source_info,
James Cookb0bf8e82017-04-09 17:01:44136 mojom::WallpaperControllerRequest request) {
137 Shell::Get()->wallpaper_controller()->BindRequest(std::move(request));
138}
139
140} // namespace
141
142namespace mojo_interface_factory {
143
144void RegisterInterfaces(
145 service_manager::BinderRegistry* registry,
146 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner) {
147 registry->AddInterface(
148 base::Bind(&BindAcceleratorControllerRequestOnMainThread),
149 main_thread_task_runner);
150 registry->AddInterface(base::Bind(&BindAppListRequestOnMainThread),
151 main_thread_task_runner);
Scott Violetd64dac12017-06-02 21:50:08152 registry->AddInterface(
153 base::Bind(&BindAshDisplayControllerRequestOnMainThread),
154 main_thread_task_runner);
James Cookb0bf8e82017-04-09 17:01:44155 registry->AddInterface(base::Bind(&BindCastConfigOnMainThread),
156 main_thread_task_runner);
157 registry->AddInterface(
158 base::Bind(&BindLocaleNotificationControllerOnMainThread),
159 main_thread_task_runner);
xiaoyinh2bbdd102017-05-18 23:29:42160 registry->AddInterface(base::Bind(&BindLockScreenRequestOnMainThread),
161 main_thread_task_runner);
James Cookb0bf8e82017-04-09 17:01:44162 registry->AddInterface(base::Bind(&BindMediaControllerRequestOnMainThread),
163 main_thread_task_runner);
164 registry->AddInterface(
165 base::Bind(&BindNewWindowControllerRequestOnMainThread),
166 main_thread_task_runner);
afakhryee3e2fa2017-06-15 17:45:41167 if (NightLightController::IsFeatureEnabled()) {
168 registry->AddInterface(
169 base::Bind(&BindNightLightControllerRequestOnMainThread),
170 main_thread_task_runner);
171 }
James Cookb0bf8e82017-04-09 17:01:44172 registry->AddInterface(base::Bind(&BindSessionControllerRequestOnMainThread),
173 main_thread_task_runner);
174 registry->AddInterface(base::Bind(&BindShelfRequestOnMainThread),
175 main_thread_task_runner);
176 registry->AddInterface(base::Bind(&BindShutdownControllerRequestOnMainThread),
177 main_thread_task_runner);
178 registry->AddInterface(base::Bind(&BindSystemTrayRequestOnMainThread),
179 main_thread_task_runner);
180 registry->AddInterface(base::Bind(&BindTouchViewRequestOnMainThread),
181 main_thread_task_runner);
tbarzicc78da1ff92017-05-08 20:46:15182 registry->AddInterface(base::Bind(&BindTrayActionRequestOnMainThread),
183 main_thread_task_runner);
James Cookb0bf8e82017-04-09 17:01:44184 registry->AddInterface(base::Bind(&BindVpnListRequestOnMainThread),
185 main_thread_task_runner);
186 registry->AddInterface(base::Bind(&BindWallpaperRequestOnMainThread),
187 main_thread_task_runner);
188}
189
190} // namespace mojo_interface_factory
191
192} // namespace ash