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