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 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ | 5 #ifndef SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ |
6 #define SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ | 6 #define SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "mojo/common/binding_set.h" | 9 #include "mojo/common/binding_set.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | |
11 #include "mojo/services/ui/views/interfaces/views.mojom.h" | 10 #include "mojo/services/ui/views/interfaces/views.mojom.h" |
12 #include "services/ui/view_manager/view_registry.h" | |
13 #include "services/ui/view_manager/view_state.h" | |
14 | 11 |
15 namespace view_manager { | 12 namespace view_manager { |
16 | 13 |
| 14 class ViewRegistry; |
| 15 class ViewState; |
| 16 |
17 // ViewHost interface implementation. | 17 // ViewHost interface implementation. |
18 // This object is owned by its associated ViewState. | 18 // This object is owned by its associated ViewState. |
19 class ViewHostImpl : public mojo::ui::ViewHost, public mojo::ServiceProvider { | 19 class ViewHostImpl : public mojo::ui::ViewHost, |
| 20 public mojo::ui::ViewOwner, |
| 21 public mojo::ServiceProvider { |
20 public: | 22 public: |
21 ViewHostImpl(ViewRegistry* registry, | 23 ViewHostImpl(ViewRegistry* registry, ViewState* state); |
22 ViewState* state, | |
23 mojo::InterfaceRequest<mojo::ui::ViewHost> view_host_request); | |
24 ~ViewHostImpl() override; | 24 ~ViewHostImpl() override; |
25 | 25 |
26 void set_view_host_connection_error_handler(const base::Closure& handler) { | |
27 binding_.set_connection_error_handler(handler); | |
28 } | |
29 | |
30 private: | 26 private: |
31 // |ViewHost|: | 27 // |ViewHost|: |
| 28 void GetToken(const mojo::ui::ViewHost::GetTokenCallback& callback) override; |
32 void GetServiceProvider(mojo::InterfaceRequest<mojo::ServiceProvider> | 29 void GetServiceProvider(mojo::InterfaceRequest<mojo::ServiceProvider> |
33 service_provider_request) override; | 30 service_provider_request) override; |
34 void CreateScene( | 31 void CreateScene( |
35 mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene) override; | 32 mojo::InterfaceRequest<mojo::gfx::composition::Scene> scene) override; |
36 void RequestLayout() override; | 33 void RequestLayout() override; |
37 void AddChild(uint32_t child_key, | 34 void AddChild(uint32_t child_key, |
38 mojo::ui::ViewTokenPtr child_view_token) override; | 35 mojo::ui::ViewOwnerPtr child_view_owner) override; |
39 void RemoveChild(uint32_t child_key) override; | 36 void RemoveChild(uint32_t child_key, |
| 37 mojo::InterfaceRequest<mojo::ui::ViewOwner> |
| 38 transferred_view_owner_request) override; |
40 void LayoutChild(uint32_t child_key, | 39 void LayoutChild(uint32_t child_key, |
41 mojo::ui::ViewLayoutParamsPtr child_layout_params, | 40 mojo::ui::ViewLayoutParamsPtr child_layout_params, |
42 const LayoutChildCallback& callback) override; | 41 const LayoutChildCallback& callback) override; |
43 | 42 |
44 // |ServiceProvider|: | 43 // |ServiceProvider|: |
45 void ConnectToService(const mojo::String& service_name, | 44 void ConnectToService(const mojo::String& service_name, |
46 mojo::ScopedMessagePipeHandle client_handle) override; | 45 mojo::ScopedMessagePipeHandle client_handle) override; |
47 | 46 |
48 ViewRegistry* const registry_; | 47 ViewRegistry* const registry_; |
49 ViewState* const state_; | 48 ViewState* const state_; |
50 mojo::Binding<mojo::ui::ViewHost> binding_; | |
51 mojo::BindingSet<mojo::ServiceProvider> service_provider_bindings_; | 49 mojo::BindingSet<mojo::ServiceProvider> service_provider_bindings_; |
52 | 50 |
53 DISALLOW_COPY_AND_ASSIGN(ViewHostImpl); | 51 DISALLOW_COPY_AND_ASSIGN(ViewHostImpl); |
54 }; | 52 }; |
55 | 53 |
56 } // namespace view_manager | 54 } // namespace view_manager |
57 | 55 |
58 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ | 56 #endif // SERVICES_UI_VIEW_MANAGER_VIEW_HOST_IMPL_H_ |
OLD | NEW |