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/stl_util.h" | 8 #include "base/stl_util.h" |
8 #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" |
9 #include "mojo/services/view_manager/node.h" | 11 #include "mojo/services/view_manager/node.h" |
10 #include "mojo/services/view_manager/root_node_manager.h" | 12 #include "mojo/services/view_manager/root_node_manager.h" |
11 #include "mojo/services/view_manager/view.h" | 13 #include "mojo/services/view_manager/view.h" |
12 #include "third_party/skia/include/core/SkBitmap.h" | 14 #include "third_party/skia/include/core/SkBitmap.h" |
13 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
14 #include "ui/gfx/codec/png_codec.h" | 16 #include "ui/gfx/codec/png_codec.h" |
15 | 17 |
16 namespace mojo { | 18 namespace mojo { |
17 namespace view_manager { | 19 namespace view_manager { |
18 namespace service { | 20 namespace service { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 197 } |
196 } | 198 } |
197 | 199 |
198 void ViewManagerConnection::ProcessViewDeleted(const ViewId& view, | 200 void ViewManagerConnection::ProcessViewDeleted(const ViewId& view, |
199 bool originated_change) { | 201 bool originated_change) { |
200 if (originated_change) | 202 if (originated_change) |
201 return; | 203 return; |
202 client()->OnViewDeleted(ViewIdToTransportId(view)); | 204 client()->OnViewDeleted(ViewIdToTransportId(view)); |
203 } | 205 } |
204 | 206 |
| 207 void ViewManagerConnection::ProcessViewInputEvent(const View* view, |
| 208 const ui::Event* event) { |
| 209 DCHECK_EQ(id_, view->id().connection_id); |
| 210 client()->OnViewInputEvent( |
| 211 ViewIdToTransportId(view->id()), |
| 212 TypeConverter<EventPtr, ui::Event>::ConvertFrom(*event), |
| 213 base::Bind(&base::DoNothing)); |
| 214 } |
| 215 |
205 void ViewManagerConnection::OnConnectionError() { | 216 void ViewManagerConnection::OnConnectionError() { |
206 if (delete_on_connection_error_) | 217 if (delete_on_connection_error_) |
207 delete this; | 218 delete this; |
208 } | 219 } |
209 | 220 |
210 bool ViewManagerConnection::CanRemoveNodeFromParent(const Node* node) const { | 221 bool ViewManagerConnection::CanRemoveNodeFromParent(const Node* node) const { |
211 if (!node) | 222 if (!node) |
212 return false; | 223 return false; |
213 | 224 |
214 const Node* parent = node->GetParent(); | 225 const Node* parent = node->GetParent(); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 const Node* old_parent) { | 622 const Node* old_parent) { |
612 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); | 623 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); |
613 } | 624 } |
614 | 625 |
615 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, | 626 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, |
616 const View* new_view, | 627 const View* new_view, |
617 const View* old_view) { | 628 const View* old_view) { |
618 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); | 629 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); |
619 } | 630 } |
620 | 631 |
| 632 void ViewManagerConnection::OnViewInputEvent(const View* view, |
| 633 const ui::Event* event) { |
| 634 ViewManagerConnection* connection = root_node_manager_->GetConnection( |
| 635 view->id().connection_id); |
| 636 DCHECK(connection); |
| 637 connection->ProcessViewInputEvent(view, event); |
| 638 } |
| 639 |
621 void ViewManagerConnection::OnConnectionEstablished() { | 640 void ViewManagerConnection::OnConnectionEstablished() { |
622 root_node_manager_->AddConnection(this); | 641 root_node_manager_->AddConnection(this); |
623 | 642 |
624 std::vector<const Node*> to_send; | 643 std::vector<const Node*> to_send; |
625 if (roots_.empty()) { | 644 if (roots_.empty()) { |
626 GetUnknownNodesFrom(root_node_manager_->root(), &to_send); | 645 GetUnknownNodesFrom(root_node_manager_->root(), &to_send); |
627 } else { | 646 } else { |
628 for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) | 647 for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) |
629 GetUnknownNodesFrom(GetNode(NodeIdFromTransportId(*i)), &to_send); | 648 GetUnknownNodesFrom(GetNode(NodeIdFromTransportId(*i)), &to_send); |
630 } | 649 } |
631 | 650 |
632 client()->OnViewManagerConnectionEstablished( | 651 client()->OnViewManagerConnectionEstablished( |
633 id_, | 652 id_, |
634 root_node_manager_->next_server_change_id(), | 653 root_node_manager_->next_server_change_id(), |
635 NodesToINodes(to_send)); | 654 NodesToINodes(to_send)); |
636 } | 655 } |
637 | 656 |
638 } // namespace service | 657 } // namespace service |
639 } // namespace view_manager | 658 } // namespace view_manager |
640 } // namespace mojo | 659 } // namespace mojo |
OLD | NEW |