| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/view_manager/view_tree_host_impl.h" |
| 6 |
| 5 #include "base/bind.h" | 7 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 7 #include "services/ui/view_manager/view_tree_host_impl.h" | |
| 8 | 9 |
| 9 namespace view_manager { | 10 namespace view_manager { |
| 10 | 11 |
| 11 ViewTreeHostImpl::ViewTreeHostImpl( | 12 ViewTreeHostImpl::ViewTreeHostImpl( |
| 12 ViewRegistry* registry, | 13 ViewRegistry* registry, |
| 13 ViewTreeState* state, | 14 ViewTreeState* state, |
| 14 mojo::InterfaceRequest<mojo::ui::ViewTreeHost> view_tree_host_request) | 15 mojo::InterfaceRequest<mojo::ui::ViewTreeHost> view_tree_host_request) |
| 15 : registry_(registry), | 16 : registry_(registry), |
| 16 state_(state), | 17 state_(state), |
| 17 binding_(this, view_tree_host_request.Pass()) {} | 18 binding_(this, view_tree_host_request.Pass()) {} |
| 18 | 19 |
| 19 ViewTreeHostImpl::~ViewTreeHostImpl() {} | 20 ViewTreeHostImpl::~ViewTreeHostImpl() {} |
| 20 | 21 |
| 22 void ViewTreeHostImpl::GetServiceProvider( |
| 23 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider) { |
| 24 service_provider_bindings_.AddBinding(this, service_provider.Pass()); |
| 25 } |
| 26 |
| 21 void ViewTreeHostImpl::RequestLayout() { | 27 void ViewTreeHostImpl::RequestLayout() { |
| 22 registry_->RequestLayout(state_); | 28 registry_->RequestLayout(state_); |
| 23 } | 29 } |
| 24 | 30 |
| 25 void ViewTreeHostImpl::SetRoot(uint32_t root_key, | 31 void ViewTreeHostImpl::SetRoot(uint32_t root_key, |
| 26 mojo::ui::ViewTokenPtr root_view_token) { | 32 mojo::ui::ViewTokenPtr root_view_token) { |
| 27 registry_->SetRoot(state_, root_key, root_view_token.Pass()); | 33 registry_->SetRoot(state_, root_key, root_view_token.Pass()); |
| 28 } | 34 } |
| 29 | 35 |
| 30 void ViewTreeHostImpl::ResetRoot() { | 36 void ViewTreeHostImpl::ResetRoot() { |
| 31 registry_->ResetRoot(state_); | 37 registry_->ResetRoot(state_); |
| 32 } | 38 } |
| 33 | 39 |
| 34 static void RunLayoutRootCallback( | 40 static void RunLayoutRootCallback( |
| 35 const ViewTreeHostImpl::LayoutRootCallback& callback, | 41 const ViewTreeHostImpl::LayoutRootCallback& callback, |
| 36 mojo::ui::ViewLayoutInfoPtr info) { | 42 mojo::ui::ViewLayoutInfoPtr info) { |
| 37 callback.Run(info.Pass()); | 43 callback.Run(info.Pass()); |
| 38 } | 44 } |
| 39 | 45 |
| 40 void ViewTreeHostImpl::LayoutRoot( | 46 void ViewTreeHostImpl::LayoutRoot( |
| 41 mojo::ui::ViewLayoutParamsPtr root_layout_params, | 47 mojo::ui::ViewLayoutParamsPtr root_layout_params, |
| 42 const LayoutRootCallback& callback) { | 48 const LayoutRootCallback& callback) { |
| 43 registry_->LayoutRoot(state_, root_layout_params.Pass(), | 49 registry_->LayoutRoot(state_, root_layout_params.Pass(), |
| 44 base::Bind(&RunLayoutRootCallback, callback)); | 50 base::Bind(&RunLayoutRootCallback, callback)); |
| 45 } | 51 } |
| 46 | 52 |
| 53 void ViewTreeHostImpl::ConnectToService( |
| 54 const mojo::String& service_name, |
| 55 mojo::ScopedMessagePipeHandle client_handle) { |
| 56 registry_->ConnectToViewTreeService(state_, service_name, |
| 57 client_handle.Pass()); |
| 58 } |
| 59 |
| 47 } // namespace view_manager | 60 } // namespace view_manager |
| OLD | NEW |