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 MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_
6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/scoped_vector.h"
12 #include "mojo/public/cpp/application/application_connection.h"
13 #include "mojo/public/cpp/application/application_delegate.h"
14 #include "mojo/services/view_manager/root_view_manager_delegate.h"
15 #include "mojo/services/view_manager/view_manager_export.h"
20 class RootNodeManager
;
21 class ViewManagerInitServiceImpl
;
23 // State shared between all ViewManagerInitService impls.
24 class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceContext
25 : public RootViewManagerDelegate
{
27 ViewManagerInitServiceContext();
28 virtual ~ViewManagerInitServiceContext();
30 void AddConnection(ViewManagerInitServiceImpl
* connection
);
31 void RemoveConnection(ViewManagerInitServiceImpl
* connection
);
33 void ConfigureIncomingConnection(ApplicationConnection
* connection
);
35 void Embed(const String
& url
,
36 ServiceProviderPtr service_provider
,
37 const Callback
<void(bool)>& callback
);
39 RootNodeManager
* root_node_manager() { return root_node_manager_
.get(); }
41 bool is_tree_host_ready() const { return is_tree_host_ready_
; }
44 typedef std::vector
<ViewManagerInitServiceImpl
*> Connections
;
46 struct ConnectParams
{
51 InterfaceRequest
<ServiceProvider
> service_provider
;
52 Callback
<void(bool)> callback
;
55 // RootViewManagerDelegate overrides:
56 virtual void OnRootViewManagerWindowTreeHostCreated() OVERRIDE
;
58 void OnNativeViewportDeleted();
62 scoped_ptr
<RootNodeManager
> root_node_manager_
;
63 Connections connections_
;
65 // Stores information about inbound calls to Embed() pending execution on
66 // the window tree host being ready to use.
67 ScopedVector
<ConnectParams
> connect_params_
;
69 bool is_tree_host_ready_
;
71 bool deleting_connection_
;
73 DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceContext
);
76 } // namespace service
79 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_