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