Chromium Code Reviews| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 } | 645 } |
| 646 | 646 |
| 647 void ViewTreeImpl::GetViewTree( | 647 void ViewTreeImpl::GetViewTree( |
| 648 Id view_id, | 648 Id view_id, |
| 649 const Callback<void(Array<ViewDataPtr>)>& callback) { | 649 const Callback<void(Array<ViewDataPtr>)>& callback) { |
| 650 std::vector<const ServerView*> views( | 650 std::vector<const ServerView*> views( |
| 651 GetViewTree(ViewIdFromTransportId(view_id))); | 651 GetViewTree(ViewIdFromTransportId(view_id))); |
| 652 callback.Run(ViewsToViewDatas(views)); | 652 callback.Run(ViewsToViewDatas(views)); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void ViewTreeImpl::SetViewSurfaceId( | |
| 656 Id view_id, | |
| 657 mojo::SurfaceIdPtr surface_id, | |
| 658 const Callback<void(bool)>& callback) { | |
| 659 // TODO(sky): add coverage of not being able to set for random node. | |
| 660 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | |
| 661 if (!view || !access_policy_->CanSetViewSurfaceId(view)) { | |
| 662 callback.Run(false); | |
| 663 return; | |
| 664 } | |
| 665 view->SetSurfaceId(surface_id.To<cc::SurfaceId>()); | |
| 666 callback.Run(true); | |
| 667 } | |
| 668 | |
| 669 void ViewTreeImpl::SetViewBounds( | 655 void ViewTreeImpl::SetViewBounds( |
| 670 Id view_id, | 656 Id view_id, |
| 671 mojo::RectPtr bounds, | 657 mojo::RectPtr bounds, |
| 672 const Callback<void(bool)>& callback) { | 658 const Callback<void(bool)>& callback) { |
| 673 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | 659 ServerView* view = GetView(ViewIdFromTransportId(view_id)); |
| 674 const bool success = view && access_policy_->CanSetViewBounds(view); | 660 const bool success = view && access_policy_->CanSetViewBounds(view); |
| 675 if (success) { | 661 if (success) { |
| 676 ConnectionManager::ScopedChange change(this, connection_manager_, false); | 662 ConnectionManager::ScopedChange change(this, connection_manager_, false); |
| 677 view->SetBounds(bounds.To<gfx::Rect>()); | 663 view->SetBounds(bounds.To<gfx::Rect>()); |
| 678 } | 664 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 700 if (value.is_null()) { | 686 if (value.is_null()) { |
| 701 view->SetProperty(name, nullptr); | 687 view->SetProperty(name, nullptr); |
| 702 } else { | 688 } else { |
| 703 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); | 689 std::vector<uint8_t> data = value.To<std::vector<uint8_t>>(); |
| 704 view->SetProperty(name, &data); | 690 view->SetProperty(name, &data); |
| 705 } | 691 } |
| 706 } | 692 } |
| 707 callback.Run(success); | 693 callback.Run(success); |
| 708 } | 694 } |
| 709 | 695 |
| 696 void ViewTreeImpl::RequestSurface( | |
| 697 mojo::Id view_id, | |
| 698 mojo::InterfaceRequest<mojo::Surface> surface, | |
| 699 mojo::SurfaceClientPtr client) { | |
| 700 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | |
|
sky
2015/08/26 22:58:03
You'll want to reset the surface/client if this is
Fady Samuel
2015/08/26 23:51:01
Done.
| |
| 701 const bool success = view && access_policy_->CanSetViewSurfaceId(view); | |
| 702 if (!success) | |
| 703 return; | |
| 704 view->Bind(surface.Pass(), client.Pass()); | |
| 705 } | |
| 706 | |
| 710 void ViewTreeImpl::SetViewTextInputState( | 707 void ViewTreeImpl::SetViewTextInputState( |
| 711 uint32_t view_id, | 708 uint32_t view_id, |
| 712 mojo::TextInputStatePtr state) { | 709 mojo::TextInputStatePtr state) { |
| 713 ServerView* view = GetView(ViewIdFromTransportId(view_id)); | 710 ServerView* view = GetView(ViewIdFromTransportId(view_id)); |
| 714 bool success = view && access_policy_->CanSetViewTextInputState(view); | 711 bool success = view && access_policy_->CanSetViewTextInputState(view); |
| 715 if (success) | 712 if (success) |
| 716 view->SetTextInputState(state.To<ui::TextInputState>()); | 713 view->SetTextInputState(state.To<ui::TextInputState>()); |
| 717 } | 714 } |
| 718 | 715 |
| 719 void ViewTreeImpl::SetImeVisibility(uint32_t view_id, | 716 void ViewTreeImpl::SetImeVisibility(uint32_t view_id, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 ViewTreeImpl* connection = | 767 ViewTreeImpl* connection = |
| 771 connection_manager_->GetConnectionWithRoot(view->id()); | 768 connection_manager_->GetConnectionWithRoot(view->id()); |
| 772 return connection && connection != this; | 769 return connection && connection != this; |
| 773 } | 770 } |
| 774 | 771 |
| 775 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { | 772 bool ViewTreeImpl::IsDescendantOfEmbedRoot(const ServerView* view) { |
| 776 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); | 773 return is_embed_root_ && root_ && GetView(*root_)->Contains(view); |
| 777 } | 774 } |
| 778 | 775 |
| 779 } // namespace view_manager | 776 } // namespace view_manager |
| OLD | NEW |