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