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