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

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

Issue 2525563003: mash: Change CastConfigDelegate to a mojoified CastConfigClient. (Closed)
Patch Set: Now for the external apitests as well. Created 4 years 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/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
21 #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"
22 #include "chrome/browser/ui/ash/ash_util.h" 22 #include "chrome/browser/ui/ash/ash_util.h"
23 #include "chrome/browser/ui/ash/cast_config_client_media_router.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"
31 #include "services/service_manager/public/cpp/connection.h" 32 #include "services/service_manager/public/cpp/connection.h"
32 #include "services/service_manager/public/cpp/interface_registry.h" 33 #include "services/service_manager/public/cpp/interface_registry.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (!factory_.Get()) 98 if (!factory_.Get())
98 factory_.Get() = base::MakeUnique<FactoryImpl>(); 99 factory_.Get() = base::MakeUnique<FactoryImpl>();
99 return factory_.Get().get(); 100 return factory_.Get().get();
100 } 101 }
101 102
102 template <typename Interface> 103 template <typename Interface>
103 static void CallMainThreadFactory(mojo::InterfaceRequest<Interface> request) { 104 static void CallMainThreadFactory(mojo::InterfaceRequest<Interface> request) {
104 Get()->BindRequest(std::move(request)); 105 Get()->BindRequest(std::move(request));
105 } 106 }
106 107
108 void BindRequest(ash::mojom::CastConfigClientRequest request) {
109 if (!cast_config_client_)
110 cast_config_client_ = base::MakeUnique<CastConfigClientMediaRouter>();
111 cast_config_client_bindings_.AddBinding(cast_config_client_.get(),
112 std::move(request));
113 }
114
107 void BindRequest(keyboard::mojom::KeyboardRequest request) { 115 void BindRequest(keyboard::mojom::KeyboardRequest request) {
108 if (!keyboard_ui_service_) 116 if (!keyboard_ui_service_)
109 keyboard_ui_service_ = base::MakeUnique<KeyboardUIService>(); 117 keyboard_ui_service_ = base::MakeUnique<KeyboardUIService>();
110 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(), 118 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(),
111 std::move(request)); 119 std::move(request));
112 } 120 }
113 121
114 void BindRequest(mash::mojom::LaunchableRequest request) { 122 void BindRequest(mash::mojom::LaunchableRequest request) {
115 if (!launchable_) 123 if (!launchable_)
116 launchable_ = base::MakeUnique<ChromeLaunchable>(); 124 launchable_ = base::MakeUnique<ChromeLaunchable>();
(...skipping 22 matching lines...) Expand all
139 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>(); 147 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>();
140 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(), 148 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
141 std::move(request)); 149 std::move(request));
142 } 150 }
143 151
144 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 152 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
145 153
146 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 154 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
147 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 155 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
148 std::unique_ptr<ChromeLaunchable> launchable_; 156 std::unique_ptr<ChromeLaunchable> launchable_;
157 std::unique_ptr<CastConfigClientMediaRouter> cast_config_client_;
158 mojo::BindingSet<ash::mojom::CastConfigClient> cast_config_client_bindings_;
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_;
151 std::unique_ptr<VolumeController> volume_controller_; 161 std::unique_ptr<VolumeController> volume_controller_;
152 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 162 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
153 mojo::BindingSet<app_list::mojom::AppListPresenter> 163 mojo::BindingSet<app_list::mojom::AppListPresenter>
154 app_list_presenter_bindings_; 164 app_list_presenter_bindings_;
155 165
156 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 166 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
157 }; 167 };
158 168
(...skipping 11 matching lines...) Expand all
170 const service_manager::Identity& remote_identity, 180 const service_manager::Identity& remote_identity,
171 service_manager::InterfaceRegistry* registry, 181 service_manager::InterfaceRegistry* registry,
172 service_manager::Connector* connector) { 182 service_manager::Connector* connector) {
173 // TODO(jamescook): Only register the interfaces needed for a particular 183 // TODO(jamescook): Only register the interfaces needed for a particular
174 // |remote_identity|. For example, a connection from service:ash needs these, 184 // |remote_identity|. For example, a connection from service:ash needs these,
175 // but a connection from service:content_gpu does not. 185 // but a connection from service:content_gpu does not.
176 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 186 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
177 main_thread_task_runner_); 187 main_thread_task_runner_);
178 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 188 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
179 main_thread_task_runner_); 189 main_thread_task_runner_);
190 FactoryImpl::AddFactory<ash::mojom::CastConfigClient>(
191 registry, main_thread_task_runner_);
180 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>( 192 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>(
181 registry, main_thread_task_runner_); 193 registry, main_thread_task_runner_);
182 FactoryImpl::AddFactory<ash::mojom::VolumeController>( 194 FactoryImpl::AddFactory<ash::mojom::VolumeController>(
183 registry, main_thread_task_runner_); 195 registry, main_thread_task_runner_);
184 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 196 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
185 registry, main_thread_task_runner_); 197 registry, main_thread_task_runner_);
186 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 198 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
187 registry, main_thread_task_runner_); 199 registry, main_thread_task_runner_);
188 200
189 // In classic ash, the browser process provides ash services to itself. 201 // In classic ash, the browser process provides ash services to itself.
190 if (!chrome::IsRunningInMash()) { 202 if (!chrome::IsRunningInMash()) {
191 ash::mojo_interface_factory::RegisterInterfaces(registry, 203 ash::mojo_interface_factory::RegisterInterfaces(registry,
192 main_thread_task_runner_); 204 main_thread_task_runner_);
193 } 205 }
194 206
195 return true; 207 return true;
196 } 208 }
197 209
198 } // namespace chromeos 210 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698