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