| 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 "services/view_manager/view_manager_service_impl.h" | 5 #include "services/view_manager/view_manager_service_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "mojo/converters/geometry/geometry_type_converters.h" | 10 #include "mojo/converters/geometry/geometry_type_converters.h" |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 std::vector<ServerView*> children = view->GetChildren(); | 399 std::vector<ServerView*> children = view->GetChildren(); |
| 400 for (size_t i = 0; i < children.size(); ++i) | 400 for (size_t i = 0; i < children.size(); ++i) |
| 401 view->Remove(children[i]); | 401 view->Remove(children[i]); |
| 402 } | 402 } |
| 403 | 403 |
| 404 Array<ViewDataPtr> ViewManagerServiceImpl::ViewsToViewDatas( | 404 Array<ViewDataPtr> ViewManagerServiceImpl::ViewsToViewDatas( |
| 405 const std::vector<const ServerView*>& views) { | 405 const std::vector<const ServerView*>& views) { |
| 406 auto array = Array<ViewDataPtr>::New(views.size()); | 406 auto array = Array<ViewDataPtr>::New(views.size()); |
| 407 for (size_t i = 0; i < views.size(); ++i) | 407 for (size_t i = 0; i < views.size(); ++i) |
| 408 array[i] = ViewToViewData(views[i]).Pass(); | 408 array[i] = ViewToViewData(views[i]).Pass(); |
| 409 return array.Pass(); | 409 return array; |
| 410 } | 410 } |
| 411 | 411 |
| 412 ViewDataPtr ViewManagerServiceImpl::ViewToViewData(const ServerView* view) { | 412 ViewDataPtr ViewManagerServiceImpl::ViewToViewData(const ServerView* view) { |
| 413 DCHECK(IsViewKnown(view)); | 413 DCHECK(IsViewKnown(view)); |
| 414 const ServerView* parent = view->parent(); | 414 const ServerView* parent = view->parent(); |
| 415 // If the parent isn't known, it means the parent is not visible to us (not | 415 // If the parent isn't known, it means the parent is not visible to us (not |
| 416 // in roots), and should not be sent over. | 416 // in roots), and should not be sent over. |
| 417 if (parent && !IsViewKnown(parent)) | 417 if (parent && !IsViewKnown(parent)) |
| 418 parent = NULL; | 418 parent = NULL; |
| 419 ViewDataPtr view_data(mojo::ViewData::New()); | 419 ViewDataPtr view_data(mojo::ViewData::New()); |
| 420 view_data->parent_id = ViewIdToTransportId(parent ? parent->id() : ViewId()); | 420 view_data->parent_id = ViewIdToTransportId(parent ? parent->id() : ViewId()); |
| 421 view_data->view_id = ViewIdToTransportId(view->id()); | 421 view_data->view_id = ViewIdToTransportId(view->id()); |
| 422 view_data->bounds = mojo::Rect::From(view->bounds()); | 422 view_data->bounds = mojo::Rect::From(view->bounds()); |
| 423 view_data->properties = | 423 view_data->properties = |
| 424 mojo::Map<String, Array<uint8_t>>::From(view->properties()); | 424 mojo::Map<String, Array<uint8_t>>::From(view->properties()); |
| 425 view_data->visible = view->visible(); | 425 view_data->visible = view->visible(); |
| 426 view_data->drawn = view->IsDrawn(connection_manager_->root()); | 426 view_data->drawn = view->IsDrawn(connection_manager_->root()); |
| 427 view_data->viewport_metrics = | 427 view_data->viewport_metrics = |
| 428 connection_manager_->display_manager()->GetViewportMetrics().Clone(); | 428 connection_manager_->display_manager()->GetViewportMetrics().Clone(); |
| 429 return view_data.Pass(); | 429 return view_data; |
| 430 } | 430 } |
| 431 | 431 |
| 432 void ViewManagerServiceImpl::GetViewTreeImpl( | 432 void ViewManagerServiceImpl::GetViewTreeImpl( |
| 433 const ServerView* view, | 433 const ServerView* view, |
| 434 std::vector<const ServerView*>* views) const { | 434 std::vector<const ServerView*>* views) const { |
| 435 DCHECK(view); | 435 DCHECK(view); |
| 436 | 436 |
| 437 if (!access_policy_->CanGetViewTree(view)) | 437 if (!access_policy_->CanGetViewTree(view)) |
| 438 return; | 438 return; |
| 439 | 439 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 } | 647 } |
| 648 | 648 |
| 649 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( | 649 bool ViewManagerServiceImpl::IsViewRootOfAnotherConnectionForAccessPolicy( |
| 650 const ServerView* view) const { | 650 const ServerView* view) const { |
| 651 ViewManagerServiceImpl* connection = | 651 ViewManagerServiceImpl* connection = |
| 652 connection_manager_->GetConnectionWithRoot(view->id()); | 652 connection_manager_->GetConnectionWithRoot(view->id()); |
| 653 return connection && connection != this; | 653 return connection && connection != this; |
| 654 } | 654 } |
| 655 | 655 |
| 656 } // namespace view_manager | 656 } // namespace view_manager |
| OLD | NEW |