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 SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
6 #define SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "mojo/public/cpp/system/core.h" | 9 #include "mojo/public/cpp/system/core.h" |
10 #include "mojo/public/interfaces/application/shell.mojom.h" | 10 #include "mojo/public/interfaces/application/shell.mojom.h" |
11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 11 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
12 #include "shell/application_manager/application_manager_export.h" | 12 #include "shell/application_manager/application_manager_export.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace mojo { | 15 namespace mojo { |
16 | 16 |
17 class Application; | 17 class Application; |
18 class ApplicationManager; | 18 class ApplicationManager; |
19 | 19 |
20 // Interface to allowing loading behavior to be established for schemes, | 20 // Interface to implement special application loading behavior for a particular |
21 // specific urls or as the default. | 21 // URL or scheme. |
22 // A ApplicationLoader is responsible to using whatever mechanism is appropriate | |
23 // to load the application at url. | |
24 // The handle to the shell is passed to that application so it can bind it to | |
25 // a Shell instance. This will give the Application a way to connect to other | |
26 // apps and services. | |
27 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { | 22 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { |
28 public: | 23 public: |
29 typedef base::Callback<void(const GURL& content_handler_url, | |
30 InterfaceRequest<Application> application_request, | |
31 URLResponsePtr url_request)> LoadCallback; | |
32 virtual ~ApplicationLoader() {} | 24 virtual ~ApplicationLoader() {} |
33 | 25 |
34 // Returns a callback that will should never be called. | 26 virtual void Load(const GURL& url, |
35 static LoadCallback SimpleLoadCallback(); | 27 InterfaceRequest<Application> application_request) = 0; |
36 | |
37 // Load the application named |url|. Applications can be loaded two ways: | |
38 // | |
39 // 1. |url| can refer directly to a Mojo application. In this case, | |
40 // shell_handle should be used to implement the mojo.Application interface. | |
41 // | |
42 // 2. |url| can refer to some content that can be handled by some other Mojo | |
43 // application. In this case, call callbacks and specify the URL of the | |
44 // application that should handle the content. The specified application | |
45 // must implement the mojo.ContentHandler interface. | |
46 virtual void Load(ApplicationManager* application_manager, | |
47 const GURL& url, | |
48 InterfaceRequest<Application> application_request, | |
49 LoadCallback callback) = 0; | |
50 | 28 |
51 // Called when the Application exits. | 29 // Called when the Application exits. |
52 virtual void OnApplicationError(ApplicationManager* manager, | 30 virtual void OnApplicationError(ApplicationManager* manager, |
53 const GURL& url) = 0; | 31 const GURL& url) = 0; |
54 | 32 |
55 protected: | 33 protected: |
56 ApplicationLoader() {} | 34 ApplicationLoader() {} |
57 }; | 35 }; |
58 | 36 |
| 37 // TODO(aa): Remove this temporary interface. This is just here as a stepping |
| 38 // stone, until I can tear apart NativeApplicationLoader into smaller pieces. |
| 39 // See comments at top of shell/native_application_loader.h. |
| 40 |
| 41 typedef base::Callback<void(const GURL& content_handler_url, |
| 42 InterfaceRequest<Application> application_request, |
| 43 URLResponsePtr url_request)> LoadCallback; |
| 44 |
| 45 class NativeApplicationLoader { |
| 46 public: |
| 47 // Returns a callback that should never be called. |
| 48 static LoadCallback SimpleLoadCallback(); |
| 49 |
| 50 virtual ~NativeApplicationLoader() {} |
| 51 |
| 52 virtual void Load(const GURL& url, |
| 53 InterfaceRequest<Application> application_request, |
| 54 LoadCallback callback) {} |
| 55 }; |
| 56 |
59 } // namespace mojo | 57 } // namespace mojo |
60 | 58 |
61 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 59 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
OLD | NEW |