OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ | 5 #ifndef MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ |
6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ | 6 #define MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ |
7 | 7 |
8 #include <set> | |
9 | |
10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/scoped_vector.h" | 9 #include "mojo/public/cpp/bindings/callback.h" |
12 #include "mojo/public/cpp/application/application_connection.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
13 #include "mojo/public/cpp/application/application_delegate.h" | 11 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
14 #include "mojo/services/view_manager/display_manager_delegate.h" | |
15 #include "mojo/services/view_manager/view_manager_export.h" | 12 #include "mojo/services/view_manager/view_manager_export.h" |
16 | 13 |
17 namespace mojo { | 14 namespace mojo { |
| 15 class ApplicationConnection; |
| 16 |
18 namespace service { | 17 namespace service { |
19 | 18 |
20 class ConnectionManager; | 19 class ConnectionManager; |
21 class ViewManagerInitServiceImpl; | 20 class ViewManagerInitServiceImpl; |
22 | 21 |
23 // State shared between all ViewManagerInitService impls. | 22 // State shared between all ViewManagerInitService impls. |
24 class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceContext | 23 class MOJO_VIEW_MANAGER_EXPORT ViewManagerInitServiceContext { |
25 : public DisplayManagerDelegate { | |
26 public: | 24 public: |
27 ViewManagerInitServiceContext(); | 25 ViewManagerInitServiceContext(); |
28 virtual ~ViewManagerInitServiceContext(); | 26 virtual ~ViewManagerInitServiceContext(); |
29 | 27 |
30 void AddConnection(ViewManagerInitServiceImpl* connection); | 28 void AddConnection(ViewManagerInitServiceImpl* connection); |
31 void RemoveConnection(ViewManagerInitServiceImpl* connection); | 29 void RemoveConnection(ViewManagerInitServiceImpl* connection); |
32 | 30 |
33 void ConfigureIncomingConnection(ApplicationConnection* connection); | 31 void ConfigureIncomingConnection(ApplicationConnection* connection); |
34 | 32 |
35 void Embed(const String& url, | 33 void Embed(const String& url, |
36 ServiceProviderPtr service_provider, | 34 ServiceProviderPtr service_provider, |
37 const Callback<void(bool)>& callback); | 35 const Callback<void(bool)>& callback); |
38 | 36 |
39 ConnectionManager* connection_manager() { return connection_manager_.get(); } | 37 ConnectionManager* connection_manager() { return connection_manager_.get(); } |
40 | 38 |
41 bool is_tree_host_ready() const { return is_tree_host_ready_; } | |
42 | |
43 private: | 39 private: |
44 typedef std::vector<ViewManagerInitServiceImpl*> Connections; | 40 typedef std::vector<ViewManagerInitServiceImpl*> Connections; |
45 | 41 |
46 struct ConnectParams { | 42 struct ConnectParams { |
47 ConnectParams(); | 43 ConnectParams(); |
48 ~ConnectParams(); | 44 ~ConnectParams(); |
49 | 45 |
50 std::string url; | 46 std::string url; |
51 InterfaceRequest<ServiceProvider> service_provider; | 47 InterfaceRequest<ServiceProvider> service_provider; |
52 Callback<void(bool)> callback; | 48 Callback<void(bool)> callback; |
53 }; | 49 }; |
54 | 50 |
55 // DisplayManagerDelegate overrides: | |
56 virtual void OnDisplayManagerWindowTreeHostCreated() OVERRIDE; | |
57 | |
58 void OnNativeViewportDeleted(); | 51 void OnNativeViewportDeleted(); |
59 | 52 |
60 void MaybeEmbed(); | |
61 | |
62 scoped_ptr<ConnectionManager> connection_manager_; | 53 scoped_ptr<ConnectionManager> connection_manager_; |
63 Connections connections_; | 54 Connections connections_; |
64 | 55 |
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_; | |
68 | |
69 bool is_tree_host_ready_; | |
70 | |
71 bool deleting_connection_; | 56 bool deleting_connection_; |
72 | 57 |
73 DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceContext); | 58 DISALLOW_COPY_AND_ASSIGN(ViewManagerInitServiceContext); |
74 }; | 59 }; |
75 | 60 |
76 } // namespace service | 61 } // namespace service |
77 } // namespace mojo | 62 } // namespace mojo |
78 | 63 |
79 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ | 64 #endif // MOJO_SERVICES_VIEW_MANAGER_VIEW_MANAGER_INIT_SERVICE_CONTEXT_H_ |
OLD | NEW |