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/wm_shell.h" |
10 #include "ash/mus/accelerators/accelerator_registrar_impl.h" | 11 #include "ash/mus/accelerators/accelerator_registrar_impl.h" |
| 12 #include "ash/mus/shelf_delegate_mus.h" |
11 #include "ash/mus/window_manager.h" | 13 #include "ash/mus/window_manager.h" |
12 #include "base/bind.h" | 14 #include "base/bind.h" |
13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
14 #include "services/shell/public/cpp/connection.h" | 16 #include "services/shell/public/cpp/connection.h" |
15 #include "services/shell/public/cpp/connector.h" | 17 #include "services/shell/public/cpp/connector.h" |
16 #include "services/tracing/public/cpp/provider.h" | 18 #include "services/tracing/public/cpp/provider.h" |
17 #include "services/ui/common/event_matcher_util.h" | 19 #include "services/ui/common/event_matcher_util.h" |
18 #include "services/ui/public/cpp/gpu_service.h" | 20 #include "services/ui/public/cpp/gpu_service.h" |
19 #include "services/ui/public/cpp/window.h" | 21 #include "services/ui/public/cpp/window.h" |
20 #include "services/ui/public/cpp/window_tree_client.h" | 22 #include "services/ui/public/cpp/window_tree_client.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 110 |
109 ui::WindowTreeClient* window_tree_client = new ui::WindowTreeClient( | 111 ui::WindowTreeClient* window_tree_client = new ui::WindowTreeClient( |
110 window_manager_.get(), window_manager_.get(), nullptr); | 112 window_manager_.get(), window_manager_.get(), nullptr); |
111 window_tree_client->ConnectAsWindowManager(connector()); | 113 window_tree_client->ConnectAsWindowManager(connector()); |
112 | 114 |
113 InitWindowManager(window_tree_client); | 115 InitWindowManager(window_tree_client); |
114 } | 116 } |
115 | 117 |
116 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity, | 118 bool WindowManagerApplication::OnConnect(const shell::Identity& remote_identity, |
117 shell::InterfaceRegistry* registry) { | 119 shell::InterfaceRegistry* registry) { |
| 120 registry->AddInterface<ash::mojom::ShelfController>(this); |
118 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); | 121 registry->AddInterface<ui::mojom::AcceleratorRegistrar>(this); |
119 if (remote_identity.name() == "mojo:mash_session") { | 122 if (remote_identity.name() == "mojo:mash_session") { |
120 connector()->ConnectToInterface(remote_identity, &session_); | 123 connector()->ConnectToInterface(remote_identity, &session_); |
121 session_->AddScreenlockStateListener( | 124 session_->AddScreenlockStateListener( |
122 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); | 125 screenlock_state_listener_binding_.CreateInterfacePtrAndBind()); |
123 } | 126 } |
124 return true; | 127 return true; |
125 } | 128 } |
126 | 129 |
127 void WindowManagerApplication::Create( | 130 void WindowManagerApplication::Create( |
128 const shell::Identity& remote_identity, | 131 const shell::Identity& remote_identity, |
129 mojo::InterfaceRequest<ui::mojom::AcceleratorRegistrar> request) { | 132 ash::mojom::ShelfControllerRequest request) { |
| 133 ash::mojom::ShelfController* shelf_controller = |
| 134 static_cast<ShelfDelegateMus*>(WmShell::Get()->shelf_delegate()); |
| 135 DCHECK(shelf_controller); |
| 136 shelf_controller_bindings_.AddBinding(shelf_controller, std::move(request)); |
| 137 } |
| 138 |
| 139 void WindowManagerApplication::Create( |
| 140 const shell::Identity& remote_identity, |
| 141 ui::mojom::AcceleratorRegistrarRequest request) { |
130 if (!window_manager_->window_manager_client()) | 142 if (!window_manager_->window_manager_client()) |
131 return; // Can happen during shutdown. | 143 return; // Can happen during shutdown. |
132 | 144 |
133 uint16_t accelerator_namespace_id; | 145 uint16_t accelerator_namespace_id; |
134 if (!window_manager_->GetNextAcceleratorNamespaceId( | 146 if (!window_manager_->GetNextAcceleratorNamespaceId( |
135 &accelerator_namespace_id)) { | 147 &accelerator_namespace_id)) { |
136 DVLOG(1) << "Max number of accelerators registered, ignoring request."; | 148 DVLOG(1) << "Max number of accelerators registered, ignoring request."; |
137 // All ids are used. Normally shouldn't happen, so we close the connection. | 149 // All ids are used. Normally shouldn't happen, so we close the connection. |
138 return; | 150 return; |
139 } | 151 } |
140 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( | 152 accelerator_registrars_.insert(new AcceleratorRegistrarImpl( |
141 window_manager_.get(), accelerator_namespace_id, std::move(request), | 153 window_manager_.get(), accelerator_namespace_id, std::move(request), |
142 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, | 154 base::Bind(&WindowManagerApplication::OnAcceleratorRegistrarDestroyed, |
143 base::Unretained(this)))); | 155 base::Unretained(this)))); |
144 } | 156 } |
145 | 157 |
146 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { | 158 void WindowManagerApplication::ScreenlockStateChanged(bool locked) { |
147 window_manager_->SetScreenLocked(locked); | 159 window_manager_->SetScreenLocked(locked); |
148 } | 160 } |
149 | 161 |
150 } // namespace mus | 162 } // namespace mus |
151 } // namespace ash | 163 } // namespace ash |
OLD | NEW |