OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ |
| 6 #define MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ |
| 7 |
| 8 #include "base/files/file_path.h" |
| 9 #include "mojo/fetcher/url_resolver.h" |
| 10 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 11 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
| 12 #include "mojo/shell/package_manager.h" |
| 13 |
| 14 namespace mojo { |
| 15 namespace shell { |
| 16 class Fetcher; |
| 17 } |
| 18 namespace package_manager { |
| 19 |
| 20 // This is the default implementation of shell::PackageManager. It loads |
| 21 // http/s urls off the network as well as providing special handling for mojo: |
| 22 // and about: urls. |
| 23 class PackageManagerImpl : public shell::PackageManager { |
| 24 public: |
| 25 // mojo: urls are only supported if |shell_file_root| is non-empty. |
| 26 explicit PackageManagerImpl(const base::FilePath& shell_file_root); |
| 27 ~PackageManagerImpl() override; |
| 28 |
| 29 // Register a content handler to handle content of |mime_type|. |
| 30 void RegisterContentHandler(const std::string& mime_type, |
| 31 const GURL& content_handler_url); |
| 32 |
| 33 // Registers a package alias. When attempting to load |alias|, it will |
| 34 // instead redirect to |content_handler_package|, which is a content handler |
| 35 // which will be passed the |alias| as the URLResponse::url. Different values |
| 36 // of |alias| with the same |qualifier| that are in the same |
| 37 // |content_handler_package| will run in the same process in multi-process |
| 38 // mode. |
| 39 void RegisterApplicationPackageAlias( |
| 40 const GURL& alias, |
| 41 const GURL& content_handler_package, |
| 42 const std::string& qualifier); |
| 43 |
| 44 private: |
| 45 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; |
| 46 using MimeTypeToURLMap = std::map<std::string, GURL>; |
| 47 |
| 48 // Overridden from shell::PackageManager: |
| 49 void SetApplicationManager(shell::ApplicationManager* manager) override; |
| 50 GURL ResolveURL(const GURL& url) override; |
| 51 void FetchRequest( |
| 52 URLRequestPtr request, |
| 53 const shell::Fetcher::FetchCallback& loader_callback) override; |
| 54 bool HandleWithContentHandler(shell::Fetcher* fetcher, |
| 55 const GURL& unresolved_url, |
| 56 base::TaskRunner* task_runner, |
| 57 URLResponsePtr* new_response, |
| 58 GURL* content_handler_url, |
| 59 std::string* qualifier) override; |
| 60 |
| 61 |
| 62 shell::ApplicationManager* application_manager_; |
| 63 scoped_ptr<fetcher::URLResolver> url_resolver_; |
| 64 const bool disable_cache_; |
| 65 NetworkServicePtr network_service_; |
| 66 URLLoaderFactoryPtr url_loader_factory_; |
| 67 ApplicationPackagedAlias application_package_alias_; |
| 68 MimeTypeToURLMap mime_type_to_url_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(PackageManagerImpl); |
| 71 }; |
| 72 |
| 73 } // namespace package_manager |
| 74 } // namespace mojo |
| 75 |
| 76 #endif // MOJO_PACKAGE_MANAGER_PACKAGE_MANAGER_IMPL_H_ |
OLD | NEW |