Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1383)

Unified Diff: mojo/services/view_manager/view_manager_service_impl.cc

Issue 489493004: Update view manager to support content handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: png viewer works sorta Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 1ba2d4aa4a753873b9d6ba5c3f61b08066a59e6e..3fc7048b77adff8e45cf5a5c51a62c947041d573 100644
--- a/mojo/services/view_manager/view_manager_service_impl.cc
+++ b/mojo/services/view_manager/view_manager_service_impl.cc
@@ -493,33 +493,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,

Powered by Google App Engine
This is Rietveld 408576698