| 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_MANAGER_H_ | 5 #ifndef SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 6 #define SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class SequencedWorkerPool; | 27 class SequencedWorkerPool; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace shell { | 30 namespace shell { |
| 31 | 31 |
| 32 class Fetcher; | 32 class Fetcher; |
| 33 class ShellImpl; | 33 class ShellImpl; |
| 34 | 34 |
| 35 class ApplicationManager { | 35 class ApplicationManager { |
| 36 public: | 36 public: |
| 37 struct Options { |
| 38 Options() : disable_cache(false), predictable_app_filenames(false) {} |
| 39 |
| 40 bool disable_cache; |
| 41 bool predictable_app_filenames; |
| 42 }; |
| 43 |
| 37 class Delegate { | 44 class Delegate { |
| 38 public: | 45 public: |
| 39 // Gives the delegate a chance to apply any mappings for the specified url. | 46 // Gives the delegate a chance to apply any mappings for the specified url. |
| 40 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). | 47 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). |
| 41 virtual GURL ResolveMappings(const GURL& url) = 0; | 48 virtual GURL ResolveMappings(const GURL& url) = 0; |
| 42 | 49 |
| 43 // Used to map a url with the scheme 'mojo' to the appropriate url. Return | 50 // Used to map a url with the scheme 'mojo' to the appropriate url. Return |
| 44 // |url| if the scheme is not 'mojo'. | 51 // |url| if the scheme is not 'mojo'. |
| 45 virtual GURL ResolveMojoURL(const GURL& url) = 0; | 52 virtual GURL ResolveMojoURL(const GURL& url) = 0; |
| 46 | 53 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 static bool HasCreatedInstance(); | 65 static bool HasCreatedInstance(); |
| 59 // Returns true if there is a ShellImpl for this URL. | 66 // Returns true if there is a ShellImpl for this URL. |
| 60 bool HasFactoryForURL(const GURL& url) const; | 67 bool HasFactoryForURL(const GURL& url) const; |
| 61 | 68 |
| 62 private: | 69 private: |
| 63 ApplicationManager* manager_; | 70 ApplicationManager* manager_; |
| 64 | 71 |
| 65 DISALLOW_COPY_AND_ASSIGN(TestAPI); | 72 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
| 66 }; | 73 }; |
| 67 | 74 |
| 68 explicit ApplicationManager(Delegate* delegate); | 75 ApplicationManager(const Options& options, Delegate* delegate); |
| 69 ~ApplicationManager(); | 76 ~ApplicationManager(); |
| 70 | 77 |
| 71 // Loads a service if necessary and establishes a new client connection. | 78 // Loads a service if necessary and establishes a new client connection. |
| 72 void ConnectToApplication( | 79 void ConnectToApplication( |
| 73 const GURL& application_url, | 80 const GURL& application_url, |
| 74 const GURL& requestor_url, | 81 const GURL& requestor_url, |
| 75 mojo::InterfaceRequest<mojo::ServiceProvider> services, | 82 mojo::InterfaceRequest<mojo::ServiceProvider> services, |
| 76 mojo::ServiceProviderPtr exposed_services, | 83 mojo::ServiceProviderPtr exposed_services, |
| 77 const base::Closure& on_application_end); | 84 const base::Closure& on_application_end); |
| 78 | 85 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 96 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { | 103 void set_default_loader(scoped_ptr<ApplicationLoader> loader) { |
| 97 default_loader_ = loader.Pass(); | 104 default_loader_ = loader.Pass(); |
| 98 } | 105 } |
| 99 void set_native_runner_factory( | 106 void set_native_runner_factory( |
| 100 scoped_ptr<NativeRunnerFactory> runner_factory) { | 107 scoped_ptr<NativeRunnerFactory> runner_factory) { |
| 101 native_runner_factory_ = runner_factory.Pass(); | 108 native_runner_factory_ = runner_factory.Pass(); |
| 102 } | 109 } |
| 103 void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) { | 110 void set_blocking_pool(base::SequencedWorkerPool* blocking_pool) { |
| 104 blocking_pool_ = blocking_pool; | 111 blocking_pool_ = blocking_pool; |
| 105 } | 112 } |
| 106 void set_disable_cache(bool disable_cache) { disable_cache_ = disable_cache; } | |
| 107 // Sets a Loader to be used for a specific url. | 113 // Sets a Loader to be used for a specific url. |
| 108 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); | 114 void SetLoaderForURL(scoped_ptr<ApplicationLoader> loader, const GURL& url); |
| 109 // Sets a Loader to be used for a specific url scheme. | 115 // Sets a Loader to be used for a specific url scheme. |
| 110 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader, | 116 void SetLoaderForScheme(scoped_ptr<ApplicationLoader> loader, |
| 111 const std::string& scheme); | 117 const std::string& scheme); |
| 112 // These strings will be passed to the Initialize() method when an Application | 118 // These strings will be passed to the Initialize() method when an Application |
| 113 // is instantiated. | 119 // is instantiated. |
| 114 // TODO(vtl): Maybe we should store/compare resolved URLs, like | 120 // TODO(vtl): Maybe we should store/compare resolved URLs, like |
| 115 // SetNativeOptionsForURL() below? | 121 // SetNativeOptionsForURL() below? |
| 116 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url); | 122 void SetArgsForURL(const std::vector<std::string>& args, const GURL& url); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ApplicationLoader* GetLoaderForURL(const GURL& url); | 216 ApplicationLoader* GetLoaderForURL(const GURL& url); |
| 211 | 217 |
| 212 // Removes a mojo::ContentHandler when it encounters an error. | 218 // Removes a mojo::ContentHandler when it encounters an error. |
| 213 void OnContentHandlerError(ContentHandlerConnection* content_handler); | 219 void OnContentHandlerError(ContentHandlerConnection* content_handler); |
| 214 | 220 |
| 215 // Returns the arguments for the given url. | 221 // Returns the arguments for the given url. |
| 216 std::vector<std::string> GetArgsForURL(const GURL& url); | 222 std::vector<std::string> GetArgsForURL(const GURL& url); |
| 217 | 223 |
| 218 void CleanupRunner(NativeRunner* runner); | 224 void CleanupRunner(NativeRunner* runner); |
| 219 | 225 |
| 226 const Options options_; |
| 220 Delegate* const delegate_; | 227 Delegate* const delegate_; |
| 221 // Loader management. | 228 // Loader management. |
| 222 // Loaders are chosen in the order they are listed here. | 229 // Loaders are chosen in the order they are listed here. |
| 223 URLToLoaderMap url_to_loader_; | 230 URLToLoaderMap url_to_loader_; |
| 224 SchemeToLoaderMap scheme_to_loader_; | 231 SchemeToLoaderMap scheme_to_loader_; |
| 225 scoped_ptr<ApplicationLoader> default_loader_; | 232 scoped_ptr<ApplicationLoader> default_loader_; |
| 226 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 233 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
| 227 | 234 |
| 228 IdentityToShellImplMap identity_to_shell_impl_; | 235 IdentityToShellImplMap identity_to_shell_impl_; |
| 229 URLToContentHandlerMap url_to_content_handler_; | 236 URLToContentHandlerMap url_to_content_handler_; |
| 230 URLToArgsMap url_to_args_; | 237 URLToArgsMap url_to_args_; |
| 231 // Note: The keys are URLs after mapping and resolving. | 238 // Note: The keys are URLs after mapping and resolving. |
| 232 URLToNativeOptionsMap url_to_native_options_; | 239 URLToNativeOptionsMap url_to_native_options_; |
| 233 | 240 |
| 234 base::SequencedWorkerPool* blocking_pool_; | 241 base::SequencedWorkerPool* blocking_pool_; |
| 235 mojo::NetworkServicePtr network_service_; | 242 mojo::NetworkServicePtr network_service_; |
| 236 mojo::URLResponseDiskCachePtr url_response_disk_cache_; | 243 mojo::URLResponseDiskCachePtr url_response_disk_cache_; |
| 237 MimeTypeToURLMap mime_type_to_url_; | 244 MimeTypeToURLMap mime_type_to_url_; |
| 238 ScopedVector<NativeRunner> native_runners_; | 245 ScopedVector<NativeRunner> native_runners_; |
| 239 bool disable_cache_; | |
| 240 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 246 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
| 241 | 247 |
| 242 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 248 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
| 243 }; | 249 }; |
| 244 | 250 |
| 245 } // namespace shell | 251 } // namespace shell |
| 246 | 252 |
| 247 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 253 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| OLD | NEW |