OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/html_viewer/layout_test_content_handler_impl.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "components/html_viewer/html_document_application_delegate.h" |
| 9 #include "components/html_viewer/web_test_delegate_impl.h" |
| 10 #include "components/test_runner/web_frame_test_proxy.h" |
| 11 #include "components/test_runner/web_test_proxy.h" |
| 12 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 13 #include "third_party/WebKit/public/web/WebView.h" |
| 14 |
| 15 namespace html_viewer { |
| 16 |
| 17 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl( |
| 18 GlobalState* global_state, |
| 19 mojo::ApplicationImpl* app, |
| 20 mojo::InterfaceRequest<mojo::ContentHandler> request, |
| 21 test_runner::WebTestInterfaces* test_interfaces, |
| 22 WebTestDelegateImpl* test_delegate) |
| 23 : ContentHandlerImpl(global_state, app, request.Pass()), |
| 24 test_interfaces_(test_interfaces), |
| 25 test_delegate_(test_delegate) { |
| 26 } |
| 27 |
| 28 LayoutTestContentHandlerImpl::~LayoutTestContentHandlerImpl() { |
| 29 } |
| 30 |
| 31 void LayoutTestContentHandlerImpl::StartApplication( |
| 32 mojo::InterfaceRequest<mojo::Application> request, |
| 33 mojo::URLResponsePtr response) { |
| 34 test_interfaces_->SetTestIsRunning(true); |
| 35 test_interfaces_->ConfigureForTestWithURL(GURL(), false); |
| 36 |
| 37 // HTMLDocumentApplicationDelegate deletes itself. |
| 38 HTMLDocumentApplicationDelegate* delegate = |
| 39 new HTMLDocumentApplicationDelegate( |
| 40 request.Pass(), response.Pass(), global_state(), |
| 41 app()->app_lifetime_helper()->CreateAppRefCount()); |
| 42 |
| 43 delegate->SetHTMLDocumentCreationCallback( |
| 44 base::Bind(&LayoutTestContentHandlerImpl::CreateHTMLDocument, |
| 45 base::Unretained(this))); |
| 46 } |
| 47 |
| 48 HTMLDocument* LayoutTestContentHandlerImpl::CreateHTMLDocument( |
| 49 HTMLDocument::CreateParams* params) { |
| 50 typedef test_runner::WebTestProxy< |
| 51 test_runner::WebFrameTestProxy<HTMLDocument, HTMLDocument::CreateParams*>, |
| 52 HTMLDocument::CreateParams*> ProxyType; |
| 53 |
| 54 ProxyType* proxy = new ProxyType(params); |
| 55 proxy->SetInterfaces(test_interfaces_); |
| 56 proxy->SetDelegate(test_delegate_); |
| 57 proxy->set_base_proxy(proxy); |
| 58 test_delegate_->set_test_proxy(proxy); |
| 59 test_interfaces_->SetWebView(proxy->web_view(), proxy); |
| 60 proxy->set_widget(proxy->web_view()); |
| 61 blink::WebTestingSupport::injectInternalsObject( |
| 62 proxy->web_view()->mainFrame()->toWebLocalFrame()); |
| 63 test_interfaces_->BindTo(proxy->web_view()->mainFrame()); |
| 64 return proxy; |
| 65 } |
| 66 |
| 67 } // namespace html_viewer |
OLD | NEW |