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

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

Issue 2549903002: mash: Reverse the responsibilities of the NewWindowClient. (Closed)
Patch Set: Make StickyKeysBrowserTest how it was before last patch + RunAllPendingInMessageLoop. 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"
12 #include "ash/public/interfaces/shutdown.mojom.h" 11 #include "ash/public/interfaces/shutdown.mojom.h"
13 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
14 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
17 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 17 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
19 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/profiles/profile_manager.h" 19 #include "chrome/browser/profiles/profile_manager.h"
21 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h" 20 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"
22 #include "chrome/browser/ui/ash/ash_util.h" 21 #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/keyboard_ui_service.h" 22 #include "chrome/browser/ui/ash/keyboard_ui_service.h"
25 #include "chrome/browser/ui/ash/volume_controller_chromeos.h" 23 #include "chrome/browser/ui/ash/volume_controller_chromeos.h"
26 #include "chrome/browser/ui/browser_commands.h" 24 #include "chrome/browser/ui/browser_commands.h"
27 #include "chrome/browser/ui/browser_finder.h" 25 #include "chrome/browser/ui/browser_finder.h"
28 #include "content/public/common/service_manager_connection.h" 26 #include "content/public/common/service_manager_connection.h"
29 #include "mash/public/interfaces/launchable.mojom.h" 27 #include "mash/public/interfaces/launchable.mojom.h"
30 #include "mojo/public/cpp/bindings/binding_set.h" 28 #include "mojo/public/cpp/bindings/binding_set.h"
31 #include "services/service_manager/public/cpp/connection.h" 29 #include "services/service_manager/public/cpp/connection.h"
32 #include "services/service_manager/public/cpp/interface_registry.h" 30 #include "services/service_manager/public/cpp/interface_registry.h"
33 #include "ui/app_list/presenter/app_list_presenter.mojom.h" 31 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(), 108 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(),
111 std::move(request)); 109 std::move(request));
112 } 110 }
113 111
114 void BindRequest(mash::mojom::LaunchableRequest request) { 112 void BindRequest(mash::mojom::LaunchableRequest request) {
115 if (!launchable_) 113 if (!launchable_)
116 launchable_ = base::MakeUnique<ChromeLaunchable>(); 114 launchable_ = base::MakeUnique<ChromeLaunchable>();
117 launchable_->ProcessRequest(std::move(request)); 115 launchable_->ProcessRequest(std::move(request));
118 } 116 }
119 117
120 void BindRequest(ash::mojom::NewWindowClientRequest request) {
121 if (!new_window_client_)
122 new_window_client_.reset(new ChromeNewWindowClient);
123 new_window_client_bindings_.AddBinding(new_window_client_.get(),
124 std::move(request));
125 }
126
127 void BindRequest(ash::mojom::WallpaperManagerRequest request) { 118 void BindRequest(ash::mojom::WallpaperManagerRequest request) {
128 WallpaperManager::Get()->BindRequest(std::move(request)); 119 WallpaperManager::Get()->BindRequest(std::move(request));
129 } 120 }
130 121
131 void BindRequest(ash::mojom::VolumeControllerRequest request) { 122 void BindRequest(ash::mojom::VolumeControllerRequest request) {
132 if (!volume_controller_) 123 if (!volume_controller_)
133 volume_controller_ = base::MakeUnique<VolumeController>(); 124 volume_controller_ = base::MakeUnique<VolumeController>();
134 volume_controller_->BindRequest(std::move(request)); 125 volume_controller_->BindRequest(std::move(request));
135 } 126 }
136 127
137 void BindRequest(app_list::mojom::AppListPresenterRequest request) { 128 void BindRequest(app_list::mojom::AppListPresenterRequest request) {
138 if (!app_list_presenter_service_) 129 if (!app_list_presenter_service_)
139 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>(); 130 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>();
140 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(), 131 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
141 std::move(request)); 132 std::move(request));
142 } 133 }
143 134
144 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 135 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
145 136
146 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 137 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
147 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 138 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
148 std::unique_ptr<ChromeLaunchable> launchable_; 139 std::unique_ptr<ChromeLaunchable> launchable_;
149 std::unique_ptr<ChromeNewWindowClient> new_window_client_;
150 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_;
151 std::unique_ptr<VolumeController> volume_controller_; 140 std::unique_ptr<VolumeController> volume_controller_;
152 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 141 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
153 mojo::BindingSet<app_list::mojom::AppListPresenter> 142 mojo::BindingSet<app_list::mojom::AppListPresenter>
154 app_list_presenter_bindings_; 143 app_list_presenter_bindings_;
155 144
156 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 145 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
157 }; 146 };
158 147
159 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 148 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
160 LAZY_INSTANCE_INITIALIZER; 149 LAZY_INSTANCE_INITIALIZER;
161 150
162 } // namespace 151 } // namespace
163 152
164 ChromeInterfaceFactory::ChromeInterfaceFactory() 153 ChromeInterfaceFactory::ChromeInterfaceFactory()
165 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 154 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
166 155
167 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 156 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
168 157
169 bool ChromeInterfaceFactory::OnConnect( 158 bool ChromeInterfaceFactory::OnConnect(
170 const service_manager::Identity& remote_identity, 159 const service_manager::Identity& remote_identity,
171 service_manager::InterfaceRegistry* registry, 160 service_manager::InterfaceRegistry* registry,
172 service_manager::Connector* connector) { 161 service_manager::Connector* connector) {
173 // TODO(jamescook): Only register the interfaces needed for a particular 162 // TODO(jamescook): Only register the interfaces needed for a particular
174 // |remote_identity|. For example, a connection from service:ash needs these, 163 // |remote_identity|. For example, a connection from service:ash needs these,
175 // but a connection from service:content_gpu does not. 164 // but a connection from service:content_gpu does not.
176 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 165 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
177 main_thread_task_runner_); 166 main_thread_task_runner_);
178 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 167 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
179 main_thread_task_runner_); 168 main_thread_task_runner_);
180 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>(
181 registry, main_thread_task_runner_);
182 FactoryImpl::AddFactory<ash::mojom::VolumeController>( 169 FactoryImpl::AddFactory<ash::mojom::VolumeController>(
183 registry, main_thread_task_runner_); 170 registry, main_thread_task_runner_);
184 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 171 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
185 registry, main_thread_task_runner_); 172 registry, main_thread_task_runner_);
186 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 173 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
187 registry, main_thread_task_runner_); 174 registry, main_thread_task_runner_);
188 175
189 // In classic ash, the browser process provides ash services to itself. 176 // In classic ash, the browser process provides ash services to itself.
190 if (!chrome::IsRunningInMash()) { 177 if (!chrome::IsRunningInMash()) {
191 ash::mojo_interface_factory::RegisterInterfaces(registry, 178 ash::mojo_interface_factory::RegisterInterfaces(registry,
192 main_thread_task_runner_); 179 main_thread_task_runner_);
193 } 180 }
194 181
195 return true; 182 return true;
196 } 183 }
197 184
198 } // namespace chromeos 185 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698