Chromium Code Reviews| 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 #include "components/html_viewer/layout_test_content_handler_impl.h" | 5 #include "components/html_viewer/layout_test_content_handler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "components/html_viewer/html_document_application_delegate.h" | 8 #include "components/html_viewer/html_document_application_delegate.h" |
| 9 #include "components/html_viewer/web_test_delegate_impl.h" | 9 #include "components/html_viewer/web_test_delegate_impl.h" |
| 10 #include "components/test_runner/web_frame_test_proxy.h" | 10 #include "components/test_runner/web_frame_test_proxy.h" |
| 11 #include "components/test_runner/web_test_proxy.h" | 11 #include "components/test_runner/web_test_proxy.h" |
| 12 #include "third_party/WebKit/public/web/WebTestingSupport.h" | 12 #include "third_party/WebKit/public/web/WebTestingSupport.h" |
| 13 #include "third_party/WebKit/public/web/WebView.h" | 13 #include "third_party/WebKit/public/web/WebView.h" |
| 14 | 14 |
| 15 namespace html_viewer { | 15 namespace html_viewer { |
| 16 | 16 |
| 17 class TestHTMLFrame : public HTMLFrame { | |
| 18 public: | |
| 19 explicit TestHTMLFrame(HTMLFrame::CreateParams* params) : HTMLFrame(params) {} | |
| 20 | |
| 21 protected: | |
| 22 ~TestHTMLFrame() override {} | |
| 23 | |
| 24 private: | |
| 25 // blink::WebFrameClient:: | |
| 26 void didClearWindowObject(blink::WebLocalFrame* frame) override { | |
| 27 HTMLFrame::didClearWindowObject(frame); | |
| 28 blink::WebTestingSupport::injectInternalsObject(frame); | |
| 29 } | |
| 30 | |
| 31 DISALLOW_COPY_AND_ASSIGN(TestHTMLFrame); | |
| 32 }; | |
| 33 | |
| 17 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl( | 34 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl( |
| 18 GlobalState* global_state, | 35 GlobalState* global_state, |
| 19 mojo::ApplicationImpl* app, | 36 mojo::ApplicationImpl* app, |
| 20 mojo::InterfaceRequest<mojo::ContentHandler> request, | 37 mojo::InterfaceRequest<mojo::ContentHandler> request, |
| 21 test_runner::WebTestInterfaces* test_interfaces, | 38 test_runner::WebTestInterfaces* test_interfaces, |
| 22 WebTestDelegateImpl* test_delegate) | 39 WebTestDelegateImpl* test_delegate) |
| 23 : ContentHandlerImpl(global_state, app, request.Pass()), | 40 : ContentHandlerImpl(global_state, app, request.Pass()), |
| 24 test_interfaces_(test_interfaces), | 41 test_interfaces_(test_interfaces), |
| 25 test_delegate_(test_delegate) { | 42 test_delegate_(test_delegate) { |
| 26 } | 43 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 39 new HTMLDocumentApplicationDelegate( | 56 new HTMLDocumentApplicationDelegate( |
| 40 request.Pass(), response.Pass(), global_state(), | 57 request.Pass(), response.Pass(), global_state(), |
| 41 app()->app_lifetime_helper()->CreateAppRefCount()); | 58 app()->app_lifetime_helper()->CreateAppRefCount()); |
| 42 | 59 |
| 43 delegate->SetHTMLFrameCreationCallback(base::Bind( | 60 delegate->SetHTMLFrameCreationCallback(base::Bind( |
| 44 &LayoutTestContentHandlerImpl::CreateHTMLFrame, base::Unretained(this))); | 61 &LayoutTestContentHandlerImpl::CreateHTMLFrame, base::Unretained(this))); |
| 45 } | 62 } |
| 46 | 63 |
| 47 HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame( | 64 HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame( |
| 48 HTMLFrame::CreateParams* params) { | 65 HTMLFrame::CreateParams* params) { |
| 66 if (params->parent) | |
|
sky
2015/08/18 20:51:44
Yes, this is what I had in mind. How about a comme
| |
| 67 return new HTMLFrame(params); | |
| 49 using ProxyType = test_runner::WebTestProxy< | 68 using ProxyType = test_runner::WebTestProxy< |
| 50 test_runner::WebFrameTestProxy<HTMLFrame, HTMLFrame::CreateParams*>, | 69 test_runner::WebFrameTestProxy<TestHTMLFrame, HTMLFrame::CreateParams*>, |
| 51 HTMLFrame::CreateParams*>; | 70 HTMLFrame::CreateParams*>; |
| 52 // TODO(sky): this isn't right for all frame types, eg remote frames. | 71 // TODO(sky): this isn't right for all frame types, eg remote frames. |
| 53 ProxyType* proxy = new ProxyType(params); | 72 ProxyType* proxy = new ProxyType(params); |
| 54 proxy->SetInterfaces(test_interfaces_); | 73 proxy->SetInterfaces(test_interfaces_); |
| 55 proxy->SetDelegate(test_delegate_); | 74 proxy->SetDelegate(test_delegate_); |
| 56 proxy->set_base_proxy(proxy); | 75 proxy->set_base_proxy(proxy); |
| 57 test_delegate_->set_test_proxy(proxy); | 76 test_delegate_->set_test_proxy(proxy); |
| 58 test_interfaces_->SetWebView(proxy->web_view(), proxy); | 77 test_interfaces_->SetWebView(proxy->web_view(), proxy); |
| 59 proxy->set_widget(proxy->web_view()); | 78 proxy->set_widget(proxy->web_view()); |
| 60 blink::WebTestingSupport::injectInternalsObject( | |
| 61 proxy->web_view()->mainFrame()->toWebLocalFrame()); | |
| 62 test_interfaces_->BindTo(proxy->web_view()->mainFrame()); | 79 test_interfaces_->BindTo(proxy->web_view()->mainFrame()); |
| 63 return proxy; | 80 return proxy; |
| 64 } | 81 } |
| 65 | 82 |
| 66 } // namespace html_viewer | 83 } // namespace html_viewer |
| OLD | NEW |