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_host_impl.h" | 5 #include "services/ui/view_manager/view_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "services/ui/view_manager/view_registry.h" |
| 9 #include "services/ui/view_manager/view_state.h" |
9 | 10 |
10 namespace view_manager { | 11 namespace view_manager { |
11 | 12 |
12 ViewHostImpl::ViewHostImpl( | 13 ViewHostImpl::ViewHostImpl(ViewRegistry* registry, ViewState* state) |
13 ViewRegistry* registry, | 14 : registry_(registry), state_(state) {} |
14 ViewState* state, | |
15 mojo::InterfaceRequest<mojo::ui::ViewHost> view_host_request) | |
16 : registry_(registry), | |
17 state_(state), | |
18 binding_(this, view_host_request.Pass()) {} | |
19 | 15 |
20 ViewHostImpl::~ViewHostImpl() {} | 16 ViewHostImpl::~ViewHostImpl() {} |
21 | 17 |
| 18 void ViewHostImpl::GetToken( |
| 19 const mojo::ui::ViewHost::GetTokenCallback& callback) { |
| 20 callback.Run(state_->view_token()->Clone()); |
| 21 } |
| 22 |
22 void ViewHostImpl::GetServiceProvider( | 23 void ViewHostImpl::GetServiceProvider( |
23 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request) { | 24 mojo::InterfaceRequest<mojo::ServiceProvider> service_provider_request) { |
24 service_provider_bindings_.AddBinding(this, service_provider_request.Pass()); | 25 service_provider_bindings_.AddBinding(this, service_provider_request.Pass()); |
25 } | 26 } |
26 | 27 |
27 void ViewHostImpl::CreateScene( | 28 void ViewHostImpl::CreateScene( |
28 mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene) { | 29 mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene) { |
29 registry_->CreateScene(state_, scene.Pass()); | 30 registry_->CreateScene(state_, scene.Pass()); |
30 } | 31 } |
31 | 32 |
32 void ViewHostImpl::RequestLayout() { | 33 void ViewHostImpl::RequestLayout() { |
33 registry_->RequestLayout(state_); | 34 registry_->RequestLayout(state_); |
34 } | 35 } |
35 | 36 |
36 void ViewHostImpl::AddChild(uint32_t child_key, | 37 void ViewHostImpl::AddChild(uint32_t child_key, |
37 mojo::ui::ViewTokenPtr child_view_token) { | 38 mojo::ui::ViewOwnerPtr child_view_owner) { |
38 registry_->AddChild(state_, child_key, child_view_token.Pass()); | 39 registry_->AddChild(state_, child_key, child_view_owner.Pass()); |
39 } | 40 } |
40 | 41 |
41 void ViewHostImpl::RemoveChild(uint32_t child_key) { | 42 void ViewHostImpl::RemoveChild(uint32_t child_key, |
42 registry_->RemoveChild(state_, child_key); | 43 mojo::InterfaceRequest<mojo::ui::ViewOwner> |
| 44 transferred_view_owner_request) { |
| 45 registry_->RemoveChild(state_, child_key, |
| 46 transferred_view_owner_request.Pass()); |
43 } | 47 } |
44 | 48 |
45 static void RunLayoutChildCallback( | 49 static void RunLayoutChildCallback( |
46 const ViewHostImpl::LayoutChildCallback& callback, | 50 const ViewHostImpl::LayoutChildCallback& callback, |
47 mojo::ui::ViewLayoutInfoPtr info) { | 51 mojo::ui::ViewLayoutInfoPtr info) { |
48 callback.Run(info.Pass()); | 52 callback.Run(info.Pass()); |
49 } | 53 } |
50 | 54 |
51 void ViewHostImpl::LayoutChild( | 55 void ViewHostImpl::LayoutChild( |
52 uint32_t child_key, | 56 uint32_t child_key, |
53 mojo::ui::ViewLayoutParamsPtr child_layout_params, | 57 mojo::ui::ViewLayoutParamsPtr child_layout_params, |
54 const LayoutChildCallback& callback) { | 58 const LayoutChildCallback& callback) { |
55 registry_->LayoutChild(state_, child_key, child_layout_params.Pass(), | 59 registry_->LayoutChild(state_, child_key, child_layout_params.Pass(), |
56 base::Bind(&RunLayoutChildCallback, callback)); | 60 base::Bind(&RunLayoutChildCallback, callback)); |
57 } | 61 } |
58 | 62 |
59 void ViewHostImpl::ConnectToService( | 63 void ViewHostImpl::ConnectToService( |
60 const mojo::String& service_name, | 64 const mojo::String& service_name, |
61 mojo::ScopedMessagePipeHandle client_handle) { | 65 mojo::ScopedMessagePipeHandle client_handle) { |
62 registry_->ConnectToViewService(state_, service_name, client_handle.Pass()); | 66 registry_->ConnectToViewService(state_, service_name, client_handle.Pass()); |
63 } | 67 } |
64 | 68 |
65 } // namespace view_manager | 69 } // namespace view_manager |
OLD | NEW |