Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: components/mus/public/cpp/lib/view_tree_client_impl.cc

Issue 1351013002: Revert of Mandoline UI Process: Update namespaces and file names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/mus/public/cpp/lib/view_tree_client_impl.h" 5 #include "components/mus/public/cpp/lib/view_tree_client_impl.h"
6 6
7 #include "components/mus/public/cpp/lib/view_private.h" 7 #include "components/mus/public/cpp/lib/view_private.h"
8 #include "components/mus/public/cpp/util.h" 8 #include "components/mus/public/cpp/util.h"
9 #include "components/mus/public/cpp/view_observer.h" 9 #include "components/mus/public/cpp/view_observer.h"
10 #include "components/mus/public/cpp/view_tree_connection.h" 10 #include "components/mus/public/cpp/view_tree_connection.h"
11 #include "components/mus/public/cpp/view_tree_delegate.h" 11 #include "components/mus/public/cpp/view_tree_delegate.h"
12 #include "mojo/application/public/cpp/application_impl.h" 12 #include "mojo/application/public/cpp/application_impl.h"
13 #include "mojo/application/public/cpp/connect.h" 13 #include "mojo/application/public/cpp/connect.h"
14 #include "mojo/application/public/cpp/service_provider_impl.h" 14 #include "mojo/application/public/cpp/service_provider_impl.h"
15 #include "mojo/application/public/interfaces/service_provider.mojom.h" 15 #include "mojo/application/public/interfaces/service_provider.mojom.h"
16 16
17 namespace mus { 17 namespace mojo {
18 18
19 Id MakeTransportId(ConnectionSpecificId connection_id, 19 Id MakeTransportId(ConnectionSpecificId connection_id,
20 ConnectionSpecificId local_id) { 20 ConnectionSpecificId local_id) {
21 return (connection_id << 16) | local_id; 21 return (connection_id << 16) | local_id;
22 } 22 }
23 23
24 // Helper called to construct a local view object from transport data. 24 // Helper called to construct a local view object from transport data.
25 View* AddViewToConnection(ViewTreeClientImpl* client, 25 View* AddViewToConnection(ViewTreeClientImpl* client,
26 View* parent, 26 View* parent,
27 const mojo::ViewDataPtr& view_data) { 27 const ViewDataPtr& view_data) {
28 // We don't use the cto that takes a ViewTreeConnection here, since it will 28 // We don't use the cto that takes a ViewTreeConnection here, since it will
29 // call back to the service and attempt to create a new view. 29 // call back to the service and attempt to create a new view.
30 View* view = ViewPrivate::LocalCreate(); 30 View* view = ViewPrivate::LocalCreate();
31 ViewPrivate private_view(view); 31 ViewPrivate private_view(view);
32 private_view.set_connection(client); 32 private_view.set_connection(client);
33 private_view.set_id(view_data->view_id); 33 private_view.set_id(view_data->view_id);
34 private_view.set_visible(view_data->visible); 34 private_view.set_visible(view_data->visible);
35 private_view.set_drawn(view_data->drawn); 35 private_view.set_drawn(view_data->drawn);
36 private_view.LocalSetViewportMetrics(mojo::ViewportMetrics(), 36 private_view.LocalSetViewportMetrics(ViewportMetrics(),
37 *view_data->viewport_metrics); 37 *view_data->viewport_metrics);
38 private_view.set_properties( 38 private_view.set_properties(
39 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); 39 view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>());
40 client->AddView(view); 40 client->AddView(view);
41 private_view.LocalSetBounds(mojo::Rect(), *view_data->bounds); 41 private_view.LocalSetBounds(Rect(), *view_data->bounds);
42 if (parent) 42 if (parent)
43 ViewPrivate(parent).LocalAddChild(view); 43 ViewPrivate(parent).LocalAddChild(view);
44 return view; 44 return view;
45 } 45 }
46 46
47 View* BuildViewTree(ViewTreeClientImpl* client, 47 View* BuildViewTree(ViewTreeClientImpl* client,
48 const mojo::Array<mojo::ViewDataPtr>& views, 48 const Array<ViewDataPtr>& views,
49 View* initial_parent) { 49 View* initial_parent) {
50 std::vector<View*> parents; 50 std::vector<View*> parents;
51 View* root = NULL; 51 View* root = NULL;
52 View* last_view = NULL; 52 View* last_view = NULL;
53 if (initial_parent) 53 if (initial_parent)
54 parents.push_back(initial_parent); 54 parents.push_back(initial_parent);
55 for (size_t i = 0; i < views.size(); ++i) { 55 for (size_t i = 0; i < views.size(); ++i) {
56 if (last_view && views[i]->parent_id == last_view->id()) { 56 if (last_view && views[i]->parent_id == last_view->id()) {
57 parents.push_back(last_view); 57 parents.push_back(last_view);
58 } else if (!parents.empty()) { 58 } else if (!parents.empty()) {
59 while (parents.back()->id() != views[i]->parent_id) 59 while (parents.back()->id() != views[i]->parent_id)
60 parents.pop_back(); 60 parents.pop_back();
61 } 61 }
62 View* view = AddViewToConnection( 62 View* view = AddViewToConnection(
63 client, !parents.empty() ? parents.back() : NULL, views[i]); 63 client, !parents.empty() ? parents.back() : NULL, views[i]);
64 if (!last_view) 64 if (!last_view)
65 root = view; 65 root = view;
66 last_view = view; 66 last_view = view;
67 } 67 }
68 return root; 68 return root;
69 } 69 }
70 70
71 ViewTreeConnection* ViewTreeConnection::Create( 71 ViewTreeConnection* ViewTreeConnection::Create(
72 ViewTreeDelegate* delegate, 72 ViewTreeDelegate* delegate,
73 mojo::InterfaceRequest<mojo::ViewTreeClient> request) { 73 InterfaceRequest<ViewTreeClient> request) {
74 return new ViewTreeClientImpl(delegate, request.Pass()); 74 return new ViewTreeClientImpl(delegate, request.Pass());
75 } 75 }
76 76
77 ViewTreeClientImpl::ViewTreeClientImpl( 77 ViewTreeClientImpl::ViewTreeClientImpl(ViewTreeDelegate* delegate,
78 ViewTreeDelegate* delegate, 78 InterfaceRequest<ViewTreeClient> request)
79 mojo::InterfaceRequest<mojo::ViewTreeClient> request)
80 : connection_id_(0), 79 : connection_id_(0),
81 next_id_(1), 80 next_id_(1),
82 delegate_(delegate), 81 delegate_(delegate),
83 root_(nullptr), 82 root_(nullptr),
84 capture_view_(nullptr), 83 capture_view_(nullptr),
85 focused_view_(nullptr), 84 focused_view_(nullptr),
86 activated_view_(nullptr), 85 activated_view_(nullptr),
87 binding_(this, request.Pass()), 86 binding_(this, request.Pass()),
88 is_embed_root_(false), 87 is_embed_root_(false),
89 in_destructor_(false) {} 88 in_destructor_(false) {}
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 tree_->AddView(parent_id, child_id, ActionCompletedCallback()); 121 tree_->AddView(parent_id, child_id, ActionCompletedCallback());
123 } 122 }
124 123
125 void ViewTreeClientImpl::RemoveChild(Id child_id, Id parent_id) { 124 void ViewTreeClientImpl::RemoveChild(Id child_id, Id parent_id) {
126 DCHECK(tree_); 125 DCHECK(tree_);
127 tree_->RemoveViewFromParent(child_id, ActionCompletedCallback()); 126 tree_->RemoveViewFromParent(child_id, ActionCompletedCallback());
128 } 127 }
129 128
130 void ViewTreeClientImpl::Reorder(Id view_id, 129 void ViewTreeClientImpl::Reorder(Id view_id,
131 Id relative_view_id, 130 Id relative_view_id,
132 mojo::OrderDirection direction) { 131 OrderDirection direction) {
133 DCHECK(tree_); 132 DCHECK(tree_);
134 tree_->ReorderView(view_id, relative_view_id, direction, 133 tree_->ReorderView(view_id, relative_view_id, direction,
135 ActionCompletedCallback()); 134 ActionCompletedCallback());
136 } 135 }
137 136
138 bool ViewTreeClientImpl::OwnsView(Id id) const { 137 bool ViewTreeClientImpl::OwnsView(Id id) const {
139 return HiWord(id) == connection_id_; 138 return HiWord(id) == connection_id_;
140 } 139 }
141 140
142 void ViewTreeClientImpl::SetBounds(Id view_id, const mojo::Rect& bounds) { 141 void ViewTreeClientImpl::SetBounds(Id view_id, const Rect& bounds) {
143 DCHECK(tree_); 142 DCHECK(tree_);
144 tree_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback()); 143 tree_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback());
145 } 144 }
146 145
147 void ViewTreeClientImpl::SetFocus(Id view_id) { 146 void ViewTreeClientImpl::SetFocus(Id view_id) {
148 // In order for us to get here we had to have exposed a view, which implies we 147 // In order for us to get here we had to have exposed a view, which implies we
149 // got a connection. 148 // got a connection.
150 DCHECK(tree_); 149 DCHECK(tree_);
151 tree_->SetFocus(view_id); 150 tree_->SetFocus(view_id);
152 } 151 }
153 152
154 void ViewTreeClientImpl::SetVisible(Id view_id, bool visible) { 153 void ViewTreeClientImpl::SetVisible(Id view_id, bool visible) {
155 DCHECK(tree_); 154 DCHECK(tree_);
156 tree_->SetViewVisibility(view_id, visible, ActionCompletedCallback()); 155 tree_->SetViewVisibility(view_id, visible, ActionCompletedCallback());
157 } 156 }
158 157
159 void ViewTreeClientImpl::SetProperty(Id view_id, 158 void ViewTreeClientImpl::SetProperty(Id view_id,
160 const std::string& name, 159 const std::string& name,
161 const std::vector<uint8_t>& data) { 160 const std::vector<uint8_t>& data) {
162 DCHECK(tree_); 161 DCHECK(tree_);
163 tree_->SetViewProperty(view_id, mojo::String(name), 162 tree_->SetViewProperty(view_id, String(name), Array<uint8_t>::From(data),
164 mojo::Array<uint8_t>::From(data),
165 ActionCompletedCallback()); 163 ActionCompletedCallback());
166 } 164 }
167 165
168 void ViewTreeClientImpl::SetViewTextInputState(Id view_id, 166 void ViewTreeClientImpl::SetViewTextInputState(Id view_id,
169 mojo::TextInputStatePtr state) { 167 TextInputStatePtr state) {
170 DCHECK(tree_); 168 DCHECK(tree_);
171 tree_->SetViewTextInputState(view_id, state.Pass()); 169 tree_->SetViewTextInputState(view_id, state.Pass());
172 } 170 }
173 171
174 void ViewTreeClientImpl::SetImeVisibility(Id view_id, 172 void ViewTreeClientImpl::SetImeVisibility(Id view_id,
175 bool visible, 173 bool visible,
176 mojo::TextInputStatePtr state) { 174 TextInputStatePtr state) {
177 DCHECK(tree_); 175 DCHECK(tree_);
178 tree_->SetImeVisibility(view_id, visible, state.Pass()); 176 tree_->SetImeVisibility(view_id, visible, state.Pass());
179 } 177 }
180 178
181 void ViewTreeClientImpl::Embed(Id view_id, 179 void ViewTreeClientImpl::Embed(Id view_id,
182 mojo::ViewTreeClientPtr client, 180 ViewTreeClientPtr client,
183 uint32_t policy_bitmask, 181 uint32_t policy_bitmask,
184 const mojo::ViewTree::EmbedCallback& callback) { 182 const ViewTree::EmbedCallback& callback) {
185 DCHECK(tree_); 183 DCHECK(tree_);
186 tree_->Embed(view_id, client.Pass(), policy_bitmask, callback); 184 tree_->Embed(view_id, client.Pass(), policy_bitmask, callback);
187 } 185 }
188 186
189 void ViewTreeClientImpl::RequestSurface( 187 void ViewTreeClientImpl::RequestSurface(Id view_id,
190 Id view_id, 188 InterfaceRequest<Surface> surface,
191 mojo::InterfaceRequest<mojo::Surface> surface, 189 SurfaceClientPtr client) {
192 mojo::SurfaceClientPtr client) {
193 DCHECK(tree_); 190 DCHECK(tree_);
194 tree_->RequestSurface(view_id, surface.Pass(), client.Pass()); 191 tree_->RequestSurface(view_id, surface.Pass(), client.Pass());
195 } 192 }
196 193
197 void ViewTreeClientImpl::AddView(View* view) { 194 void ViewTreeClientImpl::AddView(View* view) {
198 DCHECK(views_.find(view->id()) == views_.end()); 195 DCHECK(views_.find(view->id()) == views_.end());
199 views_[view->id()] = view; 196 views_[view->id()] = view;
200 } 197 }
201 198
202 void ViewTreeClientImpl::RemoveView(Id view_id) { 199 void ViewTreeClientImpl::RemoveView(Id view_id) {
(...skipping 13 matching lines...) Expand all
216 if (!in_destructor_) 213 if (!in_destructor_)
217 delete this; 214 delete this;
218 } 215 }
219 216
220 //////////////////////////////////////////////////////////////////////////////// 217 ////////////////////////////////////////////////////////////////////////////////
221 // ViewTreeClientImpl, ViewTreeConnection implementation: 218 // ViewTreeClientImpl, ViewTreeConnection implementation:
222 219
223 Id ViewTreeClientImpl::CreateViewOnServer() { 220 Id ViewTreeClientImpl::CreateViewOnServer() {
224 DCHECK(tree_); 221 DCHECK(tree_);
225 const Id view_id = MakeTransportId(connection_id_, ++next_id_); 222 const Id view_id = MakeTransportId(connection_id_, ++next_id_);
226 tree_->CreateView(view_id, [this](mojo::ErrorCode code) { 223 tree_->CreateView(view_id, [this](ErrorCode code) {
227 OnActionCompleted(code == mojo::ERROR_CODE_NONE); 224 OnActionCompleted(code == ERROR_CODE_NONE);
228 }); 225 });
229 return view_id; 226 return view_id;
230 } 227 }
231 228
232 View* ViewTreeClientImpl::GetRoot() { 229 View* ViewTreeClientImpl::GetRoot() {
233 return root_; 230 return root_;
234 } 231 }
235 232
236 View* ViewTreeClientImpl::GetViewById(Id id) { 233 View* ViewTreeClientImpl::GetViewById(Id id) {
237 IdToViewMap::const_iterator it = views_.find(id); 234 IdToViewMap::const_iterator it = views_.find(id);
(...skipping 15 matching lines...) Expand all
253 } 250 }
254 251
255 ConnectionSpecificId ViewTreeClientImpl::GetConnectionId() { 252 ConnectionSpecificId ViewTreeClientImpl::GetConnectionId() {
256 return connection_id_; 253 return connection_id_;
257 } 254 }
258 255
259 //////////////////////////////////////////////////////////////////////////////// 256 ////////////////////////////////////////////////////////////////////////////////
260 // ViewTreeClientImpl, ViewTreeClient implementation: 257 // ViewTreeClientImpl, ViewTreeClient implementation:
261 258
262 void ViewTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id, 259 void ViewTreeClientImpl::OnEmbed(ConnectionSpecificId connection_id,
263 mojo::ViewDataPtr root_data, 260 ViewDataPtr root_data,
264 mojo::ViewTreePtr tree, 261 ViewTreePtr tree,
265 Id focused_view_id, 262 Id focused_view_id,
266 uint32 access_policy) { 263 uint32 access_policy) {
267 if (tree) { 264 if (tree) {
268 DCHECK(!tree_); 265 DCHECK(!tree_);
269 tree_ = tree.Pass(); 266 tree_ = tree.Pass();
270 tree_.set_connection_error_handler([this]() { delete this; }); 267 tree_.set_connection_error_handler([this]() { delete this; });
271 } 268 }
272 connection_id_ = connection_id; 269 connection_id_ = connection_id;
273 is_embed_root_ = 270 is_embed_root_ =
274 (access_policy & mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0; 271 (access_policy & mojo::ViewTree::ACCESS_POLICY_EMBED_ROOT) != 0;
(...skipping 14 matching lines...) Expand all
289 } 286 }
290 } 287 }
291 288
292 void ViewTreeClientImpl::OnUnembed() { 289 void ViewTreeClientImpl::OnUnembed() {
293 delegate_->OnUnembed(); 290 delegate_->OnUnembed();
294 // This will send out the various notifications. 291 // This will send out the various notifications.
295 delete this; 292 delete this;
296 } 293 }
297 294
298 void ViewTreeClientImpl::OnViewBoundsChanged(Id view_id, 295 void ViewTreeClientImpl::OnViewBoundsChanged(Id view_id,
299 mojo::RectPtr old_bounds, 296 RectPtr old_bounds,
300 mojo::RectPtr new_bounds) { 297 RectPtr new_bounds) {
301 View* view = GetViewById(view_id); 298 View* view = GetViewById(view_id);
302 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); 299 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds);
303 } 300 }
304 301
305 namespace { 302 namespace {
306 303
307 void SetViewportMetricsOnDecendants(View* root, 304 void SetViewportMetricsOnDecendants(View* root,
308 const mojo::ViewportMetrics& old_metrics, 305 const ViewportMetrics& old_metrics,
309 const mojo::ViewportMetrics& new_metrics) { 306 const ViewportMetrics& new_metrics) {
310 ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); 307 ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics);
311 const View::Children& children = root->children(); 308 const View::Children& children = root->children();
312 for (size_t i = 0; i < children.size(); ++i) 309 for (size_t i = 0; i < children.size(); ++i)
313 SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics); 310 SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics);
314 } 311 }
315 } 312 }
316 313
317 void ViewTreeClientImpl::OnViewViewportMetricsChanged( 314 void ViewTreeClientImpl::OnViewViewportMetricsChanged(
318 mojo::ViewportMetricsPtr old_metrics, 315 ViewportMetricsPtr old_metrics,
319 mojo::ViewportMetricsPtr new_metrics) { 316 ViewportMetricsPtr new_metrics) {
320 View* view = GetRoot(); 317 View* view = GetRoot();
321 if (view) 318 if (view)
322 SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics); 319 SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics);
323 } 320 }
324 321
325 void ViewTreeClientImpl::OnViewHierarchyChanged( 322 void ViewTreeClientImpl::OnViewHierarchyChanged(
326 Id view_id, 323 Id view_id,
327 Id new_parent_id, 324 Id new_parent_id,
328 Id old_parent_id, 325 Id old_parent_id,
329 mojo::Array<mojo::ViewDataPtr> views) { 326 mojo::Array<ViewDataPtr> views) {
330 View* initial_parent = views.size() ? GetViewById(views[0]->parent_id) : NULL; 327 View* initial_parent = views.size() ? GetViewById(views[0]->parent_id) : NULL;
331 328
332 const bool was_view_known = GetViewById(view_id) != nullptr; 329 const bool was_view_known = GetViewById(view_id) != nullptr;
333 330
334 BuildViewTree(this, views, initial_parent); 331 BuildViewTree(this, views, initial_parent);
335 332
336 // If the view was not known, then BuildViewTree() will have created it and 333 // If the view was not known, then BuildViewTree() will have created it and
337 // parented the view. 334 // parented the view.
338 if (!was_view_known) 335 if (!was_view_known)
339 return; 336 return;
340 337
341 View* new_parent = GetViewById(new_parent_id); 338 View* new_parent = GetViewById(new_parent_id);
342 View* old_parent = GetViewById(old_parent_id); 339 View* old_parent = GetViewById(old_parent_id);
343 View* view = GetViewById(view_id); 340 View* view = GetViewById(view_id);
344 if (new_parent) 341 if (new_parent)
345 ViewPrivate(new_parent).LocalAddChild(view); 342 ViewPrivate(new_parent).LocalAddChild(view);
346 else 343 else
347 ViewPrivate(old_parent).LocalRemoveChild(view); 344 ViewPrivate(old_parent).LocalRemoveChild(view);
348 } 345 }
349 346
350 void ViewTreeClientImpl::OnViewReordered(Id view_id, 347 void ViewTreeClientImpl::OnViewReordered(Id view_id,
351 Id relative_view_id, 348 Id relative_view_id,
352 mojo::OrderDirection direction) { 349 OrderDirection direction) {
353 View* view = GetViewById(view_id); 350 View* view = GetViewById(view_id);
354 View* relative_view = GetViewById(relative_view_id); 351 View* relative_view = GetViewById(relative_view_id);
355 if (view && relative_view) 352 if (view && relative_view)
356 ViewPrivate(view).LocalReorder(relative_view, direction); 353 ViewPrivate(view).LocalReorder(relative_view, direction);
357 } 354 }
358 355
359 void ViewTreeClientImpl::OnViewDeleted(Id view_id) { 356 void ViewTreeClientImpl::OnViewDeleted(Id view_id) {
360 View* view = GetViewById(view_id); 357 View* view = GetViewById(view_id);
361 if (view) 358 if (view)
362 ViewPrivate(view).LocalDestroy(); 359 ViewPrivate(view).LocalDestroy();
363 } 360 }
364 361
365 void ViewTreeClientImpl::OnViewVisibilityChanged(Id view_id, bool visible) { 362 void ViewTreeClientImpl::OnViewVisibilityChanged(Id view_id, bool visible) {
366 // TODO(sky): there is a race condition here. If this client and another 363 // TODO(sky): there is a race condition here. If this client and another
367 // client change the visibility at the same time the wrong value may be set. 364 // client change the visibility at the same time the wrong value may be set.
368 // Deal with this some how. 365 // Deal with this some how.
369 View* view = GetViewById(view_id); 366 View* view = GetViewById(view_id);
370 if (view) 367 if (view)
371 ViewPrivate(view).LocalSetVisible(visible); 368 ViewPrivate(view).LocalSetVisible(visible);
372 } 369 }
373 370
374 void ViewTreeClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) { 371 void ViewTreeClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) {
375 View* view = GetViewById(view_id); 372 View* view = GetViewById(view_id);
376 if (view) 373 if (view)
377 ViewPrivate(view).LocalSetDrawn(drawn); 374 ViewPrivate(view).LocalSetDrawn(drawn);
378 } 375 }
379 376
380 void ViewTreeClientImpl::OnViewSharedPropertyChanged( 377 void ViewTreeClientImpl::OnViewSharedPropertyChanged(Id view_id,
381 Id view_id, 378 const String& name,
382 const mojo::String& name, 379 Array<uint8_t> new_data) {
383 mojo::Array<uint8_t> new_data) {
384 View* view = GetViewById(view_id); 380 View* view = GetViewById(view_id);
385 if (view) { 381 if (view) {
386 std::vector<uint8_t> data; 382 std::vector<uint8_t> data;
387 std::vector<uint8_t>* data_ptr = NULL; 383 std::vector<uint8_t>* data_ptr = NULL;
388 if (!new_data.is_null()) { 384 if (!new_data.is_null()) {
389 data = new_data.To<std::vector<uint8_t>>(); 385 data = new_data.To<std::vector<uint8_t>>();
390 data_ptr = &data; 386 data_ptr = &data;
391 } 387 }
392 388
393 view->SetSharedProperty(name, data_ptr); 389 view->SetSharedProperty(name, data_ptr);
394 } 390 }
395 } 391 }
396 392
397 void ViewTreeClientImpl::OnViewInputEvent( 393 void ViewTreeClientImpl::OnViewInputEvent(
398 Id view_id, 394 Id view_id,
399 mojo::EventPtr event, 395 EventPtr event,
400 const mojo::Callback<void()>& ack_callback) { 396 const Callback<void()>& ack_callback) {
401 View* view = GetViewById(view_id); 397 View* view = GetViewById(view_id);
402 if (view) { 398 if (view) {
403 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(), 399 FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(),
404 OnViewInputEvent(view, event)); 400 OnViewInputEvent(view, event));
405 } 401 }
406 ack_callback.Run(); 402 ack_callback.Run();
407 } 403 }
408 404
409 void ViewTreeClientImpl::OnViewFocused(Id focused_view_id) { 405 void ViewTreeClientImpl::OnViewFocused(Id focused_view_id) {
410 View* focused = GetViewById(focused_view_id); 406 View* focused = GetViewById(focused_view_id);
(...skipping 13 matching lines...) Expand all
424 } 420 }
425 421
426 //////////////////////////////////////////////////////////////////////////////// 422 ////////////////////////////////////////////////////////////////////////////////
427 // ViewTreeClientImpl, private: 423 // ViewTreeClientImpl, private:
428 424
429 void ViewTreeClientImpl::OnActionCompleted(bool success) { 425 void ViewTreeClientImpl::OnActionCompleted(bool success) {
430 if (!change_acked_callback_.is_null()) 426 if (!change_acked_callback_.is_null())
431 change_acked_callback_.Run(); 427 change_acked_callback_.Run();
432 } 428 }
433 429
434 mojo::Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() { 430 Callback<void(bool)> ViewTreeClientImpl::ActionCompletedCallback() {
435 return [this](bool success) { OnActionCompleted(success); }; 431 return [this](bool success) { OnActionCompleted(success); };
436 } 432 }
437 433
438 } // namespace mus 434 } // namespace mojo
OLDNEW
« no previous file with comments | « components/mus/public/cpp/lib/view_tree_client_impl.h ('k') | components/mus/public/cpp/lib/view_tree_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698