| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ash/mus/window_manager_application.h" | 5 #include "ash/mus/window_manager_application.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/mojo_interface_factory.h" | 10 #include "ash/common/mojo_interface_factory.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/mus/accelerators/accelerator_registrar_impl.h" | 12 #include "ash/mus/accelerators/accelerator_registrar_impl.h" |
| 13 #include "ash/mus/native_widget_factory_mus.h" | 13 #include "ash/mus/native_widget_factory_mus.h" |
| 14 #include "ash/mus/wallpaper_delegate_mus.h" | |
| 15 #include "ash/mus/window_manager.h" | 14 #include "ash/mus/window_manager.h" |
| 16 #include "base/bind.h" | 15 #include "base/bind.h" |
| 17 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 18 #include "services/shell/public/cpp/connection.h" | 17 #include "services/shell/public/cpp/connection.h" |
| 19 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
| 20 #include "services/tracing/public/cpp/provider.h" | 19 #include "services/tracing/public/cpp/provider.h" |
| 21 #include "services/ui/common/event_matcher_util.h" | 20 #include "services/ui/common/event_matcher_util.h" |
| 22 #include "services/ui/public/cpp/gpu_service.h" | 21 #include "services/ui/public/cpp/gpu_service.h" |
| 23 #include "services/ui/public/cpp/window.h" | 22 #include "services/ui/public/cpp/window.h" |
| 24 #include "services/ui/public/cpp/window_tree_client.h" | 23 #include "services/ui/public/cpp/window_tree_client.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); | 175 kMaxNumberThreads, kThreadNamePrefix, base::TaskPriority::USER_VISIBLE); |
| 177 InitWindowManager(std::move(window_tree_client), blocking_pool_); | 176 InitWindowManager(std::move(window_tree_client), blocking_pool_); |
| 178 } | 177 } |
| 179 | 178 |
| 180 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity, | 179 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity, |
| 181 shell::InterfaceRegistry* registry) { | 180 shell::InterfaceRegistry* registry) { |
| 182 // Register services used in both classic ash and mash. | 181 // Register services used in both classic ash and mash. |
| 183 mojo_interface_factory::RegisterInterfaces( | 182 mojo_interface_factory::RegisterInterfaces( |
| 184 registry, base::ThreadTaskRunnerHandle::Get()); | 183 registry, base::ThreadTaskRunnerHandle::Get()); |
| 185 | 184 |
| 186 registry->AddInterface<mojom::WallpaperController>(this); | |
| 187 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); | 185 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); |
| 188 if (remote_identity.name() == "service:mash_session") { | 186 if (remote_identity.name() == "service:mash_session") { |
| 189 connector()->ConnectToInterface(remote_identity, &session_); | 187 connector()->ConnectToInterface(remote_identity, &session_); |
| 190 session_->AddScreenlockStateListener( | 188 session_->AddScreenlockStateListener( |
| 191 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); | 189 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); |
| 192 } | 190 } |
| 193 return true; | 191 return true; |
| 194 } | 192 } |
| 195 | 193 |
| 196 void WindowManagerApplication::Create( | 194 void WindowManagerApplication::Create( |
| 197 const ::shell::Identity& remote_identity, | |
| 198 mojom::WallpaperControllerRequest request) { | |
| 199 mojom::WallpaperController* wallpaper_controller = | |
| 200 static_cast<WallpaperDelegateMus*>(WmShell::Get()->wallpaper_delegate()); | |
| 201 DCHECK(wallpaper_controller); | |
| 202 wallpaper_controller_bindings_.AddBinding(wallpaper_controller, | |
| 203 std::move(request)); | |
| 204 } | |
| 205 | |
| 206 void WindowManagerApplication::Create( | |
| 207 const shell::Identity& remote_identity, | 195 const shell::Identity& remote_identity, |
| 208 ui::mojom::AcceleratorRegistrarRequest request) { | 196 ui::mojom::AcceleratorRegistrarRequest request) { |
| 209 if (!window_manager_->window_manager_client()) | 197 if (!window_manager_->window_manager_client()) |
| 210 return; // Can happen during shutdown. | 198 return; // Can happen during shutdown. |
| 211 | 199 |
| 212 uint16_t accelerator_namespace_id; | 200 uint16_t accelerator_namespace_id; |
| 213 if (!window_manager_->GetNextAcceleratorNamespaceId( | 201 if (!window_manager_->GetNextAcceleratorNamespaceId( |
| 214 &accelerator_namespace_id)) { | 202 &accelerator_namespace_id)) { |
| 215 DVLOG(1) << "Max number of accelerators registered, ignoring request."; | 203 DVLOG(1) << "Max number of accelerators registered, ignoring request."; |
| 216 // All ids are used. Normally shouldn't happen, so we close the connection. | 204 // All ids are used. Normally shouldn't happen, so we close the connection. |
| 217 return; | 205 return; |
| 218 } | 206 } |
| 219 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 207 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
| 220 window_manager_.get(), accelerator_namespace_id, std::move(request), | 208 window_manager_.get(), accelerator_namespace_id, std::move(request), |
| 221 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 209 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
| 222 base::Unretained(this)))); | 210 base::Unretained(this)))); |
| 223 } | 211 } |
| 224 | 212 |
| 225 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { | 213 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { |
| 226 window_manager_->SetScreenLocked(locked); | 214 window_manager_->SetScreenLocked(locked); |
| 227 } | 215 } |
| 228 | 216 |
| 229 } // namespace mus | 217 } // namespace mus |
| 230 } // namespace ash | 218 } // namespace ash |
| OLD | NEW |