1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_
6 #define COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "components/view_manager/connection_manager_delegate.h"
10 #include "components/view_manager/gles2/gpu_impl.h"
11 #include "components/view_manager/public/interfaces/native_viewport.mojom.h"
12 #include "components/view_manager/public/interfaces/view_manager.mojom.h"
13 #include "components/view_manager/public/interfaces/view_manager_root.mojom.h"
14 #include "mojo/application/public/cpp/app_lifetime_helper.h"
15 #include "mojo/application/public/cpp/application_delegate.h"
16 #include "mojo/application/public/cpp/interface_factory.h"
17 #include "mojo/common/tracing_impl.h"
20 class ApplicationImpl
;
24 class PlatformEventSource
;
27 namespace view_manager
{
29 class ConnectionManager
;
31 class ViewManagerApp
: public mojo::ApplicationDelegate
,
32 public ConnectionManagerDelegate
,
33 public mojo::ErrorHandler
,
34 public mojo::InterfaceFactory
<mojo::ViewManagerRoot
>,
35 public mojo::InterfaceFactory
<mojo::ViewManagerService
>,
36 public mojo::InterfaceFactory
<mojo::NativeViewport
>,
37 public mojo::InterfaceFactory
<mojo::Gpu
> {
40 ~ViewManagerApp() override
;
43 // ApplicationDelegate:
44 void Initialize(mojo::ApplicationImpl
* app
) override
;
45 bool ConfigureIncomingConnection(
46 mojo::ApplicationConnection
* connection
) override
;
48 // ConnectionManagerDelegate:
49 void OnLostConnectionToWindowManager() override
;
50 ClientConnection
* CreateClientConnectionForEmbedAtView(
51 ConnectionManager
* connection_manager
,
52 mojo::InterfaceRequest
<mojo::ViewManagerService
> service_request
,
53 mojo::ConnectionSpecificId creator_id
,
54 const std::string
& creator_url
,
55 mojo::URLRequestPtr request
,
56 const ViewId
& root_id
) override
;
57 ClientConnection
* CreateClientConnectionForEmbedAtView(
58 ConnectionManager
* connection_manager
,
59 mojo::InterfaceRequest
<mojo::ViewManagerService
> service_request
,
60 mojo::ConnectionSpecificId creator_id
,
61 const std::string
& creator_url
,
62 const ViewId
& root_id
,
63 mojo::ViewManagerClientPtr view_manager_client
) override
;
65 // mojo::InterfaceFactory<mojo::ViewManagerService>:
67 mojo::ApplicationConnection
* connection
,
68 mojo::InterfaceRequest
<mojo::ViewManagerService
> request
) override
;
70 // mojo::InterfaceFactory<mojo::ViewManagerRoot>:
71 void Create(mojo::ApplicationConnection
* connection
,
72 mojo::InterfaceRequest
<mojo::ViewManagerRoot
> request
) override
;
74 // mojo::InterfaceFactory<mojo::NativeViewport> implementation.
75 void Create(mojo::ApplicationConnection
* connection
,
76 mojo::InterfaceRequest
<mojo::NativeViewport
> request
) override
;
78 // mojo::InterfaceFactory<mojo::Gpu> implementation.
79 void Create(mojo::ApplicationConnection
* connection
,
80 mojo::InterfaceRequest
<mojo::Gpu
> request
) override
;
82 // ErrorHandler (for |wm_internal_| and |wm_internal_client_binding_|).
83 void OnConnectionError() override
;
85 mojo::ApplicationImpl
* app_impl_
;
86 scoped_ptr
<mojo::Binding
<mojo::ViewManagerRoot
>> view_manager_root_binding_
;
87 scoped_ptr
<ConnectionManager
> connection_manager_
;
88 mojo::TracingImpl tracing_
;
89 scoped_refptr
<gles2::GpuState
> gpu_state_
;
90 scoped_ptr
<ui::PlatformEventSource
> event_source_
;
93 DISALLOW_COPY_AND_ASSIGN(ViewManagerApp
);
96 } // namespace view_manager
98 #endif // COMPONENTS_VIEW_MANAGER_VIEW_MANAGER_APP_H_