| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 private: | 70 private: |
| 71 ApplicationManager* manager_; | 71 ApplicationManager* manager_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(TestAPI); | 73 DISALLOW_COPY_AND_ASSIGN(TestAPI); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 explicit ApplicationManager(Delegate* delegate); | 76 explicit ApplicationManager(Delegate* delegate); |
| 77 ~ApplicationManager(); | 77 ~ApplicationManager(); |
| 78 | 78 |
| 79 // Loads a service if necessary and establishes a new client connection. | 79 // Loads a service if necessary and establishes a new client connection. |
| 80 // |originator| can be NULL (e.g. for the first application or in tests), but |
| 81 // typically is non-NULL and identifies the instance initiating the |
| 82 // connection. |
| 80 void ConnectToApplication( | 83 void ConnectToApplication( |
| 81 mojo::URLRequestPtr requested_url, | 84 ApplicationInstance* originator, |
| 85 URLRequestPtr requested_url, |
| 82 const std::string& qualifier, | 86 const std::string& qualifier, |
| 83 const GURL& requestor_url, | 87 const GURL& requestor_url, |
| 84 InterfaceRequest<ServiceProvider> services, | 88 InterfaceRequest<ServiceProvider> services, |
| 85 ServiceProviderPtr exposed_services, | 89 ServiceProviderPtr exposed_services, |
| 90 CapabilityFilterPtr filter, |
| 86 const base::Closure& on_application_end); | 91 const base::Closure& on_application_end); |
| 87 | 92 |
| 88 | 93 // Must only be used by shell internals and test code as it does not forward |
| 94 // capability filters. |
| 89 template <typename Interface> | 95 template <typename Interface> |
| 90 inline void ConnectToService(const GURL& application_url, | 96 inline void ConnectToService(const GURL& application_url, |
| 91 InterfacePtr<Interface>* ptr) { | 97 InterfacePtr<Interface>* ptr) { |
| 92 ScopedMessagePipeHandle service_handle = | 98 ScopedMessagePipeHandle service_handle = |
| 93 ConnectToServiceByName(application_url, Interface::Name_); | 99 ConnectToServiceByName(application_url, Interface::Name_); |
| 94 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); | 100 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); |
| 95 } | 101 } |
| 96 | 102 |
| 97 ScopedMessagePipeHandle ConnectToServiceByName( | |
| 98 const GURL& application_url, | |
| 99 const std::string& interface_name); | |
| 100 | |
| 101 void RegisterContentHandler(const std::string& mime_type, | 103 void RegisterContentHandler(const std::string& mime_type, |
| 102 const GURL& content_handler_url); | 104 const GURL& content_handler_url); |
| 103 | 105 |
| 104 // Registers a package alias. When attempting to load |alias|, it will | 106 // Registers a package alias. When attempting to load |alias|, it will |
| 105 // instead redirect to |content_handler_package|, which is a content handler | 107 // instead redirect to |content_handler_package|, which is a content handler |
| 106 // which will be passed the |alias| as the URLResponse::url. Different values | 108 // which will be passed the |alias| as the URLResponse::url. Different values |
| 107 // of |alias| with the same |qualifier| that are in the same | 109 // of |alias| with the same |qualifier| that are in the same |
| 108 // |content_handler_package| will run in the same process in multi-process | 110 // |content_handler_package| will run in the same process in multi-process |
| 109 // mode. | 111 // mode. |
| 110 void RegisterApplicationPackageAlias(const GURL& alias, | 112 void RegisterApplicationPackageAlias(const GURL& alias, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; | 157 using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>; |
| 156 using IdentityToApplicationInstanceMap = | 158 using IdentityToApplicationInstanceMap = |
| 157 std::map<Identity, ApplicationInstance*>; | 159 std::map<Identity, ApplicationInstance*>; |
| 158 using MimeTypeToURLMap = std::map<std::string, GURL>; | 160 using MimeTypeToURLMap = std::map<std::string, GURL>; |
| 159 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; | 161 using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>; |
| 160 using URLToContentHandlerMap = | 162 using URLToContentHandlerMap = |
| 161 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; | 163 std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>; |
| 162 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; | 164 using URLToLoaderMap = std::map<GURL, ApplicationLoader*>; |
| 163 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; | 165 using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>; |
| 164 | 166 |
| 165 bool ConnectToRunningApplication(const GURL& resolved_url, | 167 bool ConnectToRunningApplication(ApplicationInstance* originator, |
| 168 const GURL& resolved_url, |
| 166 const std::string& qualifier, | 169 const std::string& qualifier, |
| 167 const GURL& requestor_url, | 170 const GURL& requestor_url, |
| 168 InterfaceRequest<ServiceProvider>* services, | 171 InterfaceRequest<ServiceProvider>* services, |
| 169 ServiceProviderPtr* exposed_services); | 172 ServiceProviderPtr* exposed_services, |
| 173 CapabilityFilterPtr* filter); |
| 170 | 174 |
| 171 bool ConnectToApplicationWithLoader( | 175 bool ConnectToApplicationWithLoader( |
| 176 ApplicationInstance* originator, |
| 172 const GURL& requested_url, | 177 const GURL& requested_url, |
| 173 const std::string& qualifier, | 178 const std::string& qualifier, |
| 174 const GURL& resolved_url, | 179 const GURL& resolved_url, |
| 175 const GURL& requestor_url, | 180 const GURL& requestor_url, |
| 176 InterfaceRequest<ServiceProvider>* services, | 181 InterfaceRequest<ServiceProvider>* services, |
| 177 ServiceProviderPtr* exposed_services, | 182 ServiceProviderPtr* exposed_services, |
| 183 CapabilityFilterPtr* filter, |
| 178 const base::Closure& on_application_end, | 184 const base::Closure& on_application_end, |
| 179 ApplicationLoader* loader); | 185 ApplicationLoader* loader); |
| 180 | 186 |
| 181 InterfaceRequest<Application> RegisterInstance( | 187 InterfaceRequest<Application> RegisterInstance( |
| 188 ApplicationInstance* originator, |
| 182 const GURL& app_url, | 189 const GURL& app_url, |
| 183 const std::string& qualifier, | 190 const std::string& qualifier, |
| 184 const GURL& requestor_url, | 191 const GURL& requestor_url, |
| 185 InterfaceRequest<ServiceProvider> services, | 192 InterfaceRequest<ServiceProvider> services, |
| 186 ServiceProviderPtr exposed_services, | 193 ServiceProviderPtr exposed_services, |
| 194 CapabilityFilterPtr filter, |
| 187 const base::Closure& on_application_end); | 195 const base::Closure& on_application_end); |
| 188 | 196 |
| 189 ApplicationInstance* GetApplicationInstance(const GURL& url, | 197 ApplicationInstance* GetApplicationInstance(const GURL& url, |
| 190 const std::string& qualifier); | 198 const std::string& qualifier); |
| 191 | 199 |
| 192 void ConnectToClient(ApplicationInstance* instance, | |
| 193 const GURL& resolved_url, | |
| 194 const GURL& requestor_url, | |
| 195 InterfaceRequest<ServiceProvider> services, | |
| 196 ServiceProviderPtr exposed_services); | |
| 197 | |
| 198 // Called once |fetcher| has found app. |requested_url| is the url of the | 200 // Called once |fetcher| has found app. |requested_url| is the url of the |
| 199 // requested application before any mappings/resolution have been applied. | 201 // requested application before any mappings/resolution have been applied. |
| 200 void HandleFetchCallback(const GURL& requested_url, | 202 void HandleFetchCallback(ApplicationInstance* originator, |
| 203 const GURL& requested_url, |
| 201 const std::string& qualifier, | 204 const std::string& qualifier, |
| 202 const GURL& requestor_url, | 205 const GURL& requestor_url, |
| 203 InterfaceRequest<ServiceProvider> services, | 206 InterfaceRequest<ServiceProvider> services, |
| 204 ServiceProviderPtr exposed_services, | 207 ServiceProviderPtr exposed_services, |
| 208 CapabilityFilterPtr filter, |
| 205 const base::Closure& on_application_end, | 209 const base::Closure& on_application_end, |
| 206 NativeApplicationCleanup cleanup, | 210 NativeApplicationCleanup cleanup, |
| 207 scoped_ptr<Fetcher> fetcher); | 211 scoped_ptr<Fetcher> fetcher); |
| 208 | 212 |
| 209 void RunNativeApplication(InterfaceRequest<Application> application_request, | 213 void RunNativeApplication(InterfaceRequest<Application> application_request, |
| 210 const NativeRunnerFactory::Options& options, | 214 const NativeRunnerFactory::Options& options, |
| 211 NativeApplicationCleanup cleanup, | 215 NativeApplicationCleanup cleanup, |
| 212 scoped_ptr<Fetcher> fetcher, | 216 scoped_ptr<Fetcher> fetcher, |
| 213 const base::FilePath& file_path, | 217 const base::FilePath& file_path, |
| 214 bool path_exists); | 218 bool path_exists); |
| 215 | 219 |
| 216 void LoadWithContentHandler(const GURL& content_handler_url, | 220 void LoadWithContentHandler(const GURL& content_handler_url, |
| 217 const GURL& requestor_url, | 221 const GURL& requestor_url, |
| 218 const std::string& qualifier, | 222 const std::string& qualifier, |
| 219 InterfaceRequest<Application> application_request, | 223 InterfaceRequest<Application> application_request, |
| 220 URLResponsePtr url_response); | 224 URLResponsePtr url_response); |
| 221 | 225 |
| 222 // Returns the appropriate loader for |url|, or null if there is no loader | 226 // Returns the appropriate loader for |url|, or null if there is no loader |
| 223 // configured for the URL. | 227 // configured for the URL. |
| 224 ApplicationLoader* GetLoaderForURL(const GURL& url); | 228 ApplicationLoader* GetLoaderForURL(const GURL& url); |
| 225 | 229 |
| 226 void CleanupRunner(NativeRunner* runner); | 230 void CleanupRunner(NativeRunner* runner); |
| 227 | 231 |
| 232 ScopedMessagePipeHandle ConnectToServiceByName( |
| 233 const GURL& application_url, |
| 234 const std::string& interface_name); |
| 235 |
| 228 Delegate* const delegate_; | 236 Delegate* const delegate_; |
| 229 // Loader management. | 237 // Loader management. |
| 230 // Loaders are chosen in the order they are listed here. | 238 // Loaders are chosen in the order they are listed here. |
| 231 URLToLoaderMap url_to_loader_; | 239 URLToLoaderMap url_to_loader_; |
| 232 SchemeToLoaderMap scheme_to_loader_; | 240 SchemeToLoaderMap scheme_to_loader_; |
| 233 scoped_ptr<ApplicationLoader> default_loader_; | 241 scoped_ptr<ApplicationLoader> default_loader_; |
| 234 scoped_ptr<NativeRunnerFactory> native_runner_factory_; | 242 scoped_ptr<NativeRunnerFactory> native_runner_factory_; |
| 235 | 243 |
| 236 ApplicationPackagedAlias application_package_alias_; | 244 ApplicationPackagedAlias application_package_alias_; |
| 237 IdentityToApplicationInstanceMap identity_to_instance_; | 245 IdentityToApplicationInstanceMap identity_to_instance_; |
| 238 URLToContentHandlerMap url_to_content_handler_; | 246 URLToContentHandlerMap url_to_content_handler_; |
| 239 // Note: The keys are URLs after mapping and resolving. | 247 // Note: The keys are URLs after mapping and resolving. |
| 240 URLToNativeOptionsMap url_to_native_options_; | 248 URLToNativeOptionsMap url_to_native_options_; |
| 241 | 249 |
| 242 base::SequencedWorkerPool* blocking_pool_; | 250 base::SequencedWorkerPool* blocking_pool_; |
| 243 URLLoaderFactoryPtr url_loader_factory_; | 251 URLLoaderFactoryPtr url_loader_factory_; |
| 244 updater::UpdaterPtr updater_; | 252 updater::UpdaterPtr updater_; |
| 245 MimeTypeToURLMap mime_type_to_url_; | 253 MimeTypeToURLMap mime_type_to_url_; |
| 246 ScopedVector<NativeRunner> native_runners_; | 254 ScopedVector<NativeRunner> native_runners_; |
| 247 bool disable_cache_; | 255 bool disable_cache_; |
| 248 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 256 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
| 249 | 257 |
| 250 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 258 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
| 251 }; | 259 }; |
| 252 | 260 |
| 253 } // namespace shell | 261 } // namespace shell |
| 254 } // namespace mojo | 262 } // namespace mojo |
| 255 | 263 |
| 256 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 264 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| OLD | NEW |