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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/thread_task_runner_handle.h" | 14 #include "base/thread_task_runner_handle.h" |
15 #include "components/html_viewer/blink_input_events_type_converters.h" | 15 #include "components/html_viewer/blink_input_events_type_converters.h" |
16 #include "components/html_viewer/blink_url_request_type_converters.h" | 16 #include "components/html_viewer/blink_url_request_type_converters.h" |
17 #include "components/html_viewer/devtools_agent_impl.h" | |
18 #include "components/html_viewer/media_factory.h" | 17 #include "components/html_viewer/media_factory.h" |
19 #include "components/html_viewer/setup.h" | 18 #include "components/html_viewer/setup.h" |
20 #include "components/html_viewer/web_layer_tree_view_impl.h" | 19 #include "components/html_viewer/web_layer_tree_view_impl.h" |
21 #include "components/html_viewer/web_storage_namespace_impl.h" | 20 #include "components/html_viewer/web_storage_namespace_impl.h" |
22 #include "components/html_viewer/web_url_loader_impl.h" | 21 #include "components/html_viewer/web_url_loader_impl.h" |
23 #include "components/view_manager/public/cpp/view.h" | 22 #include "components/view_manager/public/cpp/view.h" |
24 #include "components/view_manager/public/cpp/view_manager.h" | 23 #include "components/view_manager/public/cpp/view_manager.h" |
25 #include "components/view_manager/public/cpp/view_property.h" | 24 #include "components/view_manager/public/cpp/view_property.h" |
26 #include "components/view_manager/public/interfaces/surfaces.mojom.h" | 25 #include "components/view_manager/public/interfaces/surfaces.mojom.h" |
27 #include "mojo/application/public/cpp/application_impl.h" | 26 #include "mojo/application/public/cpp/application_impl.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 mojo::InterfaceRequest<mandoline::FrameTreeClient> request) { | 214 mojo::InterfaceRequest<mandoline::FrameTreeClient> request) { |
216 frame_tree_manager_binding_.Bind(request.Pass()); | 215 frame_tree_manager_binding_.Bind(request.Pass()); |
217 } | 216 } |
218 | 217 |
219 void HTMLDocument::Load(URLResponsePtr response) { | 218 void HTMLDocument::Load(URLResponsePtr response) { |
220 DCHECK(!web_view_); | 219 DCHECK(!web_view_); |
221 web_view_ = blink::WebView::create(this); | 220 web_view_ = blink::WebView::create(this); |
222 touch_handler_.reset(new TouchHandler(web_view_)); | 221 touch_handler_.reset(new TouchHandler(web_view_)); |
223 web_layer_tree_view_impl_->set_widget(web_view_); | 222 web_layer_tree_view_impl_->set_widget(web_view_); |
224 ConfigureSettings(web_view_->settings()); | 223 ConfigureSettings(web_view_->settings()); |
225 | 224 web_view_->setMainFrame( |
226 blink::WebLocalFrame* main_frame = | 225 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this)); |
227 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this); | |
228 web_view_->setMainFrame(main_frame); | |
229 | |
230 devtools_agent_.reset( | |
231 new DevToolsAgentImpl(main_frame, html_document_app_->shell())); | |
232 | 226 |
233 GURL url(response->url); | 227 GURL url(response->url); |
234 | 228 |
235 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; | 229 WebURLRequestExtraData* extra_data = new WebURLRequestExtraData; |
236 extra_data->synthetic_response = response.Pass(); | 230 extra_data->synthetic_response = response.Pass(); |
237 | 231 |
238 blink::WebURLRequest web_request; | 232 blink::WebURLRequest web_request; |
239 web_request.initialize(); | 233 web_request.initialize(); |
240 web_request.setURL(url); | 234 web_request.setURL(url); |
241 web_request.setExtraData(extra_data); | 235 web_request.setExtraData(extra_data); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 child_frame_data.scope = scope; | 329 child_frame_data.scope = scope; |
336 frame_to_view_[child_frame] = child_frame_data; | 330 frame_to_view_[child_frame] = child_frame_data; |
337 } | 331 } |
338 return child_frame; | 332 return child_frame; |
339 } | 333 } |
340 | 334 |
341 void HTMLDocument::frameDetached(blink::WebFrame* frame) { | 335 void HTMLDocument::frameDetached(blink::WebFrame* frame) { |
342 if (frame->parent()) | 336 if (frame->parent()) |
343 frame->parent()->removeChild(frame); | 337 frame->parent()->removeChild(frame); |
344 | 338 |
345 if (devtools_agent_ && frame == devtools_agent_->frame()) | |
346 devtools_agent_.reset(); | |
347 | |
348 // |frame| is invalid after here. | 339 // |frame| is invalid after here. |
349 frame->close(); | 340 frame->close(); |
350 } | 341 } |
351 | 342 |
352 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) { | 343 blink::WebCookieJar* HTMLDocument::cookieJar(blink::WebLocalFrame* frame) { |
353 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. | 344 // TODO(darin): Blink does not fallback to the Platform provided WebCookieJar. |
354 // Either it should, as it once did, or we should find another solution here. | 345 // Either it should, as it once did, or we should find another solution here. |
355 return blink::Platform::current()->cookieJar(); | 346 return blink::Platform::current()->cookieJar(); |
356 } | 347 } |
357 | 348 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 touch_handler_->OnTouchEvent(*event); | 442 touch_handler_->OnTouchEvent(*event); |
452 return; | 443 return; |
453 } | 444 } |
454 scoped_ptr<blink::WebInputEvent> web_event = | 445 scoped_ptr<blink::WebInputEvent> web_event = |
455 event.To<scoped_ptr<blink::WebInputEvent>>(); | 446 event.To<scoped_ptr<blink::WebInputEvent>>(); |
456 if (web_event) | 447 if (web_event) |
457 web_view_->handleInputEvent(*web_event); | 448 web_view_->handleInputEvent(*web_event); |
458 } | 449 } |
459 | 450 |
460 } // namespace html_viewer | 451 } // namespace html_viewer |
OLD | NEW |