| 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 #ifndef MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| 7 | 7 |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/logging.h" | 8 #include "base/logging.h" |
| 11 #include "mojo/services/view_manager/ids.h" | 9 #include "mojo/services/view_manager/ids.h" |
| 12 #include "mojo/services/view_manager/view_manager_export.h" | 10 #include "mojo/services/view_manager/view_manager_export.h" |
| 13 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_observer.h" | 12 #include "ui/aura/window_observer.h" |
| 15 | 13 |
| 16 namespace mojo { | 14 namespace mojo { |
| 17 namespace services { | 15 namespace services { |
| 18 namespace view_manager { | 16 namespace view_manager { |
| 19 | 17 |
| 20 class NodeDelegate; | 18 class NodeDelegate; |
| 21 class View; | |
| 22 | 19 |
| 23 // Represents a node in the graph. Delegate is informed of interesting events. | 20 // Represents a node in the graph. Delegate is informed of interesting events. |
| 24 class MOJO_VIEW_MANAGER_EXPORT Node : public aura::WindowObserver { | 21 class MOJO_VIEW_MANAGER_EXPORT Node : public aura::WindowObserver { |
| 25 public: | 22 public: |
| 26 Node(NodeDelegate* delegate, const NodeId& id); | 23 Node(NodeDelegate* delegate, const NodeId& id); |
| 27 virtual ~Node(); | 24 virtual ~Node(); |
| 28 | 25 |
| 29 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } | 26 void set_view_id(const ViewId& view_id) { view_id_ = view_id; } |
| 30 const ViewId& view_id() const { return view_id_; } | 27 const ViewId& view_id() const { return view_id_; } |
| 31 | 28 |
| 32 const NodeId& id() const { return id_; } | 29 const NodeId& id() const { return id_; } |
| 33 | 30 |
| 34 void Add(Node* child); | 31 void Add(Node* child); |
| 35 void Remove(Node* child); | 32 void Remove(Node* child); |
| 36 | 33 |
| 37 Node* GetParent(); | 34 Node* GetParent(); |
| 38 | 35 |
| 39 std::vector<Node*> GetChildren(); | |
| 40 | |
| 41 // Sets the view associated with this node. Node does not own its View. | |
| 42 void SetView(View* view); | |
| 43 View* view() { return view_; } | |
| 44 | |
| 45 private: | 36 private: |
| 46 // WindowObserver overrides: | 37 // WindowObserver overrides: |
| 47 virtual void OnWindowHierarchyChanged( | 38 virtual void OnWindowHierarchyChanged( |
| 48 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; | 39 const aura::WindowObserver::HierarchyChangeParams& params) OVERRIDE; |
| 49 | 40 |
| 50 NodeDelegate* delegate_; | 41 NodeDelegate* delegate_; |
| 51 const NodeId id_; | 42 const NodeId id_; |
| 52 | |
| 53 // Weak pointer to view associated with this node. | |
| 54 View* view_; | |
| 55 | |
| 56 ViewId view_id_; | 43 ViewId view_id_; |
| 57 | |
| 58 aura::Window window_; | 44 aura::Window window_; |
| 59 | 45 |
| 60 DISALLOW_COPY_AND_ASSIGN(Node); | 46 DISALLOW_COPY_AND_ASSIGN(Node); |
| 61 }; | 47 }; |
| 62 | 48 |
| 63 } // namespace view_manager | 49 } // namespace view_manager |
| 64 } // namespace services | 50 } // namespace services |
| 65 } // namespace mojo | 51 } // namespace mojo |
| 66 | 52 |
| 67 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ | 53 #endif // MOJO_SERVICES_VIEW_MANAGER_NODE_H_ |
| OLD | NEW |