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_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 5 #ifndef MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 6 #define MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 bool OwnsView(Id id) const; | 56 bool OwnsView(Id id) const; |
57 | 57 |
58 void SetActiveView(Id node_id, Id view_id); | 58 void SetActiveView(Id node_id, Id view_id); |
59 void SetBounds(Id node_id, const gfx::Rect& bounds); | 59 void SetBounds(Id node_id, const gfx::Rect& bounds); |
60 void SetViewContents(Id view_id, const SkBitmap& contents); | 60 void SetViewContents(Id view_id, const SkBitmap& contents); |
61 void SetFocus(Id node_id); | 61 void SetFocus(Id node_id); |
62 void SetVisible(Id node_id, bool visible); | 62 void SetVisible(Id node_id, bool visible); |
63 | 63 |
64 void Embed(const String& url, Id node_id); | 64 void Embed(const String& url, Id node_id); |
65 | 65 |
66 void set_changes_acked_callback(const base::Callback<void(void)>& callback) { | 66 void set_change_acked_callback(const base::Callback<void(void)>& callback) { |
67 changes_acked_callback_ = callback; | 67 change_acked_callback_ = callback; |
68 } | 68 } |
69 void ClearChangesAckedCallback() { | 69 void ClearChangeAckedCallback() { |
70 changes_acked_callback_ = base::Callback<void(void)>(); | 70 change_acked_callback_ = base::Callback<void(void)>(); |
71 } | 71 } |
72 | 72 |
73 // Start/stop tracking nodes & views. While tracked, they can be retrieved via | 73 // Start/stop tracking nodes & views. While tracked, they can be retrieved via |
74 // ViewManager::GetNode/ViewById. | 74 // ViewManager::GetNode/ViewById. |
75 void AddNode(Node* node); | 75 void AddNode(Node* node); |
76 void RemoveNode(Id node_id); | 76 void RemoveNode(Id node_id); |
77 | 77 |
78 void AddView(View* view); | 78 void AddView(View* view); |
79 void RemoveView(Id view_id); | 79 void RemoveView(Id view_id); |
80 | 80 |
81 private: | 81 private: |
82 friend class RootObserver; | 82 friend class RootObserver; |
83 friend class ViewManagerTransaction; | |
84 | 83 |
85 typedef ScopedVector<ViewManagerTransaction> Transactions; | |
86 typedef std::map<Id, Node*> IdToNodeMap; | 84 typedef std::map<Id, Node*> IdToNodeMap; |
87 typedef std::map<Id, View*> IdToViewMap; | 85 typedef std::map<Id, View*> IdToViewMap; |
88 | 86 |
89 // Overridden from ViewManager: | 87 // Overridden from ViewManager: |
90 virtual void SetWindowManagerDelegate( | 88 virtual void SetWindowManagerDelegate( |
91 WindowManagerDelegate* delegate) OVERRIDE; | 89 WindowManagerDelegate* delegate) OVERRIDE; |
92 virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE; | 90 virtual void DispatchEvent(View* target, EventPtr event) OVERRIDE; |
93 virtual const std::string& GetEmbedderURL() const OVERRIDE; | 91 virtual const std::string& GetEmbedderURL() const OVERRIDE; |
94 virtual const std::vector<Node*>& GetRoots() const OVERRIDE; | 92 virtual const std::vector<Node*>& GetRoots() const OVERRIDE; |
95 virtual Node* GetNodeById(Id id) OVERRIDE; | 93 virtual Node* GetNodeById(Id id) OVERRIDE; |
(...skipping 23 matching lines...) Expand all Loading... |
119 Id new_view_id, | 117 Id new_view_id, |
120 Id old_view_id) OVERRIDE; | 118 Id old_view_id) OVERRIDE; |
121 virtual void OnViewDeleted(Id view_id) OVERRIDE; | 119 virtual void OnViewDeleted(Id view_id) OVERRIDE; |
122 virtual void OnViewInputEvent(Id view, | 120 virtual void OnViewInputEvent(Id view, |
123 EventPtr event, | 121 EventPtr event, |
124 const Callback<void()>& callback) OVERRIDE; | 122 const Callback<void()>& callback) OVERRIDE; |
125 virtual void OnFocusChanged(Id gained_focus_id, Id lost_focus_id) OVERRIDE; | 123 virtual void OnFocusChanged(Id gained_focus_id, Id lost_focus_id) OVERRIDE; |
126 virtual void Embed(const String& url) OVERRIDE; | 124 virtual void Embed(const String& url) OVERRIDE; |
127 virtual void DispatchOnViewInputEvent(Id view_id, EventPtr event) OVERRIDE; | 125 virtual void DispatchOnViewInputEvent(Id view_id, EventPtr event) OVERRIDE; |
128 | 126 |
129 // Sync the client model with the service by enumerating the pending | |
130 // transaction queue and applying them in order. | |
131 void Sync(); | |
132 | |
133 // Removes |transaction| from the pending queue. |transaction| must be at the | |
134 // front of the queue. | |
135 void RemoveFromPendingQueue(ViewManagerTransaction* transaction); | |
136 | |
137 void AddRoot(Node* root); | 127 void AddRoot(Node* root); |
138 void RemoveRoot(Node* root); | 128 void RemoveRoot(Node* root); |
139 | 129 |
| 130 void OnActionCompleted(bool success); |
| 131 void OnActionCompletedWithErrorCode(ErrorCode code); |
| 132 |
| 133 base::Callback<void(bool)> ActionCompletedCallback(); |
| 134 base::Callback<void(ErrorCode)> ActionCompletedCallbackWithErrorCode(); |
| 135 |
140 bool connected_; | 136 bool connected_; |
141 ConnectionSpecificId connection_id_; | 137 ConnectionSpecificId connection_id_; |
142 ConnectionSpecificId next_id_; | 138 ConnectionSpecificId next_id_; |
143 | 139 |
144 std::string creator_url_; | 140 std::string creator_url_; |
145 | 141 |
146 Transactions pending_transactions_; | 142 base::Callback<void(void)> change_acked_callback_; |
147 | |
148 base::Callback<void(void)> changes_acked_callback_; | |
149 | 143 |
150 ViewManagerDelegate* delegate_; | 144 ViewManagerDelegate* delegate_; |
151 WindowManagerDelegate* window_manager_delegate_; | 145 WindowManagerDelegate* window_manager_delegate_; |
152 | 146 |
153 std::vector<Node*> roots_; | 147 std::vector<Node*> roots_; |
154 | 148 |
155 IdToNodeMap nodes_; | 149 IdToNodeMap nodes_; |
156 IdToViewMap views_; | 150 IdToViewMap views_; |
157 | 151 |
158 ViewManagerService* service_; | 152 ViewManagerService* service_; |
159 | 153 |
160 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); | 154 DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); |
161 }; | 155 }; |
162 | 156 |
163 } // namespace view_manager | 157 } // namespace view_manager |
164 } // namespace mojo | 158 } // namespace mojo |
165 | 159 |
166 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ | 160 #endif // MOJO_SERVICES_PUBLIC_CPP_VIEW_MANAGER_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ |
OLD | NEW |