OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ | |
6 #define SERVICES_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "mojo/public/cpp/application/application_connection.h" | |
10 #include "mojo/public/cpp/application/application_impl.h" | |
11 #include "mojo/public/cpp/application/interface_factory.h" | |
12 #include "mojo/public/cpp/bindings/binding.h" | |
13 #include "mojo/services/view_manager/interfaces/view_manager.mojom.h" | |
14 #include "mojo/services/window_manager/interfaces/window_manager_internal.mojom.
h" | |
15 #include "services/view_manager/connection_manager.h" | |
16 #include "services/view_manager/connection_manager_delegate.h" | |
17 | |
18 namespace mojo { | |
19 class ApplicationImpl; | |
20 } | |
21 | |
22 namespace view_manager { | |
23 | |
24 // An instance of ViewManagerRootConnection represents one inbound connection | |
25 // from a window manager to the view manager app. It handles the creation of | |
26 // services for this connection, as well as any outbound connection necessary. | |
27 class ViewManagerRootConnection | |
28 : public ConnectionManagerDelegate, | |
29 public mojo::InterfaceFactory<mojo::ViewManagerService>, | |
30 public mojo::InterfaceFactory<mojo::WindowManagerInternalClient> { | |
31 public: | |
32 class ViewManagerRootConnectionObserver { | |
33 public: | |
34 // Called when a ViewManagerRootConnection is closing. | |
35 virtual void OnCloseViewManagerRootConnection( | |
36 ViewManagerRootConnection* view_manager_root_connection) = 0; | |
37 | |
38 protected: | |
39 virtual ~ViewManagerRootConnectionObserver() {} | |
40 }; | |
41 | |
42 ViewManagerRootConnection(mojo::ApplicationImpl* application_impl, | |
43 ViewManagerRootConnectionObserver* observer); | |
44 ~ViewManagerRootConnection() override; | |
45 | |
46 // Returns true if the view manager root connection is established, false | |
47 // otherwise. In that case, the object should probably be destroyed. | |
48 bool Init(mojo::ApplicationConnection* connection); | |
49 | |
50 private: | |
51 // ConnectionManagerDelegate: | |
52 void OnLostConnectionToWindowManager() override; | |
53 ClientConnection* CreateClientConnectionForEmbedAtView( | |
54 ConnectionManager* connection_manager, | |
55 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, | |
56 mojo::ConnectionSpecificId creator_id, | |
57 const std::string& creator_url, | |
58 const std::string& url, | |
59 const ViewId& root_id) override; | |
60 ClientConnection* CreateClientConnectionForEmbedAtView( | |
61 ConnectionManager* connection_manager, | |
62 mojo::InterfaceRequest<mojo::ViewManagerService> service_request, | |
63 mojo::ConnectionSpecificId creator_id, | |
64 const std::string& creator_url, | |
65 const ViewId& root_id, | |
66 mojo::ViewManagerClientPtr view_manager_client) override; | |
67 | |
68 // mojo::InterfaceFactory<mojo::ViewManagerService>: | |
69 void Create( | |
70 mojo::ApplicationConnection* connection, | |
71 mojo::InterfaceRequest<mojo::ViewManagerService> request) override; | |
72 | |
73 // mojo::InterfaceFactory<mojo::WindowManagerInternalClient>: | |
74 void Create(mojo::ApplicationConnection* connection, | |
75 mojo::InterfaceRequest<mojo::WindowManagerInternalClient> request) | |
76 override; | |
77 | |
78 mojo::ApplicationImpl* app_impl_; | |
79 ViewManagerRootConnectionObserver* observer_; | |
80 scoped_ptr<mojo::Binding<mojo::WindowManagerInternalClient>> | |
81 wm_internal_client_binding_; | |
82 mojo::InterfaceRequest<mojo::ViewManagerClient> wm_internal_client_request_; | |
83 mojo::WindowManagerInternalPtr wm_internal_; | |
84 scoped_ptr<ConnectionManager> connection_manager_; | |
85 | |
86 DISALLOW_COPY_AND_ASSIGN(ViewManagerRootConnection); | |
87 }; | |
88 | |
89 } // namespace view_manager | |
90 | |
91 #endif // SERVICES_VIEW_MANAGER_VIEW_MANAGER_ROOT_CONNECTION_H_ | |
OLD | NEW |