| 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 "components/view_manager/view_tree_impl.h" | 5 #include "components/view_manager/view_tree_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 "components/view_manager/connection_manager.h" | 9 #include "components/view_manager/connection_manager.h" |
| 10 #include "components/view_manager/default_access_policy.h" | 10 #include "components/view_manager/default_access_policy.h" |
| (...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 550 } |
| 551 | 551 |
| 552 void ViewTreeImpl::GetViewTree( | 552 void ViewTreeImpl::GetViewTree( |
| 553 Id view_id, | 553 Id view_id, |
| 554 const Callback<void(Array<ViewDataPtr>)>& callback) { | 554 const Callback<void(Array<ViewDataPtr>)>& callback) { |
| 555 std::vector<const ServerView*> views( | 555 std::vector<const ServerView*> views( |
| 556 GetViewTree(ViewIdFromTransportId(view_id))); | 556 GetViewTree(ViewIdFromTransportId(view_id))); |
| 557 callback.Run(ViewsToViewDatas(views)); | 557 callback.Run(ViewsToViewDatas(views)); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void ViewTreeImpl::SetViewSurfaceId( | |
| 561 Id view_id, | |
| 562 mojo::SurfaceIdPtr surface_id, | |
| 563 const Callback<void(bool)>& callback) { | |
| 564 // TODO(sky): add coverage of not being able to set for random node. | |
| 565 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | |
| 566 if (!view || !access_policy_->CanSetViewSurfaceId(view)) { | |
| 567 callback.Run(false); | |
| 568 return; | |
| 569 } | |
| 570 view->SetSurfaceId(surface_id.To<cc::SurfaceId>()); | |
| 571 callback.Run(true); | |
| 572 } | |
| 573 | |
| 574 void ViewTreeImpl::SetViewBounds( | 560 void ViewTreeImpl::SetViewBounds( |
| 575 Id view_id, | 561 Id view_id, |
| 576 mojo::RectPtr bounds, | 562 mojo::RectPtr bounds, |
| 577 const Callback<void(bool)>& callback) { | 563 const Callback<void(bool)>& callback) { |
| 578 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | 564 ServerView* view = GetView(ViewIdFromTransportId(view_id)); |
| 579 const bool success = view && access_policy_->CanSetViewBounds(view); | 565 const bool success = view && access_policy_->CanSetViewBounds(view); |
| 580 if (success) { | 566 if (success) { |
| 581 ConnectionManager::ScopedChange change(this, connection_manager_, false); | 567 ConnectionManager::ScopedChange change(this, connection_manager_, false); |
| 582 view->SetBounds(bounds.To<gfx::Rect>()); | 568 view->SetBounds(bounds.To<gfx::Rect>()); |
| 583 } | 569 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 605 if (value.is_null()) { | 591 if (value.is_null()) { |
| 606 view->SetProperty(name, nullptr); | 592 view->SetProperty(name, nullptr); |
| 607 } else { | 593 } else { |
| 608 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); | 594 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); |
| 609 view->SetProperty(name, &data); | 595 view->SetProperty(name, &data); |
| 610 } | 596 } |
| 611 } | 597 } |
| 612 callback.Run(success); | 598 callback.Run(success); |
| 613 } | 599 } |
| 614 | 600 |
| 601 void ViewTreeImpl::RequestSurface( |
| 602 mojo::Id view_id, |
| 603 mojo::InterfaceRequest<mojo::Surface> surface, |
| 604 mojo::SurfaceClientPtr client) { |
| 605 ServerView* view = GetView(ViewIdFromTransportId(view_id)); |
| 606 const bool success = view && access_policy_->CanSetViewSurfaceId(view); |
| 607 if (!success) |
| 608 return; |
| 609 view->Bind(surface.Pass(), client.Pass()); |
| 610 } |
| 611 |
| 615 void ViewTreeImpl::SetViewTextInputState( | 612 void ViewTreeImpl::SetViewTextInputState( |
| 616 uint32_t view_id, | 613 uint32_t view_id, |
| 617 mojo::TextInputStatePtr state) { | 614 mojo::TextInputStatePtr state) { |
| 618 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | 615 ServerView* view = GetView(ViewIdFromTransportId(view_id)); |
| 619 bool success = view && access_policy_->CanSetViewTextInputState(view); | 616 bool success = view && access_policy_->CanSetViewTextInputState(view); |
| 620 if (success) | 617 if (success) |
| 621 view->SetTextInputState(state.To<ui::TextInputState>()); | 618 view->SetTextInputState(state.To<ui::TextInputState>()); |
| 622 } | 619 } |
| 623 | 620 |
| 624 void ViewTreeImpl::SetImeVisibility(uint32_t view_id, | 621 void ViewTreeImpl::SetImeVisibility(uint32_t view_id, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ViewTreeImpl* connection = | 664 ViewTreeImpl* connection = |
| 668 connection_manager_->GetConnectionWithRoot(view->id()); | 665 connection_manager_->GetConnectionWithRoot(view->id()); |
| 669 return connection && connection != this; | 666 return connection && connection != this; |
| 670 } | 667 } |
| 671 | 668 |
| 672 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { | 669 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { |
| 673 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); | 670 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); |
| 674 } | 671 } |
| 675 | 672 |
| 676 } // namespace view_manager | 673 } // namespace view_manager |
| OLD | NEW |