Index: mojo/services/view_manager/node.cc |
diff --git a/mojo/services/view_manager/node.cc b/mojo/services/view_manager/node.cc |
index 1457a7ee6b6ac1785b983567ecbdd826555312ce..e2436dab5aeb96d5f46149465355e37299d2ac54 100644 |
--- a/mojo/services/view_manager/node.cc |
+++ b/mojo/services/view_manager/node.cc |
@@ -5,6 +5,7 @@ |
#include "mojo/services/view_manager/node.h" |
#include "mojo/services/view_manager/node_delegate.h" |
+#include "mojo/services/view_manager/view.h" |
#include "ui/aura/window_property.h" |
DECLARE_WINDOW_PROPERTY_TYPE(mojo::services::view_manager::Node*); |
@@ -18,6 +19,7 @@ DEFINE_WINDOW_PROPERTY_KEY(Node*, kNodeKey, NULL); |
Node::Node(NodeDelegate* delegate, const NodeId& id) |
: delegate_(delegate), |
id_(id), |
+ view_(NULL), |
window_(NULL) { |
DCHECK(delegate); // Must provide a delegate. |
window_.set_owned_by_parent(false); |
@@ -26,6 +28,7 @@ Node::Node(NodeDelegate* delegate, const NodeId& id) |
} |
Node::~Node() { |
+ SetView(NULL); |
} |
Node* Node::GetParent() { |
@@ -42,6 +45,36 @@ void Node::Remove(Node* child) { |
window_.RemoveChild(&child->window_); |
} |
+std::vector<Node*> Node::GetChildren() { |
+ std::vector<Node*> children; |
+ children.reserve(window_.children().size()); |
+ for (size_t i = 0; i < window_.children().size(); ++i) |
+ children.push_back(window_.children()[i]->GetProperty(kNodeKey)); |
+ return children; |
+} |
+ |
+void Node::SetView(View* view) { |
+ if (view == view_) |
+ return; |
+ |
+ // Detach view from existing node. This way notifications are sent out. |
+ if (view && view->node()) |
+ view->node()->SetView(NULL); |
+ |
+ ViewId old_view_id; |
+ if (view_) { |
+ view_->set_node(NULL); |
+ old_view_id = view_->id(); |
+ } |
+ view_ = view; |
+ ViewId view_id; |
+ if (view) { |
+ view_id = view->id(); |
+ view->set_node(this); |
+ } |
+ delegate_->OnNodeViewReplaced(id_, view_id, old_view_id); |
+} |
+ |
void Node::OnWindowHierarchyChanged( |
const aura::WindowObserver::HierarchyChangeParams& params) { |
if (params.target != &window_ || params.receiver != &window_) |