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

Side by Side 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: blah to the blizzah Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/view_manager_service_impl.h" 5 #include "mojo/services/view_manager/view_manager_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" 8 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h"
9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h" 9 #include "mojo/services/public/cpp/input_events/input_events_type_converters.h"
10 #include "mojo/services/view_manager/default_access_policy.h" 10 #include "mojo/services/view_manager/default_access_policy.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 const Callback<void(bool)>& callback) { 457 const Callback<void(bool)>& callback) {
458 InterfaceRequest<ServiceProvider> spir; 458 InterfaceRequest<ServiceProvider> spir;
459 spir.Bind(service_provider.PassMessagePipe()); 459 spir.Bind(service_provider.PassMessagePipe());
460 460
461 if (NodeIdFromTransportId(transport_view_id) == InvalidNodeId()) { 461 if (NodeIdFromTransportId(transport_view_id) == InvalidNodeId()) {
462 root_node_manager_->EmbedRoot(url, spir.Pass()); 462 root_node_manager_->EmbedRoot(url, spir.Pass());
463 callback.Run(true); 463 callback.Run(true);
464 return; 464 return;
465 } 465 }
466 const Node* node = GetNode(NodeIdFromTransportId(transport_view_id)); 466 const Node* node = GetNode(NodeIdFromTransportId(transport_view_id));
467 bool success = node && access_policy_->CanEmbed(node); 467 if (!node && access_policy_->CanEmbed(node)) {
468 if (success) { 468 callback.Run(false);
469 // Only allow a node to be the root for one connection. 469 return;
470 const NodeId node_id(NodeIdFromTransportId(transport_view_id));
471 ViewManagerServiceImpl* connection_by_url =
472 root_node_manager_->GetConnectionByCreator(id_, url.To<std::string>());
473 ViewManagerServiceImpl* connection_with_node_as_root =
474 root_node_manager_->GetConnectionWithRoot(node_id);
475 if ((connection_by_url != connection_with_node_as_root ||
476 (!connection_by_url && !connection_with_node_as_root)) &&
477 (!connection_by_url || !connection_by_url->HasRoot(node_id))) {
478 RootNodeManager::ScopedChange change(this, root_node_manager_, true);
479 RemoveChildrenAsPartOfEmbed(node_id);
480 // Never message the originating connection.
481 root_node_manager_->OnConnectionMessagedClient(id_);
482 if (connection_with_node_as_root)
483 connection_with_node_as_root->RemoveRoot(node_id);
484 if (connection_by_url) {
485 connection_by_url->AddRoot(node_id, spir.Pass());
486 } else {
487 root_node_manager_->Embed(id_, url, transport_view_id, spir.Pass());
488 }
489 } else {
490 success = false;
491 }
492 } 470 }
493 callback.Run(success); 471
472 // Only allow a node to be the root for one connection.
473 const NodeId node_id(NodeIdFromTransportId(transport_view_id));
474 ViewManagerServiceImpl* existing_owner =
475 root_node_manager_->GetConnectionWithRoot(node_id);
476
477 RootNodeManager::ScopedChange change(this, root_node_manager_, true);
478 if (existing_owner) {
479 RemoveChildrenAsPartOfEmbed(node_id);
480 // Never message the originating connection.
481 root_node_manager_->OnConnectionMessagedClient(id_);
482 existing_owner->RemoveRoot(node_id);
483 }
484 root_node_manager_->Embed(id_, url, transport_view_id, spir.Pass());
485 callback.Run(true);
494 } 486 }
495 487
496 void ViewManagerServiceImpl::DispatchOnViewInputEvent(Id transport_view_id, 488 void ViewManagerServiceImpl::DispatchOnViewInputEvent(Id transport_view_id,
497 EventPtr event) { 489 EventPtr event) {
498 // We only allow the WM to dispatch events. At some point this function will 490 // We only allow the WM to dispatch events. At some point this function will
499 // move to a separate interface and the check can go away. 491 // move to a separate interface and the check can go away.
500 if (id_ != kWindowManagerConnection) 492 if (id_ != kWindowManagerConnection)
501 return; 493 return;
502 494
503 const NodeId node_id(NodeIdFromTransportId(transport_view_id)); 495 const NodeId node_id(NodeIdFromTransportId(transport_view_id));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 531
540 bool ViewManagerServiceImpl::IsNodeRootOfAnotherConnectionForAccessPolicy( 532 bool ViewManagerServiceImpl::IsNodeRootOfAnotherConnectionForAccessPolicy(
541 const Node* node) const { 533 const Node* node) const {
542 ViewManagerServiceImpl* connection = 534 ViewManagerServiceImpl* connection =
543 root_node_manager_->GetConnectionWithRoot(node->id()); 535 root_node_manager_->GetConnectionWithRoot(node->id());
544 return connection && connection != this; 536 return connection && connection != this;
545 } 537 }
546 538
547 } // namespace service 539 } // namespace service
548 } // namespace mojo 540 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/view_manager/root_node_manager.cc ('k') | mojo/services/view_manager/view_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698