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 #include "components/html_viewer/html_document.h" | 5 #include "components/html_viewer/html_document.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "components/html_viewer/html_frame.h" | 21 #include "components/html_viewer/html_frame.h" |
22 #include "components/html_viewer/html_frame_tree_manager.h" | 22 #include "components/html_viewer/html_frame_tree_manager.h" |
23 #include "components/html_viewer/test_html_viewer_impl.h" | 23 #include "components/html_viewer/test_html_viewer_impl.h" |
24 #include "components/html_viewer/web_url_loader_impl.h" | 24 #include "components/html_viewer/web_url_loader_impl.h" |
25 #include "components/mus/public/cpp/window.h" | 25 #include "components/mus/public/cpp/window.h" |
26 #include "components/mus/public/cpp/window_tree_connection.h" | 26 #include "components/mus/public/cpp/window_tree_connection.h" |
27 #include "components/mus/ws/ids.h" | 27 #include "components/mus/ws/ids.h" |
28 #include "mojo/converters/geometry/geometry_type_converters.h" | 28 #include "mojo/converters/geometry/geometry_type_converters.h" |
29 #include "mojo/public/cpp/system/data_pipe.h" | 29 #include "mojo/public/cpp/system/data_pipe.h" |
30 #include "mojo/shell/public/cpp/application_impl.h" | 30 #include "mojo/shell/public/cpp/application_impl.h" |
31 #include "mojo/shell/public/cpp/connect.h" | |
32 #include "mojo/shell/public/interfaces/shell.mojom.h" | 31 #include "mojo/shell/public/interfaces/shell.mojom.h" |
33 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 32 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
34 #include "ui/gfx/geometry/dip_util.h" | 33 #include "ui/gfx/geometry/dip_util.h" |
35 #include "ui/gfx/geometry/size.h" | 34 #include "ui/gfx/geometry/size.h" |
36 | 35 |
37 using mojo::AxProvider; | 36 using mojo::AxProvider; |
38 using mus::Window; | 37 using mus::Window; |
39 | 38 |
40 namespace html_viewer { | 39 namespace html_viewer { |
41 namespace { | 40 namespace { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void HTMLDocument::TransferableState::Move(TransferableState* other) { | 87 void HTMLDocument::TransferableState::Move(TransferableState* other) { |
89 owns_window_tree_connection = other->owns_window_tree_connection; | 88 owns_window_tree_connection = other->owns_window_tree_connection; |
90 root = other->root; | 89 root = other->root; |
91 window_tree_delegate_impl = std::move(other->window_tree_delegate_impl); | 90 window_tree_delegate_impl = std::move(other->window_tree_delegate_impl); |
92 | 91 |
93 other->root = nullptr; | 92 other->root = nullptr; |
94 other->owns_window_tree_connection = false; | 93 other->owns_window_tree_connection = false; |
95 } | 94 } |
96 | 95 |
97 HTMLDocument::HTMLDocument(mojo::Shell* html_document_shell, | 96 HTMLDocument::HTMLDocument(mojo::Shell* html_document_shell, |
98 mojo::ApplicationConnection* connection, | 97 mojo::Connection* connection, |
99 mojo::URLResponsePtr response, | 98 mojo::URLResponsePtr response, |
100 GlobalState* global_state, | 99 GlobalState* global_state, |
101 const DeleteCallback& delete_callback, | 100 const DeleteCallback& delete_callback, |
102 HTMLFactory* factory) | 101 HTMLFactory* factory) |
103 : app_refcount_(html_document_shell->CreateAppRefCount()), | 102 : app_refcount_(html_document_shell->CreateAppRefCount()), |
104 html_document_shell_(html_document_shell), | 103 html_document_shell_(html_document_shell), |
105 connection_(connection), | 104 connection_(connection), |
106 global_state_(global_state), | 105 global_state_(global_state), |
107 frame_(nullptr), | 106 frame_(nullptr), |
108 delete_callback_(delete_callback), | 107 delete_callback_(delete_callback), |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 old_document->frame_ = nullptr; | 263 old_document->frame_ = nullptr; |
265 old_document->Destroy(); | 264 old_document->Destroy(); |
266 } | 265 } |
267 } | 266 } |
268 | 267 |
269 void HTMLDocument::OnFrameDestroyed() { | 268 void HTMLDocument::OnFrameDestroyed() { |
270 if (!transferable_state_.owns_window_tree_connection) | 269 if (!transferable_state_.owns_window_tree_connection) |
271 delete this; | 270 delete this; |
272 } | 271 } |
273 | 272 |
274 void HTMLDocument::Create(mojo::ApplicationConnection* connection, | 273 void HTMLDocument::Create(mojo::Connection* connection, |
275 mojo::InterfaceRequest<AxProvider> request) { | 274 mojo::InterfaceRequest<AxProvider> request) { |
276 if (!did_finish_local_frame_load_) { | 275 if (!did_finish_local_frame_load_) { |
277 // Cache AxProvider interface requests until the document finishes loading. | 276 // Cache AxProvider interface requests until the document finishes loading. |
278 auto cached_request = new mojo::InterfaceRequest<AxProvider>(); | 277 auto cached_request = new mojo::InterfaceRequest<AxProvider>(); |
279 *cached_request = std::move(request); | 278 *cached_request = std::move(request); |
280 GetBeforeLoadCache()->ax_provider_requests.insert(cached_request); | 279 GetBeforeLoadCache()->ax_provider_requests.insert(cached_request); |
281 } else { | 280 } else { |
282 ax_providers_.insert( | 281 ax_providers_.insert( |
283 new AxProviderImpl(frame_->web_view(), std::move(request))); | 282 new AxProviderImpl(frame_->web_view(), std::move(request))); |
284 } | 283 } |
285 } | 284 } |
286 | 285 |
287 void HTMLDocument::Create(mojo::ApplicationConnection* connection, | 286 void HTMLDocument::Create(mojo::Connection* connection, |
288 mojo::InterfaceRequest<TestHTMLViewer> request) { | 287 mojo::InterfaceRequest<TestHTMLViewer> request) { |
289 CHECK(IsTestInterfaceEnabled()); | 288 CHECK(IsTestInterfaceEnabled()); |
290 if (!did_finish_local_frame_load_) { | 289 if (!did_finish_local_frame_load_) { |
291 auto cached_request = new mojo::InterfaceRequest<TestHTMLViewer>(); | 290 auto cached_request = new mojo::InterfaceRequest<TestHTMLViewer>(); |
292 *cached_request = std::move(request); | 291 *cached_request = std::move(request); |
293 GetBeforeLoadCache()->test_interface_requests.insert(cached_request); | 292 GetBeforeLoadCache()->test_interface_requests.insert(cached_request); |
294 } else { | 293 } else { |
295 test_html_viewers_.push_back(new TestHTMLViewerImpl( | 294 test_html_viewers_.push_back(new TestHTMLViewerImpl( |
296 frame_->web_frame()->toWebLocalFrame(), std::move(request))); | 295 frame_->web_frame()->toWebLocalFrame(), std::move(request))); |
297 } | 296 } |
298 } | 297 } |
299 | 298 |
300 void HTMLDocument::Create( | 299 void HTMLDocument::Create( |
301 mojo::ApplicationConnection* connection, | 300 mojo::Connection* connection, |
302 mojo::InterfaceRequest<web_view::mojom::FrameClient> request) { | 301 mojo::InterfaceRequest<web_view::mojom::FrameClient> request) { |
303 if (frame_) { | 302 if (frame_) { |
304 DVLOG(1) << "Request for FrameClient after one already vended."; | 303 DVLOG(1) << "Request for FrameClient after one already vended."; |
305 return; | 304 return; |
306 } | 305 } |
307 resource_waiter_->Bind(std::move(request)); | 306 resource_waiter_->Bind(std::move(request)); |
308 } | 307 } |
309 | 308 |
310 void HTMLDocument::Create( | 309 void HTMLDocument::Create( |
311 mojo::ApplicationConnection* connection, | 310 mojo::Connection* connection, |
312 mojo::InterfaceRequest<devtools_service::DevToolsAgent> request) { | 311 mojo::InterfaceRequest<devtools_service::DevToolsAgent> request) { |
313 if (frame_) { | 312 if (frame_) { |
314 if (frame_->devtools_agent()) | 313 if (frame_->devtools_agent()) |
315 frame_->devtools_agent()->BindToRequest(std::move(request)); | 314 frame_->devtools_agent()->BindToRequest(std::move(request)); |
316 } else { | 315 } else { |
317 devtools_agent_request_ = std::move(request); | 316 devtools_agent_request_ = std::move(request); |
318 } | 317 } |
319 } | 318 } |
320 | 319 |
321 void HTMLDocument::Create( | 320 void HTMLDocument::Create( |
322 mojo::ApplicationConnection* connection, | 321 mojo::Connection* connection, |
323 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) { | 322 mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) { |
324 DCHECK(!transferable_state_.window_tree_delegate_impl); | 323 DCHECK(!transferable_state_.window_tree_delegate_impl); |
325 transferable_state_.window_tree_delegate_impl.reset( | 324 transferable_state_.window_tree_delegate_impl.reset( |
326 new WindowTreeDelegateImpl(this)); | 325 new WindowTreeDelegateImpl(this)); |
327 transferable_state_.owns_window_tree_connection = true; | 326 transferable_state_.owns_window_tree_connection = true; |
328 mus::WindowTreeConnection::Create( | 327 mus::WindowTreeConnection::Create( |
329 transferable_state_.window_tree_delegate_impl.get(), std::move(request), | 328 transferable_state_.window_tree_delegate_impl.get(), std::move(request), |
330 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); | 329 mus::WindowTreeConnection::CreateType::DONT_WAIT_FOR_EMBED); |
331 } | 330 } |
332 | 331 |
333 } // namespace html_viewer | 332 } // namespace html_viewer |
OLD | NEW |