| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 85 |
| 86 // Notify remaining connections so that they can cleanup. | 86 // Notify remaining connections so that they can cleanup. |
| 87 for (ConnectionMap::const_iterator i = connection_map_.begin(); | 87 for (ConnectionMap::const_iterator i = connection_map_.begin(); |
| 88 i != connection_map_.end(); ++i) { | 88 i != connection_map_.end(); ++i) { |
| 89 i->second->OnViewManagerServiceImplDestroyed(connection->id()); | 89 i->second->OnViewManagerServiceImplDestroyed(connection->id()); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 void RootNodeManager::EmbedRoot(const std::string& url) { | 93 void RootNodeManager::EmbedRoot(const std::string& url) { |
| 94 CHECK(connection_map_.empty()); | 94 CHECK(connection_map_.empty()); |
| 95 Array<Id> roots(0); | 95 EmbedImpl(kRootConnection, String::From(url), InvalidNodeId()); |
| 96 EmbedImpl(kRootConnection, String::From(url), roots); | |
| 97 } | 96 } |
| 98 | 97 |
| 99 void RootNodeManager::Embed(ConnectionSpecificId creator_id, | 98 void RootNodeManager::Embed(ConnectionSpecificId creator_id, |
| 100 const String& url, | 99 const String& url, |
| 101 const Array<Id>& node_ids) { | 100 Id transport_node_id) { |
| 102 CHECK_GT(node_ids.size(), 0u); | 101 EmbedImpl(creator_id, url, NodeIdFromTransportId(transport_node_id))-> |
| 103 EmbedImpl(creator_id, url, node_ids)->set_delete_on_connection_error(); | 102 set_delete_on_connection_error(); |
| 104 } | 103 } |
| 105 | 104 |
| 106 ViewManagerServiceImpl* RootNodeManager::GetConnection( | 105 ViewManagerServiceImpl* RootNodeManager::GetConnection( |
| 107 ConnectionSpecificId connection_id) { | 106 ConnectionSpecificId connection_id) { |
| 108 ConnectionMap::iterator i = connection_map_.find(connection_id); | 107 ConnectionMap::iterator i = connection_map_.find(connection_id); |
| 109 return i == connection_map_.end() ? NULL : i->second; | 108 return i == connection_map_.end() ? NULL : i->second; |
| 110 } | 109 } |
| 111 | 110 |
| 112 Node* RootNodeManager::GetNode(const NodeId& id) { | 111 Node* RootNodeManager::GetNode(const NodeId& id) { |
| 113 if (id == root_->id()) | 112 if (id == root_->id()) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // PrepareForChange/FinishChange should be balanced. | 232 // PrepareForChange/FinishChange should be balanced. |
| 234 CHECK(current_change_); | 233 CHECK(current_change_); |
| 235 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) | 234 if (current_change_->change_type() == CHANGE_TYPE_ADVANCE_SERVER_CHANGE_ID) |
| 236 next_server_change_id_++; | 235 next_server_change_id_++; |
| 237 current_change_ = NULL; | 236 current_change_ = NULL; |
| 238 } | 237 } |
| 239 | 238 |
| 240 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( | 239 ViewManagerServiceImpl* RootNodeManager::EmbedImpl( |
| 241 const ConnectionSpecificId creator_id, | 240 const ConnectionSpecificId creator_id, |
| 242 const String& url, | 241 const String& url, |
| 243 const Array<Id>& node_ids) { | 242 const NodeId& root_id) { |
| 244 MessagePipe pipe; | 243 MessagePipe pipe; |
| 245 | 244 |
| 246 ServiceProvider* service_provider = | 245 ServiceProvider* service_provider = |
| 247 app_connection_->ConnectToApplication(url)->GetServiceProvider(); | 246 app_connection_->ConnectToApplication(url)->GetServiceProvider(); |
| 248 service_provider->ConnectToService( | 247 service_provider->ConnectToService( |
| 249 ViewManagerServiceImpl::Client::Name_, | 248 ViewManagerServiceImpl::Client::Name_, |
| 250 pipe.handle1.Pass()); | 249 pipe.handle1.Pass()); |
| 251 | 250 |
| 252 std::string creator_url; | 251 std::string creator_url; |
| 253 ConnectionMap::const_iterator it = connection_map_.find(creator_id); | 252 ConnectionMap::const_iterator it = connection_map_.find(creator_id); |
| 254 if (it != connection_map_.end()) | 253 if (it != connection_map_.end()) |
| 255 creator_url = it->second->url(); | 254 creator_url = it->second->url(); |
| 256 | 255 |
| 257 ViewManagerServiceImpl* connection = | 256 ViewManagerServiceImpl* connection = |
| 258 new ViewManagerServiceImpl(this, | 257 new ViewManagerServiceImpl(this, |
| 259 creator_id, | 258 creator_id, |
| 260 creator_url, | 259 creator_url, |
| 261 url.To<std::string>()); | 260 url.To<std::string>(), |
| 262 connection->SetRoots(node_ids); | 261 root_id); |
| 263 BindToPipe(connection, pipe.handle0.Pass()); | 262 BindToPipe(connection, pipe.handle0.Pass()); |
| 264 connections_created_by_connect_.insert(connection); | 263 connections_created_by_connect_.insert(connection); |
| 265 return connection; | 264 return connection; |
| 266 } | 265 } |
| 267 | 266 |
| 268 void RootNodeManager::OnNodeDestroyed(const Node* node) { | 267 void RootNodeManager::OnNodeDestroyed(const Node* node) { |
| 269 ProcessNodeDeleted(node->id()); | 268 ProcessNodeDeleted(node->id()); |
| 270 } | 269 } |
| 271 | 270 |
| 272 void RootNodeManager::OnNodeHierarchyChanged(const Node* node, | 271 void RootNodeManager::OnNodeHierarchyChanged(const Node* node, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 289 } | 288 } |
| 290 | 289 |
| 291 void RootNodeManager::OnViewInputEvent(const View* view, | 290 void RootNodeManager::OnViewInputEvent(const View* view, |
| 292 const ui::Event* event) { | 291 const ui::Event* event) { |
| 293 DispatchViewInputEventToWindowManager(view, event); | 292 DispatchViewInputEventToWindowManager(view, event); |
| 294 } | 293 } |
| 295 | 294 |
| 296 } // namespace service | 295 } // namespace service |
| 297 } // namespace view_manager | 296 } // namespace view_manager |
| 298 } // namespace mojo | 297 } // namespace mojo |
| OLD | NEW |