Chromium Code Reviews| 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 MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 5 #ifndef MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
| 6 #define MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 6 #define MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "mojo/application_manager/application_manager_export.h" | 9 #include "mojo/application_manager/application_manager_export.h" |
| 10 #include "mojo/public/cpp/system/core.h" | 10 #include "mojo/public/cpp/system/core.h" |
| 11 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" | 11 #include "mojo/services/public/interfaces/network/url_loader.mojom.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace mojo { | 14 namespace mojo { |
| 15 | 15 |
| 16 class ApplicationManager; | 16 class ApplicationManager; |
| 17 | 17 |
| 18 // Interface to allowing loading behavior to be established for schemes, | 18 // Interface to allowing loading behavior to be established for schemes, |
| 19 // specific urls or as the default. | 19 // specific urls or as the default. |
| 20 // A ApplicationLoader is responsible to using whatever mechanism is appropriate | 20 // A ApplicationLoader is responsible to using whatever mechanism is appropriate |
| 21 // to load the application at url. | 21 // to load the application at url. |
| 22 // The handle to the shell is passed to that application so it can bind it to | 22 // The handle to the shell is passed to that application so it can bind it to |
| 23 // a Shell instance. This will give the Application a way to connect to other | 23 // a Shell instance. This will give the Application a way to connect to other |
| 24 // apps and services. | 24 // apps and services. |
| 25 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { | 25 class MOJO_APPLICATION_MANAGER_EXPORT ApplicationLoader { |
| 26 public: | 26 public: |
| 27 class MOJO_APPLICATION_MANAGER_EXPORT LoadCallbacks | 27 class MOJO_APPLICATION_MANAGER_EXPORT LoadCallbacks |
|
Aaron Boodman
2014/11/18 23:46:15
We don't need LoadCallbacks anymore. We can just u
qsr
2014/11/19 13:42:37
Done.
| |
| 28 : public base::RefCounted<LoadCallbacks> { | 28 : public base::RefCounted<LoadCallbacks> { |
| 29 public: | 29 public: |
| 30 // Register the requested application with ApplicationManager. If the | |
| 31 // returned handle is valid, it should be used to implement the | |
| 32 // mojo::Application interface. | |
| 33 virtual ScopedMessagePipeHandle RegisterApplication() = 0; | |
| 34 | |
| 35 // Load the requested application with a content handler. | 30 // Load the requested application with a content handler. |
| 36 virtual void LoadWithContentHandler(const GURL& content_handler_url, | 31 virtual void LoadWithContentHandler(const GURL& content_handler_url, |
| 32 ScopedMessagePipeHandle shell_handle, | |
| 37 URLResponsePtr url_response) = 0; | 33 URLResponsePtr url_response) = 0; |
|
DaveMoore
2014/11/18 17:00:45
I like this. It's a lot more like ApplicationLoade
| |
| 38 | 34 |
| 39 protected: | 35 protected: |
| 40 friend base::RefCounted<LoadCallbacks>; | 36 friend base::RefCounted<LoadCallbacks>; |
| 41 virtual ~LoadCallbacks() {} | 37 virtual ~LoadCallbacks() {} |
| 42 }; | 38 }; |
| 43 | 39 |
| 44 // Implements RegisterApplication() by returning a handle that was specified | |
| 45 // at construction time. LoadWithContentHandler() is not supported. | |
| 46 class MOJO_APPLICATION_MANAGER_EXPORT SimpleLoadCallbacks | |
| 47 : public LoadCallbacks { | |
| 48 public: | |
| 49 SimpleLoadCallbacks(ScopedMessagePipeHandle shell_handle); | |
| 50 ScopedMessagePipeHandle RegisterApplication() override; | |
| 51 void LoadWithContentHandler(const GURL& content_handler_url, | |
| 52 URLResponsePtr response) override; | |
| 53 | |
| 54 private: | |
| 55 ScopedMessagePipeHandle shell_handle_; | |
| 56 ~SimpleLoadCallbacks() override; | |
| 57 }; | |
| 58 | |
| 59 virtual ~ApplicationLoader() {} | 40 virtual ~ApplicationLoader() {} |
| 60 | 41 |
| 61 // Load the application named |url|. Applications can be loaded two ways: | 42 // Load the application named |url|. Applications can be loaded two ways: |
| 62 // | 43 // |
| 63 // 1. |url| can refer directly to a Mojo application. In this case, call | 44 // 1. |url| can refer directly to a Mojo application. In this case, call |
| 64 // callbacks->RegisterApplication(). The returned handle should be used to | 45 // callbacks->RegisterApplication(). The returned handle should be used to |
| 65 // implement the mojo.Application interface. Note that the returned handle | 46 // implement the mojo.Application interface. Note that the returned handle |
| 66 // can be invalid in the case where the application has already been | 47 // can be invalid in the case where the application has already been |
| 67 // loaded. | 48 // loaded. |
| 68 // | 49 // |
| 69 // 2. |url| can refer to some content that can be handled by some other Mojo | 50 // 2. |url| can refer to some content that can be handled by some other Mojo |
| 70 // application. In this case, call callbacks->LoadWithContentHandler() and | 51 // application. In this case, call callbacks->LoadWithContentHandler() and |
| 71 // specify the URL of the application that should handle the content. | 52 // specify the URL of the application that should handle the content. |
| 72 // The specified application must implement the mojo.ContentHandler | 53 // The specified application must implement the mojo.ContentHandler |
| 73 // interface. | 54 // interface. |
| 74 virtual void Load(ApplicationManager* application_manager, | 55 virtual void Load(ApplicationManager* application_manager, |
| 75 const GURL& url, | 56 const GURL& url, |
| 57 ScopedMessagePipeHandle shell_handle, | |
| 76 scoped_refptr<LoadCallbacks> callbacks) = 0; | 58 scoped_refptr<LoadCallbacks> callbacks) = 0; |
| 77 | 59 |
| 78 // Called when the Application exits. | 60 // Called when the Application exits. |
| 79 virtual void OnApplicationError(ApplicationManager* manager, | 61 virtual void OnApplicationError(ApplicationManager* manager, |
| 80 const GURL& url) = 0; | 62 const GURL& url) = 0; |
| 81 | 63 |
| 82 protected: | 64 protected: |
| 83 ApplicationLoader() {} | 65 ApplicationLoader() {} |
| 84 }; | 66 }; |
| 85 | 67 |
| 86 } // namespace mojo | 68 } // namespace mojo |
| 87 | 69 |
| 88 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ | 70 #endif // MOJO_APPLICATION_MANAGER_APPLICATION_LOADER_H_ |
| OLD | NEW |