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 69495c5f50fe5e7a522768f8852319b71e131469..282cab3a272335d1fa1fc9cf2029192f6365eb36 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 ServerView* view = GetView(ViewIdFromTransportId(transport_view_id)); |
- bool success = view && access_policy_->CanEmbed(view); |
- if (success) { |
- // Only allow a view to be the root for one connection. |
- const ViewId view_id(ViewIdFromTransportId(transport_view_id)); |
- ViewManagerServiceImpl* connection_by_url = |
- connection_manager_->GetConnectionByCreator(id_, url.To<std::string>()); |
- ViewManagerServiceImpl* connection_with_view_as_root = |
- connection_manager_->GetConnectionWithRoot(view_id); |
- if ((connection_by_url != connection_with_view_as_root || |
- (!connection_by_url && !connection_with_view_as_root)) && |
- (!connection_by_url || !connection_by_url->HasRoot(view_id))) { |
- ConnectionManager::ScopedChange change(this, connection_manager_, true); |
- RemoveChildrenAsPartOfEmbed(view_id); |
- // Never message the originating connection. |
- connection_manager_->OnConnectionMessagedClient(id_); |
- if (connection_with_view_as_root) |
- connection_with_view_as_root->RemoveRoot(view_id); |
sky
2014/09/02 15:47:16
You should be able to get rid of AddRoot now.
Also
Aaron Boodman
2014/09/02 19:10:44
Done.
|
- if (connection_by_url) { |
- connection_by_url->AddRoot(view_id, spir.Pass()); |
- } else { |
- connection_manager_->Embed(id_, url, transport_view_id, spir.Pass()); |
- } |
- } else { |
- success = false; |
- } |
+ if (!view && access_policy_->CanEmbed(view)) { |
sky
2014/09/02 15:47:15
Shouldn't this be:
if (!view || !...CanEmbed(view
Aaron Boodman
2014/09/02 19:10:44
Done.
|
+ callback.Run(false); |
+ return; |
} |
- callback.Run(success); |
+ |
+ // Only allow a node to be the root for one connection. |
Ben Goodger (Google)
2014/09/02 20:50:14
I think this is a good simplification. I will pond
|
+ const ViewId view_id(ViewIdFromTransportId(transport_view_id)); |
+ ViewManagerServiceImpl* existing_owner = |
+ connection_manager_->GetConnectionWithRoot(view_id); |
+ |
+ ConnectionManager::ScopedChange change(this, connection_manager_, true); |
+ if (existing_owner) { |
+ RemoveChildrenAsPartOfEmbed(view_id); |
+ // Never message the originating connection. |
+ connection_manager_->OnConnectionMessagedClient(id_); |
+ existing_owner->RemoveRoot(view_id); |
+ } |
+ connection_manager_->Embed(id_, url, transport_view_id, spir.Pass()); |
+ callback.Run(true); |
} |
void ViewManagerServiceImpl::DispatchOnViewInputEvent(Id transport_view_id, |