| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "mojo/public/cpp/bindings/interface_request.h" | 16 #include "mojo/public/cpp/bindings/interface_request.h" |
| 17 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 17 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 18 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 18 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
| 19 #include "shell/application_manager/application_loader.h" | 19 #include "shell/application_manager/application_loader.h" |
| 20 #include "shell/application_manager/application_manager_export.h" | |
| 21 #include "shell/application_manager/fetcher.h" | 20 #include "shell/application_manager/fetcher.h" |
| 22 #include "shell/application_manager/shell_impl.h" | 21 #include "shell/application_manager/shell_impl.h" |
| 23 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 24 | 23 |
| 25 namespace base { | 24 namespace base { |
| 26 class FilePath; | 25 class FilePath; |
| 27 class SequencedWorkerPool; | 26 class SequencedWorkerPool; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace mojo { | 29 namespace mojo { |
| 31 | 30 |
| 32 // ApplicationManager requires implementations of NativeRunner and | 31 // ApplicationManager requires implementations of NativeRunner and |
| 33 // NativeRunnerFactory to run native applications. | 32 // NativeRunnerFactory to run native applications. |
| 34 class MOJO_APPLICATION_MANAGER_EXPORT NativeRunner { | 33 class NativeRunner { |
| 35 public: | 34 public: |
| 36 // Parameter for |Start| to specify its cleanup behavior. | 35 // Parameter for |Start()| to specify its cleanup behavior. |
| 37 enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath }; | 36 enum CleanupBehavior { DeleteAppPath, DontDeleteAppPath }; |
| 38 virtual ~NativeRunner() {} | 37 virtual ~NativeRunner() {} |
| 39 | 38 |
| 40 // Loads the app in the file at |app_path| and runs it on some other | 39 // Loads the app in the file at |app_path| and runs it on some other |
| 41 // thread/process. If |cleanup_behavior| is |true|, takes ownership of the | 40 // thread/process. If |cleanup_behavior| is |true|, takes ownership of the |
| 42 // file. |app_completed_callback| is posted (to the thread on which |Start()| | 41 // file. |app_completed_callback| is posted (to the thread on which |Start()| |
| 43 // was called) after |MojoMain()| completes. | 42 // was called) after |MojoMain()| completes. |
| 44 virtual void Start(const base::FilePath& app_path, | 43 virtual void Start(const base::FilePath& app_path, |
| 45 CleanupBehavior cleanup_behavior, | 44 CleanupBehavior cleanup_behavior, |
| 46 InterfaceRequest<Application> application_request, | 45 InterfaceRequest<Application> application_request, |
| 47 const base::Closure& app_completed_callback) = 0; | 46 const base::Closure& app_completed_callback) = 0; |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 class MOJO_APPLICATION_MANAGER_EXPORT NativeRunnerFactory { | 49 class NativeRunnerFactory { |
| 51 public: | 50 public: |
| 52 virtual ~NativeRunnerFactory() {} | 51 virtual ~NativeRunnerFactory() {} |
| 53 virtual scoped_ptr<NativeRunner> Create() = 0; | 52 virtual scoped_ptr<NativeRunner> Create() = 0; |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationManager { | 55 class ApplicationManager { |
| 57 public: | 56 public: |
| 58 class MOJO_APPLICATION_MANAGER_EXPORT Delegate { | 57 class Delegate { |
| 59 public: | 58 public: |
| 60 virtual ~Delegate(); | 59 virtual ~Delegate(); |
| 61 // Send when the Application holding the handle on the other end of the | 60 // Send when the Application holding the handle on the other end of the |
| 62 // Shell pipe goes away. | 61 // Shell pipe goes away. |
| 63 virtual void OnApplicationError(const GURL& url); | 62 virtual void OnApplicationError(const GURL& url); |
| 64 virtual GURL ResolveURL(const GURL& url); | 63 virtual GURL ResolveURL(const GURL& url); |
| 65 virtual GURL ResolveMappings(const GURL& url); | 64 virtual GURL ResolveMappings(const GURL& url); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 // API for testing. | 67 // API for testing. |
| 69 class MOJO_APPLICATION_MANAGER_EXPORT TestAPI { | 68 class TestAPI { |
| 70 public: | 69 public: |
| 71 explicit TestAPI(ApplicationManager* manager); | 70 explicit TestAPI(ApplicationManager* manager); |
| 72 ~TestAPI(); | 71 ~TestAPI(); |
| 73 | 72 |
| 74 // Returns true if the shared instance has been created. | 73 // Returns true if the shared instance has been created. |
| 75 static bool HasCreatedInstance(); | 74 static bool HasCreatedInstance(); |
| 76 // Returns true if there is a ShellImpl for this URL. | 75 // Returns true if there is a ShellImpl for this URL. |
| 77 bool HasFactoryForURL(const GURL& url) const; | 76 bool HasFactoryForURL(const GURL& url) const; |
| 78 | 77 |
| 79 private: | 78 private: |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 MimeTypeToURLMap mime_type_to_url_; | 229 MimeTypeToURLMap mime_type_to_url_; |
| 231 ScopedVector<NativeRunner> native_runners_; | 230 ScopedVector<NativeRunner> native_runners_; |
| 232 bool disable_cache_; | 231 bool disable_cache_; |
| 233 | 232 |
| 234 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); | 233 DISALLOW_COPY_AND_ASSIGN(ApplicationManager); |
| 235 }; | 234 }; |
| 236 | 235 |
| 237 } // namespace mojo | 236 } // namespace mojo |
| 238 | 237 |
| 239 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ | 238 #endif // SHELL_APPLICATION_MANAGER_APPLICATION_MANAGER_H_ |
| OLD | NEW |