Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Side by Side Diff: chrome/browser/chromeos/chrome_interface_factory.cc

Issue 2567523002: mash: Have chrome set itself as the app list presenter. (Closed)
Patch Set: Address comments, Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/mojo_interface_factory.h" 10 #include "ash/common/mojo_interface_factory.h"
11 #include "ash/public/interfaces/shutdown.mojom.h" 11 #include "ash/public/interfaces/shutdown.mojom.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/ash/app_list/app_list_presenter_service.h"
20 #include "chrome/browser/ui/ash/ash_util.h" 19 #include "chrome/browser/ui/ash/ash_util.h"
21 #include "chrome/browser/ui/ash/keyboard_ui_service.h" 20 #include "chrome/browser/ui/ash/keyboard_ui_service.h"
22 #include "chrome/browser/ui/browser_commands.h" 21 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
24 #include "content/public/common/service_manager_connection.h" 23 #include "content/public/common/service_manager_connection.h"
25 #include "mash/public/interfaces/launchable.mojom.h" 24 #include "mash/public/interfaces/launchable.mojom.h"
26 #include "mojo/public/cpp/bindings/binding_set.h" 25 #include "mojo/public/cpp/bindings/binding_set.h"
27 #include "services/service_manager/public/cpp/connection.h" 26 #include "services/service_manager/public/cpp/connection.h"
28 #include "services/service_manager/public/cpp/interface_registry.h" 27 #include "services/service_manager/public/cpp/interface_registry.h"
29 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
30 #include "ui/keyboard/keyboard.mojom.h" 28 #include "ui/keyboard/keyboard.mojom.h"
31 29
32 namespace chromeos { 30 namespace chromeos {
33 31
34 namespace { 32 namespace {
35 33
36 class ChromeLaunchable : public mash::mojom::Launchable { 34 class ChromeLaunchable : public mash::mojom::Launchable {
37 public: 35 public:
38 ChromeLaunchable() {} 36 ChromeLaunchable() {}
39 ~ChromeLaunchable() override {} 37 ~ChromeLaunchable() override {}
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(), 104 keyboard_bindings_.AddBinding(keyboard_ui_service_.get(),
107 std::move(request)); 105 std::move(request));
108 } 106 }
109 107
110 void BindRequest(mash::mojom::LaunchableRequest request) { 108 void BindRequest(mash::mojom::LaunchableRequest request) {
111 if (!launchable_) 109 if (!launchable_)
112 launchable_ = base::MakeUnique<ChromeLaunchable>(); 110 launchable_ = base::MakeUnique<ChromeLaunchable>();
113 launchable_->ProcessRequest(std::move(request)); 111 launchable_->ProcessRequest(std::move(request));
114 } 112 }
115 113
116 void BindRequest(app_list::mojom::AppListPresenterRequest request) {
117 if (!app_list_presenter_service_)
118 app_list_presenter_service_ = base::MakeUnique<AppListPresenterService>();
119 app_list_presenter_bindings_.AddBinding(app_list_presenter_service_.get(),
120 std::move(request));
121 }
122
123 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_; 114 static base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky factory_;
124 115
125 std::unique_ptr<KeyboardUIService> keyboard_ui_service_; 116 std::unique_ptr<KeyboardUIService> keyboard_ui_service_;
126 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_; 117 mojo::BindingSet<keyboard::mojom::Keyboard> keyboard_bindings_;
127 std::unique_ptr<ChromeLaunchable> launchable_; 118 std::unique_ptr<ChromeLaunchable> launchable_;
128 std::unique_ptr<AppListPresenterService> app_list_presenter_service_;
129 mojo::BindingSet<app_list::mojom::AppListPresenter>
130 app_list_presenter_bindings_;
131 119
132 DISALLOW_COPY_AND_ASSIGN(FactoryImpl); 120 DISALLOW_COPY_AND_ASSIGN(FactoryImpl);
133 }; 121 };
134 122
135 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ = 123 base::LazyInstance<std::unique_ptr<FactoryImpl>>::Leaky FactoryImpl::factory_ =
136 LAZY_INSTANCE_INITIALIZER; 124 LAZY_INSTANCE_INITIALIZER;
137 125
138 } // namespace 126 } // namespace
139 127
140 ChromeInterfaceFactory::ChromeInterfaceFactory() 128 ChromeInterfaceFactory::ChromeInterfaceFactory()
141 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {} 129 : main_thread_task_runner_(base::ThreadTaskRunnerHandle::Get()) {}
142 130
143 ChromeInterfaceFactory::~ChromeInterfaceFactory() {} 131 ChromeInterfaceFactory::~ChromeInterfaceFactory() {}
144 132
145 bool ChromeInterfaceFactory::OnConnect( 133 bool ChromeInterfaceFactory::OnConnect(
146 const service_manager::Identity& remote_identity, 134 const service_manager::Identity& remote_identity,
147 service_manager::InterfaceRegistry* registry, 135 service_manager::InterfaceRegistry* registry,
148 service_manager::Connector* connector) { 136 service_manager::Connector* connector) {
149 // TODO(jamescook): Only register the interfaces needed for a particular 137 // TODO(jamescook): Only register the interfaces needed for a particular
150 // |remote_identity|. For example, a connection from service:ash needs these, 138 // |remote_identity|. For example, a connection from service:ash needs these,
151 // but a connection from service:content_gpu does not. 139 // but a connection from service:content_gpu does not.
152 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry, 140 FactoryImpl::AddFactory<keyboard::mojom::Keyboard>(registry,
153 main_thread_task_runner_); 141 main_thread_task_runner_);
154 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry, 142 FactoryImpl::AddFactory<mash::mojom::Launchable>(registry,
155 main_thread_task_runner_); 143 main_thread_task_runner_);
156 FactoryImpl::AddFactory<app_list::mojom::AppListPresenter>(
157 registry, main_thread_task_runner_);
158 144
159 // In classic ash, the browser process provides ash services to itself. 145 // In classic ash, the browser process provides ash services to itself.
160 if (!chrome::IsRunningInMash()) { 146 if (!chrome::IsRunningInMash()) {
161 ash::mojo_interface_factory::RegisterInterfaces(registry, 147 ash::mojo_interface_factory::RegisterInterfaces(registry,
162 main_thread_task_runner_); 148 main_thread_task_runner_);
163 } 149 }
164 150
165 return true; 151 return true;
166 } 152 }
167 153
168 } // namespace chromeos 154 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698