Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1614)

Side by Side Diff: components/html_viewer/html_document.h

Issue 1677293002: Bye bye Mandoline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/html_viewer/global_state.cc ('k') | components/html_viewer/html_document.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_
6 #define COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_
7
8 #include <set>
9
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/scoped_vector.h"
14 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h "
15 #include "components/html_viewer/ax_provider_impl.h"
16 #include "components/html_viewer/html_frame_delegate.h"
17 #include "components/html_viewer/public/interfaces/test_html_viewer.mojom.h"
18 #include "components/mus/public/cpp/window_tree_delegate.h"
19 #include "components/web_view/public/interfaces/frame.mojom.h"
20 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
21 #include "mojo/shell/public/cpp/app_lifetime_helper.h"
22 #include "mojo/shell/public/cpp/interface_factory.h"
23 #include "mojo/shell/public/interfaces/application.mojom.h"
24
25 namespace base {
26 class SingleThreadTaskRunner;
27 }
28
29 namespace mus {
30 class Window;
31 class WindowTreeConnection;
32 }
33
34 namespace html_viewer {
35
36 class AxProviderImpl;
37 class DocumentResourceWaiter;
38 class GlobalState;
39 class HTMLFactory;
40 class HTMLFrame;
41 class TestHTMLViewerImpl;
42 class WindowTreeDelegateImpl;
43 class WebLayerTreeViewImpl;
44
45 // A window for a single HTML document.
46 //
47 // HTMLDocument is deleted in one of two ways:
48 // . When the Window the HTMLDocument is embedded in is destroyed.
49 // . Explicitly by way of Destroy().
50 class HTMLDocument
51 : public mus::WindowTreeDelegate,
52 public HTMLFrameDelegate,
53 public mojo::InterfaceFactory<mojo::AxProvider>,
54 public mojo::InterfaceFactory<web_view::mojom::FrameClient>,
55 public mojo::InterfaceFactory<TestHTMLViewer>,
56 public mojo::InterfaceFactory<devtools_service::DevToolsAgent>,
57 public mojo::InterfaceFactory<mus::mojom::WindowTreeClient> {
58 public:
59 using DeleteCallback = base::Callback<void(HTMLDocument*)>;
60
61 // Load a new HTMLDocument with |response|.
62 // |html_document_shell| is the application this app was created in, and
63 // |connection| the specific connection triggering this new instance.
64 // |setup| is used to obtain init type state (such as resources).
65 HTMLDocument(mojo::Shell* html_document_shell,
66 mojo::Connection* connection,
67 mojo::URLResponsePtr response,
68 GlobalState* setup,
69 const DeleteCallback& delete_callback,
70 HTMLFactory* factory);
71
72 // Deletes this object.
73 void Destroy();
74
75 private:
76 friend class DocumentResourceWaiter; // So it can call Load().
77
78 // Requests for interfaces before the document is loaded go here. Once
79 // loaded the requests are bound and BeforeLoadCache is deleted.
80 struct BeforeLoadCache {
81 BeforeLoadCache();
82 ~BeforeLoadCache();
83
84 std::set<mojo::InterfaceRequest<mojo::AxProvider>*> ax_provider_requests;
85 std::set<mojo::InterfaceRequest<TestHTMLViewer>*> test_interface_requests;
86 };
87
88 // Any state that needs to be moved when rendering transfers from one frame
89 // to another is stored here.
90 struct TransferableState {
91 TransferableState();
92 ~TransferableState();
93
94 // Takes the state from |other|.
95 void Move(TransferableState* other);
96
97 bool owns_window_tree_connection;
98 mus::Window* root;
99 scoped_ptr<WindowTreeDelegateImpl> window_tree_delegate_impl;
100 };
101
102 ~HTMLDocument() override;
103
104 void Load();
105
106 BeforeLoadCache* GetBeforeLoadCache();
107
108 // WindowTreeDelegate:
109 void OnEmbed(mus::Window* root) override;
110 void OnConnectionLost(mus::WindowTreeConnection* connection) override;
111
112 // HTMLFrameDelegate:
113 mojo::Shell* GetShell() override;
114 HTMLFactory* GetHTMLFactory() override;
115 void OnFrameDidFinishLoad() override;
116 void OnFrameSwappedToRemote() override;
117 void OnSwap(HTMLFrame* frame, HTMLFrameDelegate* old_delegate) override;
118 void OnFrameDestroyed() override;
119
120 // mojo::InterfaceFactory<mojo::AxProvider>:
121 void Create(mojo::Connection* connection,
122 mojo::InterfaceRequest<mojo::AxProvider> request) override;
123
124 // mojo::InterfaceFactory<web_view::mojom::FrameClient>:
125 void Create(
126 mojo::Connection* connection,
127 mojo::InterfaceRequest<web_view::mojom::FrameClient> request) override;
128
129 // mojo::InterfaceFactory<TestHTMLViewer>:
130 void Create(mojo::Connection* connection,
131 mojo::InterfaceRequest<TestHTMLViewer> request) override;
132
133 // mojo::InterfaceFactory<devtools_service::DevToolsAgent>:
134 void Create(
135 mojo::Connection* connection,
136 mojo::InterfaceRequest<devtools_service::DevToolsAgent> request) override;
137
138 // mojo::InterfaceFactory<mus::WindowTreeClient>:
139 void Create(
140 mojo::Connection* connection,
141 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override;
142
143 scoped_ptr<mojo::AppRefCount> app_refcount_;
144 mojo::Shell* html_document_shell_;
145 mojo::Connection* connection_;
146
147 // HTMLDocument owns these pointers; binding requests after document load.
148 std::set<AxProviderImpl*> ax_providers_;
149
150 ScopedVector<TestHTMLViewerImpl> test_html_viewers_;
151
152 // Set to true when the local frame has finished loading.
153 bool did_finish_local_frame_load_ = false;
154
155 GlobalState* global_state_;
156
157 HTMLFrame* frame_;
158
159 scoped_ptr<DocumentResourceWaiter> resource_waiter_;
160
161 scoped_ptr<BeforeLoadCache> before_load_cache_;
162
163 DeleteCallback delete_callback_;
164
165 HTMLFactory* factory_;
166
167 TransferableState transferable_state_;
168
169 // Cache interface request of DevToolsAgent if |frame_| hasn't been
170 // initialized.
171 mojo::InterfaceRequest<devtools_service::DevToolsAgent>
172 devtools_agent_request_;
173
174 DISALLOW_COPY_AND_ASSIGN(HTMLDocument);
175 };
176
177 } // namespace html_viewer
178
179 #endif // COMPONENTS_HTML_VIEWER_HTML_DOCUMENT_H_
OLDNEW
« no previous file with comments | « components/html_viewer/global_state.cc ('k') | components/html_viewer/html_document.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698