| Index: mojo/services/view_manager/view_manager_service_impl.cc
|
| diff --git a/mojo/services/view_manager/view_manager_service_impl.cc b/mojo/services/view_manager/view_manager_service_impl.cc
|
| index 2311b74e7f7e78e911e3f4a361f577e5556b8bca..4938cb461210ddd8823dc9486f499bb494d0efe8 100644
|
| --- a/mojo/services/view_manager/view_manager_service_impl.cc
|
| +++ b/mojo/services/view_manager/view_manager_service_impl.cc
|
| @@ -464,33 +464,25 @@ void ViewManagerServiceImpl::Embed(
|
| return;
|
| }
|
| const Node* node = GetNode(NodeIdFromTransportId(transport_view_id));
|
| - bool success = node && access_policy_->CanEmbed(node);
|
| - if (success) {
|
| - // Only allow a node to be the root for one connection.
|
| - const NodeId node_id(NodeIdFromTransportId(transport_view_id));
|
| - ViewManagerServiceImpl* connection_by_url =
|
| - root_node_manager_->GetConnectionByCreator(id_, url.To<std::string>());
|
| - ViewManagerServiceImpl* connection_with_node_as_root =
|
| - root_node_manager_->GetConnectionWithRoot(node_id);
|
| - if ((connection_by_url != connection_with_node_as_root ||
|
| - (!connection_by_url && !connection_with_node_as_root)) &&
|
| - (!connection_by_url || !connection_by_url->HasRoot(node_id))) {
|
| - RootNodeManager::ScopedChange change(this, root_node_manager_, true);
|
| - RemoveChildrenAsPartOfEmbed(node_id);
|
| - // Never message the originating connection.
|
| - root_node_manager_->OnConnectionMessagedClient(id_);
|
| - if (connection_with_node_as_root)
|
| - connection_with_node_as_root->RemoveRoot(node_id);
|
| - if (connection_by_url) {
|
| - connection_by_url->AddRoot(node_id, spir.Pass());
|
| - } else {
|
| - root_node_manager_->Embed(id_, url, transport_view_id, spir.Pass());
|
| - }
|
| - } else {
|
| - success = false;
|
| - }
|
| + if (!node && access_policy_->CanEmbed(node)) {
|
| + callback.Run(false);
|
| + return;
|
| }
|
| - callback.Run(success);
|
| +
|
| + // Only allow a node to be the root for one connection.
|
| + const NodeId node_id(NodeIdFromTransportId(transport_view_id));
|
| + ViewManagerServiceImpl* existing_owner =
|
| + root_node_manager_->GetConnectionWithRoot(node_id);
|
| +
|
| + RootNodeManager::ScopedChange change(this, root_node_manager_, true);
|
| + if (existing_owner) {
|
| + RemoveChildrenAsPartOfEmbed(node_id);
|
| + // Never message the originating connection.
|
| + root_node_manager_->OnConnectionMessagedClient(id_);
|
| + existing_owner->RemoveRoot(node_id);
|
| + }
|
| + root_node_manager_->Embed(id_, url, transport_view_id, spir.Pass());
|
| + callback.Run(true);
|
| }
|
|
|
| void ViewManagerServiceImpl::DispatchOnViewInputEvent(Id transport_view_id,
|
|
|