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 ApplicationManager; | 18 class ApplicationManager; |
18 | 19 |
19 // Interface to allowing loading behavior to be established for schemes, | 20 // Interface to allowing loading behavior to be established for schemes, |
20 // specific urls or as the default. | 21 // specific urls or as the default. |
21 // A ApplicationLoader is responsible to using whatever mechanism is appropriate | 22 // A ApplicationLoader is responsible to using whatever mechanism is appropriate |
22 // to load the application at url. | 23 // to load the application at url. |
23 // The handle to the shell is passed to that application so it can bind it to | 24 // The handle to the shell is passed to that application so it can bind it to |
24 // a Shell instance. This will give the Application a way to connect to other | 25 // a Shell instance. This will give the Application a way to connect to other |
25 // apps and services. | 26 // apps and services. |
26 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { | 27 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { |
27 public: | 28 public: |
28 typedef base::Callback< | 29 typedef base::Callback<void(const GURL& content_handler_url, |
29 void(const GURL&, ScopedMessagePipeHandle, URLResponsePtr)> LoadCallback; | 30 InterfaceRequest<Application> application_request, |
| 31 URLResponsePtr url_request)> LoadCallback; |
30 virtual ~ApplicationLoader() {} | 32 virtual ~ApplicationLoader() {} |
31 | 33 |
32 // Returns a callback that will should never be called. | 34 // Returns a callback that will should never be called. |
33 static LoadCallback SimpleLoadCallback(); | 35 static LoadCallback SimpleLoadCallback(); |
34 | 36 |
35 // Load the application named |url|. Applications can be loaded two ways: | 37 // Load the application named |url|. Applications can be loaded two ways: |
36 // | 38 // |
37 // 1. |url| can refer directly to a Mojo application. In this case, | 39 // 1. |url| can refer directly to a Mojo application. In this case, |
38 // shell_handle should be used to implement the mojo.Application interface. | 40 // shell_handle should be used to implement the mojo.Application interface. |
39 // | 41 // |
40 // 2. |url| can refer to some content that can be handled by some other Mojo | 42 // 2. |url| can refer to some content that can be handled by some other Mojo |
41 // application. In this case, call callbacks and specify the URL of the | 43 // application. In this case, call callbacks and specify the URL of the |
42 // application that should handle the content. The specified application | 44 // application that should handle the content. The specified application |
43 // must implement the mojo.ContentHandler interface. | 45 // must implement the mojo.ContentHandler interface. |
44 virtual void Load(ApplicationManager* application_manager, | 46 virtual void Load(ApplicationManager* application_manager, |
45 const GURL& url, | 47 const GURL& url, |
46 ShellPtr shell, | 48 InterfaceRequest<Application> application_request, |
47 LoadCallback callback) = 0; | 49 LoadCallback callback) = 0; |
48 | 50 |
49 // Called when the Application exits. | 51 // Called when the Application exits. |
50 virtual void OnApplicationError(ApplicationManager* manager, | 52 virtual void OnApplicationError(ApplicationManager* manager, |
51 const GURL& url) = 0; | 53 const GURL& url) = 0; |
52 | 54 |
53 protected: | 55 protected: |
54 ApplicationLoader() {} | 56 ApplicationLoader() {} |
55 }; | 57 }; |
56 | 58 |
57 } // namespace mojo | 59 } // namespace mojo |
58 | 60 |
59 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 61 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
OLD | NEW |