| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "services/ui/view_manager/view_host_impl.h" |
| |
| #include "base/bind.h" |
| #include "services/ui/view_manager/view_registry.h" |
| #include "services/ui/view_manager/view_state.h" |
| |
| namespace view_manager { |
| |
| ViewHostImpl::ViewHostImpl(ViewRegistry* registry, ViewState* state) |
| : registry_(registry), state_(state) {} |
| |
| ViewHostImpl::~ViewHostImpl() {} |
| |
| void ViewHostImpl::GetToken( |
| const mojo::ui::ViewHost::GetTokenCallback& callback) { |
| callback.Run(state_->view_token()->Clone()); |
| } |
| |
| void ViewHostImpl::GetServiceProvider( |
| mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request) { |
| service_provider_bindings_.AddBinding(this, service_provider_request.Pass()); |
| } |
| |
| void ViewHostImpl::CreateScene( |
| mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene) { |
| registry_->CreateScene(state_, scene.Pass()); |
| } |
| |
| void ViewHostImpl::RequestLayout() { |
| registry_->RequestLayout(state_); |
| } |
| |
| void ViewHostImpl::AddChild( |
| uint32_t child_key, |
| mojo::InterfaceHandle<mojo::ui::ViewOwner> child_view_owner) { |
| registry_->AddChild(state_, child_key, child_view_owner.Pass()); |
| } |
| |
| void ViewHostImpl::RemoveChild(uint32_t child_key, |
| mojo::InterfaceRequest<mojo::ui::ViewOwner> |
| transferred_view_owner_request) { |
| registry_->RemoveChild(state_, child_key, |
| transferred_view_owner_request.Pass()); |
| } |
| |
| static void RunLayoutChildCallback( |
| const ViewHostImpl::LayoutChildCallback& callback, |
| mojo::ui::ViewLayoutInfoPtr info) { |
| callback.Run(info.Pass()); |
| } |
| |
| void ViewHostImpl::LayoutChild( |
| uint32_t child_key, |
| mojo::ui::ViewLayoutParamsPtr child_layout_params, |
| const LayoutChildCallback& callback) { |
| registry_->LayoutChild(state_, child_key, child_layout_params.Pass(), |
| base::Bind(&RunLayoutChildCallback, callback)); |
| } |
| |
| void ViewHostImpl::ConnectToService( |
| const mojo::String& service_name, |
| mojo::ScopedMessagePipeHandle client_handle) { |
| registry_->ConnectToViewService(state_, service_name, client_handle.Pass()); |
| } |
| |
| } // namespace view_manager |