OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/view_manager/root_node_manager.h" | 5 #include "mojo/services/view_manager/root_node_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "mojo/public/cpp/application/application_connection.h" | 8 #include "mojo/public/cpp/application/application_connection.h" |
9 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" | 9 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h" |
10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" | 10 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 connection_id_(connection->id()), | 26 connection_id_(connection->id()), |
27 change_type_(change_type), | 27 change_type_(change_type), |
28 is_delete_node_(is_delete_node) { | 28 is_delete_node_(is_delete_node) { |
29 root_->PrepareForChange(this); | 29 root_->PrepareForChange(this); |
30 } | 30 } |
31 | 31 |
32 RootNodeManager::ScopedChange::~ScopedChange() { | 32 RootNodeManager::ScopedChange::~ScopedChange() { |
33 root_->FinishChange(); | 33 root_->FinishChange(); |
34 } | 34 } |
35 | 35 |
| 36 void RootNodeManager::ScopedChange::SendServerChangeIdAdvanced() { |
| 37 root_->SendServerChangeIdAdvanced(); |
| 38 } |
| 39 |
36 RootNodeManager::Context::Context() { | 40 RootNodeManager::Context::Context() { |
37 // Pass in false as native viewport creates the PlatformEventSource. | 41 // Pass in false as native viewport creates the PlatformEventSource. |
38 aura::Env::CreateInstance(false); | 42 aura::Env::CreateInstance(false); |
39 } | 43 } |
40 | 44 |
41 RootNodeManager::Context::~Context() { | 45 RootNodeManager::Context::~Context() { |
42 aura::Env::DeleteInstance(); | 46 aura::Env::DeleteInstance(); |
43 } | 47 } |
44 | 48 |
45 RootNodeManager::RootNodeManager( | 49 RootNodeManager::RootNodeManager( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 ConnectionSpecificId creator_id, | 138 ConnectionSpecificId creator_id, |
135 const std::string& url) const { | 139 const std::string& url) const { |
136 for (ConnectionMap::const_iterator i = connection_map_.begin(); | 140 for (ConnectionMap::const_iterator i = connection_map_.begin(); |
137 i != connection_map_.end(); ++i) { | 141 i != connection_map_.end(); ++i) { |
138 if (i->second->creator_id() == creator_id && i->second->url() == url) | 142 if (i->second->creator_id() == creator_id && i->second->url() == url) |
139 return i->second; | 143 return i->second; |
140 } | 144 } |
141 return NULL; | 145 return NULL; |
142 } | 146 } |
143 | 147 |
| 148 ViewManagerServiceImpl* RootNodeManager::GetConnectionWithRoot( |
| 149 const NodeId& id) { |
| 150 for (ConnectionMap::const_iterator i = connection_map_.begin(); |
| 151 i != connection_map_.end(); ++i) { |
| 152 if (i->second->HasRoot(id)) |
| 153 return i->second; |
| 154 } |
| 155 return NULL; |
| 156 } |
| 157 |
144 void RootNodeManager::DispatchViewInputEventToWindowManager( | 158 void RootNodeManager::DispatchViewInputEventToWindowManager( |
145 const View* view, | 159 const View* view, |
146 const ui::Event* event) { | 160 const ui::Event* event) { |
147 // Input events are forwarded to the WindowManager. The WindowManager | 161 // Input events are forwarded to the WindowManager. The WindowManager |
148 // eventually calls back to us with DispatchOnViewInputEvent(). | 162 // eventually calls back to us with DispatchOnViewInputEvent(). |
149 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection); | 163 ViewManagerServiceImpl* connection = GetConnection(kWindowManagerConnection); |
150 if (!connection) | 164 if (!connection) |
151 return; | 165 return; |
152 connection->client()->DispatchOnViewInputEvent( | 166 connection->client()->DispatchOnViewInputEvent( |
153 ViewIdToTransportId(view->id()), | 167 ViewIdToTransportId(view->id()), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } | 243 } |
230 | 244 |
231 void RootNodeManager::FinishChange() { | 245 void RootNodeManager::FinishChange() { |
232 // PrepareForChange/FinishChange should be balanced. | 246 // PrepareForChange/FinishChange should be balanced. |
233 CHECK(current_change_); | 247 CHECK(current_change_); |
234 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) | 248 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) |
235 next_server_change_id_++; | 249 next_server_change_id_++; |
236 current_change_ = NULL; | 250 current_change_ = NULL; |
237 } | 251 } |
238 | 252 |
| 253 void RootNodeManager::SendServerChangeIdAdvanced() { |
| 254 CHECK(current_change_); |
| 255 for (ConnectionMap::iterator i = connection_map_.begin(); |
| 256 i != connection_map_.end(); ++i) { |
| 257 if (!DidConnectionMessageClient(i->first)) |
| 258 i->second->client()->OnServerChangeIdAdvanced(next_server_change_id_ + 1); |
| 259 } |
| 260 } |
| 261 |
239 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( | 262 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( |
240 const ConnectionSpecificId creator_id, | 263 const ConnectionSpecificId creator_id, |
241 const String& url, | 264 const String& url, |
242 const NodeId& root_id) { | 265 const NodeId& root_id) { |
243 MessagePipe pipe; | 266 MessagePipe pipe; |
244 | 267 |
245 ServiceProvider* service_provider = | 268 ServiceProvider* service_provider = |
246 app_connection_->ConnectToApplication(url)->GetServiceProvider(); | 269 app_connection_->ConnectToApplication(url)->GetServiceProvider(); |
247 service_provider->ConnectToService( | 270 service_provider->ConnectToService( |
248 ViewManagerServiceImpl::Client::Name_, | 271 ViewManagerServiceImpl::Client::Name_, |
249 pipe.handle1.Pass()); | 272 pipe.handle1.Pass()); |
250 | 273 |
251 std::string creator_url; | 274 std::string creator_url; |
252 ConnectionMap::const_iterator it = connection_map_.find(creator_id); | 275 ConnectionMap::const_iterator it = connection_map_.find(creator_id); |
253 if (it != connection_map_.end()) | 276 if (it != connection_map_.end()) |
254 creator_url = it->second->url(); | 277 creator_url = it->second->url(); |
255 | 278 |
256 ViewManagerServiceImpl* connection = | 279 ViewManagerServiceImpl* connection = |
257 new ViewManagerServiceImpl(this, | 280 new ViewManagerServiceImpl(this, |
258 creator_id, | 281 creator_id, |
259 creator_url, | 282 creator_url, |
260 url.To<std::string>(), | 283 url.To<std::string>(), |
261 root_id); | 284 root_id); |
262 BindToPipe(connection, pipe.handle0.Pass()); | 285 BindToPipe(connection, pipe.handle0.Pass()); |
263 connections_created_by_connect_.insert(connection); | 286 connections_created_by_connect_.insert(connection); |
| 287 OnConnectionMessagedClient(connection->id()); |
264 return connection; | 288 return connection; |
265 } | 289 } |
266 | 290 |
267 void RootNodeManager::OnNodeDestroyed(const Node* node) { | 291 void RootNodeManager::OnNodeDestroyed(const Node* node) { |
268 ProcessNodeDeleted(node->id()); | 292 ProcessNodeDeleted(node->id()); |
269 } | 293 } |
270 | 294 |
271 void RootNodeManager::OnNodeHierarchyChanged(const Node* node, | 295 void RootNodeManager::OnNodeHierarchyChanged(const Node* node, |
272 const Node* new_parent, | 296 const Node* new_parent, |
273 const Node* old_parent) { | 297 const Node* old_parent) { |
(...skipping 14 matching lines...) Expand all Loading... |
288 } | 312 } |
289 | 313 |
290 void RootNodeManager::OnViewInputEvent(const View* view, | 314 void RootNodeManager::OnViewInputEvent(const View* view, |
291 const ui::Event* event) { | 315 const ui::Event* event) { |
292 DispatchViewInputEventToWindowManager(view, event); | 316 DispatchViewInputEventToWindowManager(view, event); |
293 } | 317 } |
294 | 318 |
295 } // namespace service | 319 } // namespace service |
296 } // namespace view_manager | 320 } // namespace view_manager |
297 } // namespace mojo | 321 } // namespace mojo |
OLD | NEW |