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_SHELL_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_FACTORY_H_ |
6 #define MOJO_SHELL_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_FACTORY_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" | 10 #include "mojo/services/network/public/interfaces/url_loader.mojom.h" |
11 #include "mojo/shell/public/cpp/interface_factory.h" | 11 #include "mojo/shell/public/cpp/interface_factory.h" |
12 #include "mojo/shell/public/interfaces/content_handler.mojom.h" | |
13 #include "mojo/shell/public/interfaces/shell.mojom.h" | 12 #include "mojo/shell/public/interfaces/shell.mojom.h" |
| 13 #include "mojo/shell/public/interfaces/shell_client_factory.mojom.h" |
| 14 |
| 15 class GURL; |
14 | 16 |
15 namespace mojo { | 17 namespace mojo { |
16 | 18 |
17 class ContentHandlerFactory | 19 class ShellClientFactory |
18 : public InterfaceFactory<shell::mojom::ContentHandler> { | 20 : public InterfaceFactory<shell::mojom::ShellClientFactory> { |
19 public: | 21 public: |
20 class HandledApplicationHolder { | 22 class HandledApplicationHolder { |
21 public: | 23 public: |
22 virtual ~HandledApplicationHolder() {} | 24 virtual ~HandledApplicationHolder() {} |
23 }; | 25 }; |
24 | 26 |
25 class Delegate { | 27 class Delegate { |
26 public: | 28 public: |
27 virtual ~Delegate() {} | 29 virtual ~Delegate() {} |
28 // Implement this method to create the Application. This method will be | 30 // Implement this method to create the Application. This method will be |
29 // called on a new thread. Leaving this method will quit the application. | 31 // called on a new thread. Leaving this method will quit the application. |
30 virtual void RunApplication( | 32 virtual void CreateShellClient( |
31 InterfaceRequest<shell::mojom::ShellClient> request, | 33 shell::mojom::ShellClientRequest request, |
32 URLResponsePtr response) = 0; | 34 const GURL& url) = 0; |
33 }; | 35 }; |
34 | 36 |
35 class ManagedDelegate : public Delegate { | 37 class ManagedDelegate : public Delegate { |
36 public: | 38 public: |
37 ~ManagedDelegate() override {} | 39 ~ManagedDelegate() override {} |
38 // Implement this method to create the Application for the given content. | 40 // Implement this method to create the Application for the given content. |
39 // This method will be called on a new thread. The application will be run | 41 // This method will be called on a new thread. The application will be run |
40 // on this new thread, and the returned value will be kept alive until the | 42 // on this new thread, and the returned value will be kept alive until the |
41 // application ends. | 43 // application ends. |
42 virtual scoped_ptr<HandledApplicationHolder> CreateApplication( | 44 virtual scoped_ptr<HandledApplicationHolder> CreateShellClientManaged( |
43 InterfaceRequest<shell::mojom::ShellClient> request, | 45 shell::mojom::ShellClientRequest request, |
44 URLResponsePtr response) = 0; | 46 const GURL& url) = 0; |
45 | 47 |
46 private: | 48 private: |
47 void RunApplication(InterfaceRequest<shell::mojom::ShellClient> request, | 49 void CreateShellClient(shell::mojom::ShellClientRequest request, |
48 URLResponsePtr response) override; | 50 const GURL& url) override; |
49 }; | 51 }; |
50 | 52 |
51 explicit ContentHandlerFactory(Delegate* delegate); | 53 explicit ShellClientFactory(Delegate* delegate); |
52 ~ContentHandlerFactory() override; | 54 ~ShellClientFactory() override; |
53 | 55 |
54 private: | 56 private: |
55 // From InterfaceFactory: | 57 // InterfaceFactory<shell::mojom::ShellClientFactory>: |
56 void Create(Connection* connection, | 58 void Create(Connection* connection, |
57 InterfaceRequest<shell::mojom::ContentHandler> request) override; | 59 shell::mojom::ShellClientFactoryRequest request) override; |
58 | 60 |
59 Delegate* delegate_; | 61 Delegate* delegate_; |
60 | 62 |
61 DISALLOW_COPY_AND_ASSIGN(ContentHandlerFactory); | 63 DISALLOW_COPY_AND_ASSIGN(ShellClientFactory); |
62 }; | 64 }; |
63 | 65 |
64 template <class A> | 66 template <class A> |
65 class HandledApplicationHolderImpl | 67 class HandledApplicationHolderImpl |
66 : public ContentHandlerFactory::HandledApplicationHolder { | 68 : public ShellClientFactory::HandledApplicationHolder { |
67 public: | 69 public: |
68 explicit HandledApplicationHolderImpl(A* value) : value_(value) {} | 70 explicit HandledApplicationHolderImpl(A* value) : value_(value) {} |
69 | 71 |
70 private: | 72 private: |
71 scoped_ptr<A> value_; | 73 scoped_ptr<A> value_; |
72 }; | 74 }; |
73 | 75 |
74 template <class A> | 76 template <class A> |
75 scoped_ptr<ContentHandlerFactory::HandledApplicationHolder> | 77 scoped_ptr<ShellClientFactory::HandledApplicationHolder> |
76 make_handled_factory_holder(A* value) { | 78 make_handled_factory_holder(A* value) { |
77 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value)); | 79 return make_scoped_ptr(new HandledApplicationHolderImpl<A>(value)); |
78 } | 80 } |
79 | 81 |
80 } // namespace mojo | 82 } // namespace mojo |
81 | 83 |
82 #endif // MOJO_SHELL_PUBLIC_CPP_CONTENT_HANDLER_FACTORY_H_ | 84 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CLIENT_FACTORY_H_ |
OLD | NEW |