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/sysui/public/interfaces/wallpaper.mojom.h" | 9 #include "ash/sysui/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/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
21 #include "content/public/common/mojo_shell_connection.h" | 21 #include "content/public/common/mojo_shell_connection.h" |
22 #include "mash/public/interfaces/launchable.mojom.h" | 22 #include "mash/public/interfaces/launchable.mojom.h" |
23 #include "mojo/public/cpp/bindings/binding_set.h" | 23 #include "mojo/public/cpp/bindings/binding_set.h" |
24 #include "services/shell/public/cpp/connection.h" | 24 #include "services/shell/public/cpp/connection.h" |
| 25 #include "services/shell/public/cpp/interface_registry.h" |
25 #include "ui/app_list/presenter/app_list_presenter.mojom.h" | 26 #include "ui/app_list/presenter/app_list_presenter.mojom.h" |
26 #include "ui/keyboard/keyboard.mojom.h" | 27 #include "ui/keyboard/keyboard.mojom.h" |
27 | 28 |
28 namespace chromeos { | 29 namespace chromeos { |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 class ChromeLaunchable : public mash::mojom::Launchable { | 33 class ChromeLaunchable : public mash::mojom::Launchable { |
33 public: | 34 public: |
34 ChromeLaunchable() {} | 35 ChromeLaunchable() {} |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 DISALLOW_COPY_AND_ASSIGN(ChromeLaunchable); | 74 DISALLOW_COPY_AND_ASSIGN(ChromeLaunchable); |
74 }; | 75 }; |
75 | 76 |
76 class FactoryImpl { | 77 class FactoryImpl { |
77 public: | 78 public: |
78 FactoryImpl() {} | 79 FactoryImpl() {} |
79 ~FactoryImpl() {} | 80 ~FactoryImpl() {} |
80 | 81 |
81 template <typename Interface> | 82 template <typename Interface> |
82 static void AddFactory( | 83 static void AddFactory( |
83 shell::Connection* connection, | 84 shell::InterfaceRegistry* registry, |
84 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 85 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
85 connection->AddInterface<Interface>( | 86 registry->AddInterface<Interface>( |
86 base::Bind(&FactoryImpl::CallMainThreadFactory<Interface>), | 87 base::Bind(&FactoryImpl::CallMainThreadFactory<Interface>), |
87 task_runner); | 88 task_runner); |
88 } | 89 } |
89 | 90 |
90 private: | 91 private: |
91 static FactoryImpl* Get() { | 92 static FactoryImpl* Get() { |
92 if (!factory_.Get()) | 93 if (!factory_.Get()) |
93 factory_.Get().reset(new FactoryImpl); | 94 factory_.Get().reset(new FactoryImpl); |
94 return factory_.Get().get(); | 95 return factory_.Get().get(); |
95 } | 96 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = | 142 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = |
142 LAZY_INSTANCE_INITIALIZER; | 143 LAZY_INSTANCE_INITIALIZER; |
143 | 144 |
144 } // namespace | 145 } // namespace |
145 | 146 |
146 ChromeInterfaceFactory::ChromeInterfaceFactory() | 147 ChromeInterfaceFactory::ChromeInterfaceFactory() |
147 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} | 148 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} |
148 | 149 |
149 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} | 150 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} |
150 | 151 |
151 bool ChromeInterfaceFactory::OnConnect(shell::Connection* connection, | 152 bool ChromeInterfaceFactory::OnConnect(const shell::Identity& remote_identity, |
| 153 shell::InterfaceRegistry* registry, |
152 shell::Connector* connector) { | 154 shell::Connector* connector) { |
153 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>( | 155 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, |
154 connection, main_thread_task_runner_); | 156 main_thread_task_runner_); |
155 FactoryImpl::AddFactory<mash::mojom::Launchable>( | 157 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, |
156 connection, main_thread_task_runner_); | 158 main_thread_task_runner_); |
157 FactoryImpl::AddFactory<ash::sysui::mojom::WallpaperManager>( | 159 FactoryImpl::AddFactory<ash::sysui::mojom::WallpaperManager>( |
158 connection, main_thread_task_runner_); | 160 registry, main_thread_task_runner_); |
159 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( | 161 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>( |
160 connection, main_thread_task_runner_); | 162 registry, main_thread_task_runner_); |
161 return true; | 163 return true; |
162 } | 164 } |
163 | 165 |
164 } // namespace chromeos | 166 } // namespace chromeos |
OLD | NEW |