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

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

Issue 2549903002: mash: Reverse the responsibilities of the NewWindowClient. (Closed)
Patch Set: jamescook comments 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/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
26 #include "chrome/browser/ui/browser_finder.h" 24 #include "chrome/browser/ui/browser_finder.h"
27 #include "content/public/common/service_manager_connection.h" 25 #include "content/public/common/service_manager_connection.h"
28 #include "mash/public/interfaces/launchable.mojom.h" 26 #include "mash/public/interfaces/launchable.mojom.h"
29 #include "mojo/public/cpp/bindings/binding_set.h" 27 #include "mojo/public/cpp/bindings/binding_set.h"
30 #include "services/service_manager/public/cpp/connection.h" 28 #include "services/service_manager/public/cpp/connection.h"
31 #include "services/service_manager/public/cpp/interface_registry.h" 29 #include "services/service_manager/public/cpp/interface_registry.h"
32 #include "ui/app_list/presenter/app_list_presenter.mojom.h" 30 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
33 #include "ui/keyboard/keyboard.mojom.h" 31 #include "ui/keyboard/keyboard.mojom.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(), 107 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(),
110 std::move(request)); 108 std::move(request));
111 } 109 }
112 110
113 void BindRequest(mash::mojom::LaunchableRequest request) { 111 void BindRequest(mash::mojom::LaunchableRequest request) {
114 if (!launchable_) 112 if (!launchable_)
115 launchable_ = base::MakeUnique<ChromeLaunchable>(); 113 launchable_ = base::MakeUnique<ChromeLaunchable>();
116 launchable_->ProcessRequest(std::move(request)); 114 launchable_->ProcessRequest(std::move(request));
117 } 115 }
118 116
119 void BindRequest(ash::mojom::NewWindowClientRequest request) {
120 if (!new_window_client_)
121 new_window_client_.reset(new ChromeNewWindowClient);
122 new_window_client_bindings_.AddBinding(new_window_client_.get(),
123 std::move(request));
124 }
125
126 void BindRequest(ash::mojom::WallpaperManagerRequest request) { 117 void BindRequest(ash::mojom::WallpaperManagerRequest request) {
127 WallpaperManager::Get()->BindRequest(std::move(request)); 118 WallpaperManager::Get()->BindRequest(std::move(request));
128 } 119 }
129 120
130 void BindRequest(app_list::mojom::AppListPresenterRequest request) { 121 void BindRequest(app_list::mojom::AppListPresenterRequest request) {
131 if (!app_list_presenter_service_) 122 if (!app_list_presenter_service_)
132 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>(); 123 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>();
133 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(), 124 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
134 std::move(request)); 125 std::move(request));
135 } 126 }
136 127
137 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 128 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
138 129
139 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 130 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
140 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 131 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
141 std::unique_ptr<ChromeLaunchable> launchable_; 132 std::unique_ptr<ChromeLaunchable> launchable_;
142 std::unique_ptr<ChromeNewWindowClient> new_window_client_;
143 mojo::BindingSet<ash::mojom::NewWindowClient> new_window_client_bindings_;
144 std::unique_ptr<AppListPresenterService> app_list_presenter_service_; 133 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
145 mojo::BindingSet<app_list::mojom::AppListPresenter> 134 mojo::BindingSet<app_list::mojom::AppListPresenter>
146 app_list_presenter_bindings_; 135 app_list_presenter_bindings_;
147 136
148 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 137 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
149 }; 138 };
150 139
151 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 140 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
152 LAZY_INSTANCE_INITIALIZER; 141 LAZY_INSTANCE_INITIALIZER;
153 142
154 } // namespace 143 } // namespace
155 144
156 ChromeInterfaceFactory::ChromeInterfaceFactory() 145 ChromeInterfaceFactory::ChromeInterfaceFactory()
157 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 146 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
158 147
159 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 148 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
160 149
161 bool ChromeInterfaceFactory::OnConnect( 150 bool ChromeInterfaceFactory::OnConnect(
162 const service_manager::Identity& remote_identity, 151 const service_manager::Identity& remote_identity,
163 service_manager::InterfaceRegistry* registry, 152 service_manager::InterfaceRegistry* registry,
164 service_manager::Connector* connector) { 153 service_manager::Connector* connector) {
165 // TODO(jamescook): Only register the interfaces needed for a particular 154 // TODO(jamescook): Only register the interfaces needed for a particular
166 // |remote_identity|. For example, a connection from service:ash needs these, 155 // |remote_identity|. For example, a connection from service:ash needs these,
167 // but a connection from service:content_gpu does not. 156 // but a connection from service:content_gpu does not.
168 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 157 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
169 main_thread_task_runner_); 158 main_thread_task_runner_);
170 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 159 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
171 main_thread_task_runner_); 160 main_thread_task_runner_);
172 FactoryImpl::AddFactory<ash::mojom::NewWindowClient>(
173 registry, main_thread_task_runner_);
174 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( 161 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>(
175 registry, main_thread_task_runner_); 162 registry, main_thread_task_runner_);
176 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( 163 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
177 registry, main_thread_task_runner_); 164 registry, main_thread_task_runner_);
178 165
179 // In classic ash, the browser process provides ash services to itself. 166 // In classic ash, the browser process provides ash services to itself.
180 if (!chrome::IsRunningInMash()) { 167 if (!chrome::IsRunningInMash()) {
181 ash::mojo_interface_factory::RegisterInterfaces(registry, 168 ash::mojo_interface_factory::RegisterInterfaces(registry,
182 main_thread_task_runner_); 169 main_thread_task_runner_);
183 } 170 }
184 171
185 return true; 172 return true;
186 } 173 }
187 174
188 } // namespace chromeos 175 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility/sticky_keys_browsertest.cc ('k') | chrome/browser/ui/ash/chrome_new_window_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698