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_SHELL_PACKAGE_MANAGER_H_ | 5 #ifndef MOJO_SHELL_PACKAGE_MANAGER_H_ |
6 #define MOJO_SHELL_PACKAGE_MANAGER_H_ | 6 #define MOJO_SHELL_PACKAGE_MANAGER_H_ |
7 | 7 |
8 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 8 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
9 #include "mojo/shell/fetcher.h" | 9 #include "mojo/shell/fetcher.h" |
10 | 10 |
11 class GURL; | 11 class GURL; |
12 | 12 |
13 namespace mojo { | 13 namespace mojo { |
14 namespace shell { | 14 namespace shell { |
15 | 15 |
16 class ApplicationManager; | 16 class ApplicationManager; |
17 | 17 |
18 // A class implementing this interface assists Shell::ConnectToApplication in | 18 // A class implementing this interface assists Shell::ConnectToApplication in |
19 // fetching the applications located therein. | 19 // resolving URLs and fetching the applications located therein. |
20 class PackageManager { | 20 class PackageManager { |
21 public: | 21 public: |
22 PackageManager() {} | 22 PackageManager() {} |
23 virtual ~PackageManager() {} | 23 virtual ~PackageManager() {} |
24 | 24 |
25 // Called once, during initialization, to tell the package manager about the | 25 // Called once, during initialization, to tell the package manager about the |
26 // associated ApplicationManager. | 26 // associated ApplicationManager. |
27 virtual void SetApplicationManager(ApplicationManager* manager) = 0; | 27 virtual void SetApplicationManager(ApplicationManager* manager) = 0; |
28 | 28 |
29 // Asks the delegate to fetch the specified url. | 29 // Resolves |url| to its canonical form. e.g. for mojo: urls, returns a file: |
| 30 // url with a path ending in .mojo. |
| 31 virtual GURL ResolveURL(const GURL& url) = 0; |
| 32 |
| 33 // Asks the delegate to fetch the specified url. |url| must be unresolved, |
| 34 // i.e. ResolveURL() above must not have been called on it. |
30 // TODO(beng): figure out how not to expose Fetcher at all at this layer. | 35 // TODO(beng): figure out how not to expose Fetcher at all at this layer. |
31 virtual void FetchRequest( | 36 virtual void FetchRequest( |
32 URLRequestPtr request, | 37 URLRequestPtr request, |
33 const Fetcher::FetchCallback& loader_callback) = 0; | 38 const Fetcher::FetchCallback& loader_callback) = 0; |
34 | 39 |
35 // Determine if a content handler should handle the response received by | 40 // Determine if a content handler should handle the response received by |
36 // |fetcher|. | 41 // |fetcher|. |
37 // |url| is the url requested initially by a call to ConnectToApplication(). | 42 // |unresolved_url| is the url requested initially by a call to |
| 43 // Shell::ConnectToApplication() before any resolution is applied. |
38 // |task_runner| is a base::TaskRunner* that can be used to post callbacks. | 44 // |task_runner| is a base::TaskRunner* that can be used to post callbacks. |
39 // |new_response| is the response that should be passed to | 45 // |new_response| is the response that should be passed to |
40 // ContentHandler::StartApplication(), unchanged if the return value is false. | 46 // ContentHandler::StartApplication(), unchanged if the return value is false. |
41 // |content_handler_url| is the url of the content handler application to | 47 // |content_handler_url| is the url of the content handler application to |
42 // run, unchanged if the return value is false. | 48 // run, unchanged if the return value is false. |
43 // |qualifier| is the Identity qualifier that the content handler application | 49 // |qualifier| is the Identity qualifier that the content handler application |
44 // instance should be associated with, unchanged if the return value is false. | 50 // instance should be associated with, unchanged if the return value is false. |
45 virtual bool HandleWithContentHandler(Fetcher* fetcher, | 51 virtual bool HandleWithContentHandler(Fetcher* fetcher, |
46 const GURL& url, | 52 const GURL& unresolved_url, |
47 base::TaskRunner* task_runner, | 53 base::TaskRunner* task_runner, |
48 URLResponsePtr* new_response, | 54 URLResponsePtr* new_response, |
49 GURL* content_handler_url, | 55 GURL* content_handler_url, |
50 std::string* qualifier) = 0; | 56 std::string* qualifier) = 0; |
51 }; | 57 }; |
52 | 58 |
53 } // namespace shell | 59 } // namespace shell |
54 } // namespace mojo | 60 } // namespace mojo |
55 | 61 |
56 #endif // MOJO_SHELL_PACKAGE_MANAGER_H_ | 62 #endif // MOJO_SHELL_PACKAGE_MANAGER_H_ |
OLD | NEW |