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 // resolving URLs and fetching the applications located therein. | 19 // 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 // Resolves |url| to its canonical form. e.g. for mojo: urls, returns a file: | 29 // Asks the delegate to fetch the specified url. |
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. | |
35 // TODO(beng): figure out how not to expose Fetcher at all at this layer. | 30 // TODO(beng): figure out how not to expose Fetcher at all at this layer. |
36 virtual void FetchRequest( | 31 virtual void FetchRequest( |
37 URLRequestPtr request, | 32 URLRequestPtr request, |
38 const Fetcher::FetchCallback& loader_callback) = 0; | 33 const Fetcher::FetchCallback& loader_callback) = 0; |
39 | 34 |
40 // Determine if a content handler should handle the response received by | 35 // Determine if a content handler should handle the response received by |
41 // |fetcher|. | 36 // |fetcher|. |
42 // |unresolved_url| is the url requested initially by a call to | 37 // |url| is the url requested initially by a call to ConnectToApplication(). |
43 // Shell::ConnectToApplication() before any resolution is applied. | |
44 // |task_runner| is a base::TaskRunner* that can be used to post callbacks. | 38 // |task_runner| is a base::TaskRunner* that can be used to post callbacks. |
45 // |new_response| is the response that should be passed to | 39 // |new_response| is the response that should be passed to |
46 // ContentHandler::StartApplication(), unchanged if the return value is false. | 40 // ContentHandler::StartApplication(), unchanged if the return value is false. |
47 // |content_handler_url| is the url of the content handler application to | 41 // |content_handler_url| is the url of the content handler application to |
48 // run, unchanged if the return value is false. | 42 // run, unchanged if the return value is false. |
49 // |qualifier| is the Identity qualifier that the content handler application | 43 // |qualifier| is the Identity qualifier that the content handler application |
50 // instance should be associated with, unchanged if the return value is false. | 44 // instance should be associated with, unchanged if the return value is false. |
51 virtual bool HandleWithContentHandler(Fetcher* fetcher, | 45 virtual bool HandleWithContentHandler(Fetcher* fetcher, |
52 const GURL& unresolved_url, | 46 const GURL& url, |
53 base::TaskRunner* task_runner, | 47 base::TaskRunner* task_runner, |
54 URLResponsePtr* new_response, | 48 URLResponsePtr* new_response, |
55 GURL* content_handler_url, | 49 GURL* content_handler_url, |
56 std::string* qualifier) = 0; | 50 std::string* qualifier) = 0; |
57 }; | 51 }; |
58 | 52 |
59 } // namespace shell | 53 } // namespace shell |
60 } // namespace mojo | 54 } // namespace mojo |
61 | 55 |
62 #endif // MOJO_SHELL_PACKAGE_MANAGER_H_ | 56 #endif // MOJO_SHELL_PACKAGE_MANAGER_H_ |
OLD | NEW |