| 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/public/cpp/view_manager/lib/view_manager_client_impl.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_client_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "mojo/public/cpp/application/application_impl.h" | 10 #include "mojo/public/cpp/application/application_impl.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 const ViewDataPtr& view_data) { | 30 const ViewDataPtr& view_data) { |
| 31 // We don't use the ctor that takes a ViewManager here, since it will call | 31 // We don't use the ctor that takes a ViewManager here, since it will call |
| 32 // back to the service and attempt to create a new view. | 32 // back to the service and attempt to create a new view. |
| 33 View* view = ViewPrivate::LocalCreate(); | 33 View* view = ViewPrivate::LocalCreate(); |
| 34 ViewPrivate private_view(view); | 34 ViewPrivate private_view(view); |
| 35 private_view.set_view_manager(client); | 35 private_view.set_view_manager(client); |
| 36 private_view.set_id(view_data->view_id); | 36 private_view.set_id(view_data->view_id); |
| 37 private_view.set_visible(view_data->visible); | 37 private_view.set_visible(view_data->visible); |
| 38 private_view.set_drawn(view_data->drawn); | 38 private_view.set_drawn(view_data->drawn); |
| 39 client->AddView(view); | 39 client->AddView(view); |
| 40 private_view.LocalSetBounds(gfx::Rect(), view_data->bounds.To<gfx::Rect>()); | 40 private_view.LocalSetBounds(Rect(), *view_data->bounds); |
| 41 if (parent) | 41 if (parent) |
| 42 ViewPrivate(parent).LocalAddChild(view); | 42 ViewPrivate(parent).LocalAddChild(view); |
| 43 return view; | 43 return view; |
| 44 } | 44 } |
| 45 | 45 |
| 46 View* BuildViewTree(ViewManagerClientImpl* client, | 46 View* BuildViewTree(ViewManagerClientImpl* client, |
| 47 const Array<ViewDataPtr>& views, | 47 const Array<ViewDataPtr>& views, |
| 48 View* initial_parent) { | 48 View* initial_parent) { |
| 49 std::vector<View*> parents; | 49 std::vector<View*> parents; |
| 50 View* root = NULL; | 50 View* root = NULL; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 OrderDirection direction) { | 147 OrderDirection direction) { |
| 148 DCHECK(connected_); | 148 DCHECK(connected_); |
| 149 service_->ReorderView(view_id, relative_view_id, direction, | 149 service_->ReorderView(view_id, relative_view_id, direction, |
| 150 ActionCompletedCallback()); | 150 ActionCompletedCallback()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool ViewManagerClientImpl::OwnsView(Id id) const { | 153 bool ViewManagerClientImpl::OwnsView(Id id) const { |
| 154 return HiWord(id) == connection_id_; | 154 return HiWord(id) == connection_id_; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ViewManagerClientImpl::SetBounds(Id view_id, const gfx::Rect& bounds) { | 157 void ViewManagerClientImpl::SetBounds(Id view_id, const Rect& bounds) { |
| 158 DCHECK(connected_); | 158 DCHECK(connected_); |
| 159 service_->SetViewBounds(view_id, Rect::From(bounds), | 159 service_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback()); |
| 160 ActionCompletedCallback()); | |
| 161 } | 160 } |
| 162 | 161 |
| 163 void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) { | 162 void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) { |
| 164 DCHECK(connected_); | 163 DCHECK(connected_); |
| 165 if (surface_id.is_null()) | 164 if (surface_id.is_null()) |
| 166 return; | 165 return; |
| 167 service_->SetViewSurfaceId( | 166 service_->SetViewSurfaceId( |
| 168 view_id, surface_id.Pass(), ActionCompletedCallback()); | 167 view_id, surface_id.Pass(), ActionCompletedCallback()); |
| 169 } | 168 } |
| 170 | 169 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 BindToRequest(exported_services, &service_provider); | 253 BindToRequest(exported_services, &service_provider); |
| 255 scoped_ptr<ServiceProvider> remote( | 254 scoped_ptr<ServiceProvider> remote( |
| 256 exported_services->CreateRemoteServiceProvider()); | 255 exported_services->CreateRemoteServiceProvider()); |
| 257 delegate_->OnEmbed(this, root, exported_services, remote.Pass()); | 256 delegate_->OnEmbed(this, root, exported_services, remote.Pass()); |
| 258 } | 257 } |
| 259 | 258 |
| 260 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, | 259 void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, |
| 261 RectPtr old_bounds, | 260 RectPtr old_bounds, |
| 262 RectPtr new_bounds) { | 261 RectPtr new_bounds) { |
| 263 View* view = GetViewById(view_id); | 262 View* view = GetViewById(view_id); |
| 264 ViewPrivate(view).LocalSetBounds(old_bounds.To<gfx::Rect>(), | 263 ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); |
| 265 new_bounds.To<gfx::Rect>()); | |
| 266 } | 264 } |
| 267 | 265 |
| 268 void ViewManagerClientImpl::OnViewHierarchyChanged( | 266 void ViewManagerClientImpl::OnViewHierarchyChanged( |
| 269 Id view_id, | 267 Id view_id, |
| 270 Id new_parent_id, | 268 Id new_parent_id, |
| 271 Id old_parent_id, | 269 Id old_parent_id, |
| 272 mojo::Array<ViewDataPtr> views) { | 270 mojo::Array<ViewDataPtr> views) { |
| 273 View* initial_parent = views.size() ? | 271 View* initial_parent = views.size() ? |
| 274 GetViewById(views[0]->parent_id) : NULL; | 272 GetViewById(views[0]->parent_id) : NULL; |
| 275 | 273 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 base::Unretained(this)); | 376 base::Unretained(this)); |
| 379 } | 377 } |
| 380 | 378 |
| 381 base::Callback<void(ErrorCode)> | 379 base::Callback<void(ErrorCode)> |
| 382 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { | 380 ViewManagerClientImpl::ActionCompletedCallbackWithErrorCode() { |
| 383 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, | 381 return base::Bind(&ViewManagerClientImpl::OnActionCompletedWithErrorCode, |
| 384 base::Unretained(this)); | 382 base::Unretained(this)); |
| 385 } | 383 } |
| 386 | 384 |
| 387 } // namespace mojo | 385 } // namespace mojo |
| OLD | NEW |