OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ | 5 #ifndef COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ |
6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ | 6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
| 10 #include "base/callback.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "components/html_viewer/html_document.h" |
12 #include "mojo/application/public/cpp/application_delegate.h" | 14 #include "mojo/application/public/cpp/application_delegate.h" |
13 #include "mojo/application/public/cpp/application_impl.h" | 15 #include "mojo/application/public/cpp/application_impl.h" |
14 #include "mojo/services/network/public/interfaces/network_service.mojom.h" | 16 #include "mojo/services/network/public/interfaces/network_service.mojom.h" |
15 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" | 17 #include "mojo/services/network/public/interfaces/url_loader_factory.mojom.h" |
16 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" | 18 #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" |
17 | 19 |
18 namespace html_viewer { | 20 namespace html_viewer { |
19 | 21 |
20 class GlobalState; | 22 class GlobalState; |
21 class HTMLDocument; | |
22 class HTMLDocumentOOPIF; | 23 class HTMLDocumentOOPIF; |
23 | 24 |
24 // ApplicationDelegate created by the content handler for a specific url. | 25 // ApplicationDelegate created by the content handler for a specific url. |
25 class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate { | 26 class HTMLDocumentApplicationDelegate : public mojo::ApplicationDelegate { |
26 public: | 27 public: |
27 HTMLDocumentApplicationDelegate( | 28 HTMLDocumentApplicationDelegate( |
28 mojo::InterfaceRequest<mojo::Application> request, | 29 mojo::InterfaceRequest<mojo::Application> request, |
29 mojo::URLResponsePtr response, | 30 mojo::URLResponsePtr response, |
30 GlobalState* global_state, | 31 GlobalState* global_state, |
31 scoped_ptr<mojo::AppRefCount> parent_app_refcount); | 32 scoped_ptr<mojo::AppRefCount> parent_app_refcount); |
32 | 33 |
| 34 typedef base::Callback<HTMLDocument*(HTMLDocument::CreateParams*)> |
| 35 HTMLDocumentCreationCallback; |
| 36 |
| 37 void SetHTMLDocumentCreationCallback( |
| 38 const HTMLDocumentCreationCallback& callback); |
| 39 |
33 private: | 40 private: |
34 class ServiceConnectorQueue; | 41 class ServiceConnectorQueue; |
35 | 42 |
36 ~HTMLDocumentApplicationDelegate() override; | 43 ~HTMLDocumentApplicationDelegate() override; |
37 | 44 |
38 // Callback from the quit closure. We key off this rather than | 45 // Callback from the quit closure. We key off this rather than |
39 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop | 46 // ApplicationDelegate::Quit() as we don't want to shut down the messageloop |
40 // when we quit (the messageloop is shared among multiple | 47 // when we quit (the messageloop is shared among multiple |
41 // HTMLDocumentApplicationDelegates). | 48 // HTMLDocumentApplicationDelegates). |
42 void OnTerminate(); | 49 void OnTerminate(); |
(...skipping 20 matching lines...) Expand all Loading... |
63 GlobalState* global_state_; | 70 GlobalState* global_state_; |
64 | 71 |
65 // As we create HTMLDocuments they are added here. They are removed when the | 72 // As we create HTMLDocuments they are added here. They are removed when the |
66 // HTMLDocument is deleted. | 73 // HTMLDocument is deleted. |
67 std::set<HTMLDocument*> documents_; | 74 std::set<HTMLDocument*> documents_; |
68 | 75 |
69 // As we create HTMLDocuments they are added here. They are removed when the | 76 // As we create HTMLDocuments they are added here. They are removed when the |
70 // HTMLDocument is deleted. | 77 // HTMLDocument is deleted. |
71 std::set<HTMLDocumentOOPIF*> documents2_; | 78 std::set<HTMLDocumentOOPIF*> documents2_; |
72 | 79 |
| 80 HTMLDocumentCreationCallback html_document_creation_callback_; |
| 81 |
73 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentApplicationDelegate); | 82 DISALLOW_COPY_AND_ASSIGN(HTMLDocumentApplicationDelegate); |
74 }; | 83 }; |
75 | 84 |
76 } // namespace html_viewer | 85 } // namespace html_viewer |
77 | 86 |
78 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ | 87 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_APPLICATION_DELEGATE_H_ |
OLD | NEW |