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

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

Issue 2427913003: Use mojo volume interfaces for mash and classic ash. (Closed)
Patch Set: Address comments. Created 4 years, 2 months 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 8
9 #include "ash/common/mojo_interface_factory.h" 9 #include "ash/common/mojo_interface_factory.h"
10 #include "ash/public/interfaces/wallpaper.mojom.h" 10 #include "ash/public/interfaces/wallpaper.mojom.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "base/threading/thread_task_runner_handle.h" 14 #include "base/threading/thread_task_runner_handle.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h" 17 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"
18 #include "chrome/browser/ui/ash/ash_util.h" 18 #include "chrome/browser/ui/ash/ash_util.h"
19 #include "chrome/browser/ui/ash/chrome_wallpaper_manager.h" 19 #include "chrome/browser/ui/ash/chrome_wallpaper_manager.h"
20 #include "chrome/browser/ui/ash/keyboard_ui_service.h" 20 #include "chrome/browser/ui/ash/keyboard_ui_service.h"
21 #include "chrome/browser/ui/ash/system_tray_client.h" 21 #include "chrome/browser/ui/ash/system_tray_client.h"
22 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
22 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
24 #include "content/public/common/service_manager_connection.h" 25 #include "content/public/common/service_manager_connection.h"
25 #include "mash/public/interfaces/launchable.mojom.h" 26 #include "mash/public/interfaces/launchable.mojom.h"
26 #include "mojo/public/cpp/bindings/binding_set.h" 27 #include "mojo/public/cpp/bindings/binding_set.h"
27 #include "services/service_manager/public/cpp/connection.h" 28 #include "services/service_manager/public/cpp/connection.h"
28 #include "services/service_manager/public/cpp/interface_registry.h" 29 #include "services/service_manager/public/cpp/interface_registry.h"
29 #include "ui/app_list/presenter/app_list_presenter.mojom.h" 30 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
30 #include "ui/keyboard/keyboard.mojom.h" 31 #include "ui/keyboard/keyboard.mojom.h"
31 32
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(), 121 system_tray_client_bindings_.AddBinding(SystemTrayClient::Get(),
121 std::move(request)); 122 std::move(request));
122 } 123 }
123 124
124 void BindRequest(ash::mojom::WallpaperManagerRequest request) { 125 void BindRequest(ash::mojom::WallpaperManagerRequest request) {
125 if (!wallpaper_manager_) 126 if (!wallpaper_manager_)
126 wallpaper_manager_.reset(new ChromeWallpaperManager); 127 wallpaper_manager_.reset(new ChromeWallpaperManager);
127 wallpaper_manager_->ProcessRequest(std::move(request)); 128 wallpaper_manager_->ProcessRequest(std::move(request));
128 } 129 }
129 130
131 void BindRequest(ash::mojom::VolumeControllerRequest request) {
132 if (!volume_controller_)
133 volume_controller_.reset(new VolumeController);
sky 2016/10/19 15:26:39 MakeUnique if possible.
msw 2016/10/19 22:36:25 Done (here and elsewhere).
134 volume_controller_->BindRequest(std::move(request));
135 }
136
130 void BindRequest(app_list::mojom::AppListPresenterRequest request) { 137 void BindRequest(app_list::mojom::AppListPresenterRequest request) {
131 if (!app_list_presenter_service_) 138 if (!app_list_presenter_service_)
132 app_list_presenter_service_.reset(new AppListPresenterService); 139 app_list_presenter_service_.reset(new AppListPresenterService);
133 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(), 140 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
134 std::move(request)); 141 std::move(request));
135 } 142 }
136 143
137 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 144 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
138 145
139 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 146 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
140 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 147 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
141 std::unique_ptr<ChromeLaunchable> launchable_; 148 std::unique_ptr<ChromeLaunchable> launchable_;
142 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_; 149 mojo::BindingSet<ash::mojom::SystemTrayClient> system_tray_client_bindings_;
143 std::unique_ptr<ChromeWallpaperManager> wallpaper_manager_; 150 std::unique_ptr<ChromeWallpaperManager> wallpaper_manager_;
151 std::unique_ptr<VolumeController> volume_controller_;
144 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 152 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
145 mojo::BindingSet<app_list::mojom::AppListPresenter> 153 mojo::BindingSet<app_list::mojom::AppListPresenter>
146 app_list_presenter_bindings_; 154 app_list_presenter_bindings_;
147 155
148 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 156 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
149 }; 157 };
150 158
151 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 159 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
152 LAZY_INSTANCE_INITIALIZER; 160 LAZY_INSTANCE_INITIALIZER;
153 161
154 } // namespace 162 } // namespace
155 163
156 ChromeInterfaceFactory::ChromeInterfaceFactory() 164 ChromeInterfaceFactory::ChromeInterfaceFactory()
157 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 165 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
158 166
159 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 167 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
160 168
161 bool ChromeInterfaceFactory::OnConnect( 169 bool ChromeInterfaceFactory::OnConnect(
162 const service_manager::Identity& remote_identity, 170 const service_manager::Identity& remote_identity,
163 service_manager::InterfaceRegistry* registry, 171 service_manager::InterfaceRegistry* registry,
164 service_manager::Connector* connector) { 172 service_manager::Connector* connector) {
165 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 173 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
166 main_thread_task_runner_); 174 main_thread_task_runner_);
167 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 175 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
168 main_thread_task_runner_); 176 main_thread_task_runner_);
169 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>( 177 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>(
170 registry, main_thread_task_runner_); 178 registry, main_thread_task_runner_);
179 FactoryImpl::AddFactory<ash::mojom::VolumeController>(
180 registry, main_thread_task_runner_);
171 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 181 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
172 registry, main_thread_task_runner_); 182 registry, main_thread_task_runner_);
173 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 183 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
174 registry, main_thread_task_runner_); 184 registry, main_thread_task_runner_);
175 185
176 // In classic ash, the browser process provides ash services to itself. 186 // In classic ash, the browser process provides ash services to itself.
177 if (!chrome::IsRunningInMash()) { 187 if (!chrome::IsRunningInMash()) {
178 ash::mojo_interface_factory::RegisterInterfaces(registry, 188 ash::mojo_interface_factory::RegisterInterfaces(registry,
179 main_thread_task_runner_); 189 main_thread_task_runner_);
180 } 190 }
181 191
182 return true; 192 return true;
183 } 193 }
184 194
185 } // namespace chromeos 195 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_manifest_overlay.json ('k') | chrome/browser/ui/ash/system_tray_delegate_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698