| 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/wallpaper.mojom.h" | 10 #include "ash/public/interfaces/wallpaper.mojom.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 DISALLOW_COPY_AND_ASSIGN(ChromeLaunchable); | 77 DISALLOW_COPY_AND_ASSIGN(ChromeLaunchable); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class FactoryImpl { | 80 class FactoryImpl { |
| 81 public: | 81 public: |
| 82 FactoryImpl() {} | 82 FactoryImpl() {} |
| 83 ~FactoryImpl() {} | 83 ~FactoryImpl() {} |
| 84 | 84 |
| 85 template <typename Interface> | 85 template <typename Interface> |
| 86 static void AddFactory( | 86 static void AddFactory( |
| 87 shell::InterfaceRegistry* registry, | 87 service_manager::InterfaceRegistry* registry, |
| 88 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 88 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 89 registry->AddInterface<Interface>( | 89 registry->AddInterface<Interface>( |
| 90 base::Bind(&FactoryImpl::CallMainThreadFactory<Interface>), | 90 base::Bind(&FactoryImpl::CallMainThreadFactory<Interface>), |
| 91 task_runner); | 91 task_runner); |
| 92 } | 92 } |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 static FactoryImpl* Get() { | 95 static FactoryImpl* Get() { |
| 96 if (!factory_.Get()) | 96 if (!factory_.Get()) |
| 97 factory_.Get().reset(new FactoryImpl); | 97 factory_.Get().reset(new FactoryImpl); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = | 151 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = |
| 152 LAZY_INSTANCE_INITIALIZER; | 152 LAZY_INSTANCE_INITIALIZER; |
| 153 | 153 |
| 154 } // namespace | 154 } // namespace |
| 155 | 155 |
| 156 ChromeInterfaceFactory::ChromeInterfaceFactory() | 156 ChromeInterfaceFactory::ChromeInterfaceFactory() |
| 157 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 157 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
| 158 | 158 |
| 159 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} | 159 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} |
| 160 | 160 |
| 161 bool ChromeInterfaceFactory::OnConnect(const shell::Identity& remote_identity, | 161 bool ChromeInterfaceFactory::OnConnect( |
| 162 shell::InterfaceRegistry* registry, | 162 const service_manager::Identity& remote_identity, |
| 163 shell::Connector* connector) { | 163 service_manager::InterfaceRegistry* registry, |
| 164 service_manager::Connector* connector) { |
| 164 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, | 165 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, |
| 165 main_thread_task_runner_); | 166 main_thread_task_runner_); |
| 166 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, | 167 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, |
| 167 main_thread_task_runner_); | 168 main_thread_task_runner_); |
| 168 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>( | 169 FactoryImpl::AddFactory<ash::mojom::SystemTrayClient>( |
| 169 registry, main_thread_task_runner_); | 170 registry, main_thread_task_runner_); |
| 170 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( | 171 FactoryImpl::AddFactory<ash::mojom::WallpaperManager>( |
| 171 registry, main_thread_task_runner_); | 172 registry, main_thread_task_runner_); |
| 172 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( | 173 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( |
| 173 registry, main_thread_task_runner_); | 174 registry, main_thread_task_runner_); |
| 174 | 175 |
| 175 // In classic ash, the browser process provides ash services to itself. | 176 // In classic ash, the browser process provides ash services to itself. |
| 176 if (!chrome::IsRunningInMash()) { | 177 if (!chrome::IsRunningInMash()) { |
| 177 ash::mojo_interface_factory::RegisterInterfaces(registry, | 178 ash::mojo_interface_factory::RegisterInterfaces(registry, |
| 178 main_thread_task_runner_); | 179 main_thread_task_runner_); |
| 179 } | 180 } |
| 180 | 181 |
| 181 return true; | 182 return true; |
| 182 } | 183 } |
| 183 | 184 |
| 184 } // namespace chromeos | 185 } // namespace chromeos |
| OLD | NEW |