| 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/view_manager_connection.h" | 5 #include "mojo/services/view_manager/view_manager_connection.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "mojo/services/public/cpp/geometry/geometry_type_converters.h" | 9 #include "mojo/services/public/cpp/geometry/geometry_type_converters.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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 | 280 |
| 281 const View* view = GetView(view_id); | 281 const View* view = GetView(view_id); |
| 282 return (view && view_id.connection_id == id_) || view_id == ViewId(); | 282 return (view && view_id.connection_id == id_) || view_id == ViewId(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool ViewManagerConnection::CanGetNodeTree(const Node* node) const { | 285 bool ViewManagerConnection::CanGetNodeTree(const Node* node) const { |
| 286 return node && | 286 return node && |
| 287 (IsNodeDescendantOfRoots(node) || node->id().connection_id == id_); | 287 (IsNodeDescendantOfRoots(node) || node->id().connection_id == id_); |
| 288 } | 288 } |
| 289 | 289 |
| 290 bool ViewManagerConnection::CanConnect( | 290 bool ViewManagerConnection::CanEmbed( |
| 291 const mojo::Array<uint32_t>& node_ids) const { | 291 const mojo::Array<uint32_t>& node_ids) const { |
| 292 for (size_t i = 0; i < node_ids.size(); ++i) { | 292 for (size_t i = 0; i < node_ids.size(); ++i) { |
| 293 const Node* node = GetNode(NodeIdFromTransportId(node_ids[i])); | 293 const Node* node = GetNode(NodeIdFromTransportId(node_ids[i])); |
| 294 if (!node || node->id().connection_id != id_) | 294 if (!node || node->id().connection_id != id_) |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 return node_ids.size() > 0; | 297 return node_ids.size() > 0; |
| 298 } | 298 } |
| 299 | 299 |
| 300 bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source, | 300 bool ViewManagerConnection::DeleteNodeImpl(ViewManagerConnection* source, |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 RootNodeManager::ScopedChange change( | 639 RootNodeManager::ScopedChange change( |
| 640 this, root_node_manager_, | 640 this, root_node_manager_, |
| 641 RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false); | 641 RootNodeManager::CHANGE_TYPE_DONT_ADVANCE_SERVER_CHANGE_ID, false); |
| 642 gfx::Rect old_bounds = node->window()->bounds(); | 642 gfx::Rect old_bounds = node->window()->bounds(); |
| 643 node->window()->SetBounds(bounds.To<gfx::Rect>()); | 643 node->window()->SetBounds(bounds.To<gfx::Rect>()); |
| 644 root_node_manager_->ProcessNodeBoundsChanged( | 644 root_node_manager_->ProcessNodeBoundsChanged( |
| 645 node, old_bounds, bounds.To<gfx::Rect>()); | 645 node, old_bounds, bounds.To<gfx::Rect>()); |
| 646 callback.Run(true); | 646 callback.Run(true); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void ViewManagerConnection::Connect(const String& url, | 649 void ViewManagerConnection::Embed(const String& url, |
| 650 Array<uint32_t> node_ids, | 650 Array<uint32_t> node_ids, |
| 651 const Callback<void(bool)>& callback) { | 651 const Callback<void(bool)>& callback) { |
| 652 bool success = CanConnect(node_ids); | 652 bool success = CanEmbed(node_ids); |
| 653 if (success) { | 653 if (success) { |
| 654 // We may already have this connection, if so reuse it. | 654 // We may already have this connection, if so reuse it. |
| 655 ViewManagerConnection* existing_connection = | 655 ViewManagerConnection* existing_connection = |
| 656 root_node_manager_->GetConnectionByCreator(id_, url.To<std::string>()); | 656 root_node_manager_->GetConnectionByCreator(id_, url.To<std::string>()); |
| 657 if (existing_connection) | 657 if (existing_connection) |
| 658 success = existing_connection->AddRoots(node_ids.storage()); | 658 success = existing_connection->AddRoots(node_ids.storage()); |
| 659 else | 659 else |
| 660 root_node_manager_->Connect(id_, url, node_ids); | 660 root_node_manager_->Embed(id_, url, node_ids); |
| 661 } | 661 } |
| 662 callback.Run(success); | 662 callback.Run(success); |
| 663 } | 663 } |
| 664 | 664 |
| 665 void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node, | 665 void ViewManagerConnection::OnNodeHierarchyChanged(const Node* node, |
| 666 const Node* new_parent, | 666 const Node* new_parent, |
| 667 const Node* old_parent) { | 667 const Node* old_parent) { |
| 668 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); | 668 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); |
| 669 } | 669 } |
| 670 | 670 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 695 | 695 |
| 696 client()->OnViewManagerConnectionEstablished( | 696 client()->OnViewManagerConnectionEstablished( |
| 697 id_, | 697 id_, |
| 698 root_node_manager_->next_server_change_id(), | 698 root_node_manager_->next_server_change_id(), |
| 699 NodesToINodes(to_send)); | 699 NodesToINodes(to_send)); |
| 700 } | 700 } |
| 701 | 701 |
| 702 } // namespace service | 702 } // namespace service |
| 703 } // namespace view_manager | 703 } // namespace view_manager |
| 704 } // namespace mojo | 704 } // namespace mojo |
| OLD | NEW |