| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 #include "mojo/public/interfaces/application/application.mojom.h" | 15 #include "mojo/public/interfaces/application/application.mojom.h" |
| 16 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 16 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 17 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 18 #include "mojo/shell/application_loader.h" | 18 #include "mojo/shell/application_loader.h" |
| 19 #include "mojo/shell/fetcher.h" |
| 19 #include "mojo/shell/identity.h" | 20 #include "mojo/shell/identity.h" |
| 20 #include "mojo/shell/native_runner.h" | 21 #include "mojo/shell/native_runner.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| 24 class FilePath; | 25 class FilePath; |
| 25 class SequencedWorkerPool; | 26 class SequencedWorkerPool; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace mojo { | 29 namespace mojo { |
| 29 namespace shell { | 30 namespace shell { |
| 30 | 31 |
| 31 class Fetcher; | |
| 32 class ShellImpl; | 32 class ShellImpl; |
| 33 | 33 |
| 34 class ApplicationManager { | 34 class ApplicationManager { |
| 35 public: | 35 public: |
| 36 class Delegate { | 36 class Delegate { |
| 37 public: | 37 public: |
| 38 // Gives the delegate a chance to apply any mappings for the specified url. | 38 // Gives the delegate a chance to apply any mappings for the specified url. |
| 39 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). | 39 // This should not resolve 'mojo' urls, that is done by ResolveMojoURL(). |
| 40 virtual GURL ResolveMappings(const GURL& url) = 0; | 40 virtual GURL ResolveMappings(const GURL& url) = 0; |
| 41 | 41 |
| 42 // Used to map a url with the scheme 'mojo' to the appropriate url. Return | 42 // Used to map a url with the scheme 'mojo' to the appropriate url. Return |
| 43 // |url| if the scheme is not 'mojo'. | 43 // |url| if the scheme is not 'mojo'. |
| 44 virtual GURL ResolveMojoURL(const GURL& url) = 0; | 44 virtual GURL ResolveMojoURL(const GURL& url) = 0; |
| 45 | 45 |
| 46 // Asks the delegate to create a Fetcher for the specified url. Return |
| 47 // true on success, false if the default fetcher should be created. |
| 48 virtual bool CreateFetcher( |
| 49 const GURL& url, |
| 50 const Fetcher::FetchCallback& loader_callback) = 0; |
| 51 |
| 46 protected: | 52 protected: |
| 47 virtual ~Delegate() {} | 53 virtual ~Delegate() {} |
| 48 }; | 54 }; |
| 49 | 55 |
| 50 // API for testing. | 56 // API for testing. |
| 51 class TestAPI { | 57 class TestAPI { |
| 52 public: | 58 public: |
| 53 explicit TestAPI(ApplicationManager* manager); | 59 explicit TestAPI(ApplicationManager* manager); |
| 54 ~TestAPI(); | 60 ~TestAPI(); |
| 55 | 61 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 scoped_ptr<Fetcher> fetcher); | 209 scoped_ptr<Fetcher> fetcher); |
| 204 | 210 |
| 205 void RunNativeApplication(InterfaceRequest<Application> application_request, | 211 void RunNativeApplication(InterfaceRequest<Application> application_request, |
| 206 const NativeRunnerFactory::Options& options, | 212 const NativeRunnerFactory::Options& options, |
| 207 NativeApplicationCleanup cleanup, | 213 NativeApplicationCleanup cleanup, |
| 208 scoped_ptr<Fetcher> fetcher, | 214 scoped_ptr<Fetcher> fetcher, |
| 209 const base::FilePath& file_path, | 215 const base::FilePath& file_path, |
| 210 bool path_exists); | 216 bool path_exists); |
| 211 | 217 |
| 212 void LoadWithContentHandler(const GURL& content_handler_url, | 218 void LoadWithContentHandler(const GURL& content_handler_url, |
| 219 const GURL& requestor_url, |
| 213 const std::string& qualifier, | 220 const std::string& qualifier, |
| 214 InterfaceRequest<Application> application_request, | 221 InterfaceRequest<Application> application_request, |
| 215 URLResponsePtr url_response); | 222 URLResponsePtr url_response); |
| 216 | 223 |
| 217 // Returns the appropriate loader for |url|, or null if there is no loader | 224 // Returns the appropriate loader for |url|, or null if there is no loader |
| 218 // configured for the URL. | 225 // configured for the URL. |
| 219 ApplicationLoader* GetLoaderForURL(const GURL& url); | 226 ApplicationLoader* GetLoaderForURL(const GURL& url); |
| 220 | 227 |
| 221 // Removes a ContentHandler when it encounters an error. | 228 // Removes a ContentHandler when it encounters an error. |
| 222 void OnContentHandlerError(ContentHandlerConnection* content_handler); | 229 void OnContentHandlerError(ContentHandlerConnection* content_handler); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 244 bool disable_cache_; | 251 bool disable_cache_; |
| 245 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; | 252 base::WeakPtrFactory<ApplicationManager> weak_ptr_factory_; |
| 246 | 253 |
| 247 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 254 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
| 248 }; | 255 }; |
| 249 | 256 |
| 250 } // namespace shell | 257 } // namespace shell |
| 251 } // namespace mojo | 258 } // namespace mojo |
| 252 | 259 |
| 253 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 260 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| OLD | NEW |