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 MOJO_UI_VIEW_PROVIDER_APP_H_ | 5 #ifndef MOJO_UI_VIEW_PROVIDER_APP_H_ |
6 #define MOJO_UI_VIEW_PROVIDER_APP_H_ | 6 #define MOJO_UI_VIEW_PROVIDER_APP_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "mojo/common/strong_binding_set.h" | 10 #include "mojo/common/strong_binding_set.h" |
11 #include "mojo/public/c/system/main.h" | 11 #include "mojo/public/cpp/application/application_impl_base.h" |
12 #include "mojo/public/cpp/application/application_delegate.h" | |
13 #include "mojo/public/cpp/application/application_impl.h" | |
14 #include "mojo/public/cpp/application/service_provider_impl.h" | |
15 #include "mojo/public/cpp/system/macros.h" | 12 #include "mojo/public/cpp/system/macros.h" |
16 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" | 13 #include "mojo/services/ui/views/interfaces/view_provider.mojom.h" |
17 | 14 |
18 namespace mojo { | 15 namespace mojo { |
| 16 |
| 17 class ServiceProviderImpl; |
| 18 |
19 namespace ui { | 19 namespace ui { |
20 | 20 |
21 // Abstract implementation of a simple application that offers a ViewProvider. | 21 // Abstract implementation of a simple application that offers a ViewProvider. |
22 // Subclasses must provide a function to create the necessary Views. | 22 // Subclasses must provide a function to create the necessary Views. |
23 // | 23 // |
24 // It is not necessary to use this class to implement all ViewProviders. | 24 // It is not necessary to use this class to implement all ViewProviders. |
25 // This class is merely intended to make the simple apps easier to write. | 25 // This class is merely intended to make the simple apps easier to write. |
26 class ViewProviderApp : public ApplicationDelegate { | 26 class ViewProviderApp : public ApplicationImplBase { |
27 public: | 27 public: |
28 ViewProviderApp(); | 28 ViewProviderApp(); |
29 ~ViewProviderApp() override; | 29 ~ViewProviderApp() override; |
30 | 30 |
31 ApplicationImpl* app_impl() { return app_impl_; } | 31 // |ApplicationImplBase|: |
32 | 32 void OnInitialize() override; |
33 // |ApplicationDelegate|: | 33 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override; |
34 void Initialize(ApplicationImpl* app) override; | |
35 bool ConfigureIncomingConnection( | |
36 ServiceProviderImpl* service_provider_impl) override; | |
37 | 34 |
38 // Called by the ViewProvider to create a view. | 35 // Called by the ViewProvider to create a view. |
39 // This method may be called multiple times in the case where the | 36 // This method may be called multiple times in the case where the |
40 // view provider is asked to create multiple view instances. | 37 // view provider is asked to create multiple view instances. |
41 // | 38 // |
42 // The |view_provider_url| is the connection URL of the view provider request. | 39 // The |view_provider_url| is the connection URL of the view provider request. |
43 // | 40 // |
44 // The |view_owner_request| should be attached to the newly created view | 41 // The |view_owner_request| should be attached to the newly created view |
45 // and closed or left pending if the view could not be created. | 42 // and closed or left pending if the view could not be created. |
46 // | 43 // |
47 // The |services| parameter is used to receive services from the view | 44 // The |services| parameter is used to receive services from the view |
48 // on behalf of the caller. | 45 // on behalf of the caller. |
49 virtual void CreateView(const std::string& view_provider_url, | 46 virtual void CreateView(const std::string& view_provider_url, |
50 InterfaceRequest<ViewOwner> view_owner_request, | 47 InterfaceRequest<ViewOwner> view_owner_request, |
51 InterfaceRequest<ServiceProvider> services) = 0; | 48 InterfaceRequest<ServiceProvider> services) = 0; |
52 | 49 |
53 private: | 50 private: |
54 class DelegatingViewProvider; | 51 class DelegatingViewProvider; |
55 | 52 |
56 void CreateView(DelegatingViewProvider* provider, | 53 void CreateView(DelegatingViewProvider* provider, |
57 const std::string& view_provider_url, | 54 const std::string& view_provider_url, |
58 InterfaceRequest<ViewOwner> view_owner_request, | 55 InterfaceRequest<ViewOwner> view_owner_request, |
59 InterfaceRequest<ServiceProvider> services); | 56 InterfaceRequest<ServiceProvider> services); |
60 | 57 |
61 ApplicationImpl* app_impl_ = nullptr; | |
62 StrongBindingSet<ViewProvider> bindings_; | 58 StrongBindingSet<ViewProvider> bindings_; |
63 | 59 |
64 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewProviderApp); | 60 MOJO_DISALLOW_COPY_AND_ASSIGN(ViewProviderApp); |
65 }; | 61 }; |
66 | 62 |
67 } // namespace ui | 63 } // namespace ui |
68 } // namespace mojo | 64 } // namespace mojo |
69 | 65 |
70 #endif // MOJO_UI_VIEW_PROVIDER_APP_H_ | 66 #endif // MOJO_UI_VIEW_PROVIDER_APP_H_ |
OLD | NEW |