Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / components / html_viewer / layout_test_content_handler_impl.cc
blobea2530737b72897e2c2d4f71ae0b04c68535e573
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.
5 #include "components/html_viewer/layout_test_content_handler_impl.h"
7 #include "base/bind.h"
8 #include "components/html_viewer/html_document_application_delegate.h"
9 #include "components/html_viewer/html_widget.h"
10 #include "components/html_viewer/web_test_delegate_impl.h"
11 #include "components/test_runner/web_frame_test_proxy.h"
12 #include "third_party/WebKit/public/web/WebTestingSupport.h"
13 #include "third_party/WebKit/public/web/WebView.h"
15 namespace html_viewer {
17 class TestHTMLFrame : public HTMLFrame {
18 public:
19 explicit TestHTMLFrame(HTMLFrame::CreateParams* params) : HTMLFrame(params) {}
21 protected:
22 ~TestHTMLFrame() override {}
24 private:
25 // blink::WebFrameClient::
26 void didClearWindowObject(blink::WebLocalFrame* frame) override {
27 HTMLFrame::didClearWindowObject(frame);
28 blink::WebTestingSupport::injectInternalsObject(frame);
31 DISALLOW_COPY_AND_ASSIGN(TestHTMLFrame);
34 LayoutTestContentHandlerImpl::LayoutTestContentHandlerImpl(
35 GlobalState* global_state,
36 mojo::ApplicationImpl* app,
37 mojo::InterfaceRequest<mojo::ContentHandler> request,
38 test_runner::WebTestInterfaces* test_interfaces,
39 WebTestDelegateImpl* test_delegate)
40 : ContentHandlerImpl(global_state, app, request.Pass()),
41 test_interfaces_(test_interfaces),
42 test_delegate_(test_delegate),
43 web_widget_proxy_(nullptr) {}
45 LayoutTestContentHandlerImpl::~LayoutTestContentHandlerImpl() {
48 void LayoutTestContentHandlerImpl::StartApplication(
49 mojo::InterfaceRequest<mojo::Application> request,
50 mojo::URLResponsePtr response) {
51 test_interfaces_->SetTestIsRunning(true);
52 test_interfaces_->ConfigureForTestWithURL(GURL(), false);
54 // HTMLDocumentApplicationDelegate deletes itself.
55 HTMLDocumentApplicationDelegate* delegate =
56 new HTMLDocumentApplicationDelegate(
57 request.Pass(), response.Pass(), global_state(),
58 app()->app_lifetime_helper()->CreateAppRefCount());
60 delegate->set_html_factory(this);
63 HTMLWidgetRootLocal* LayoutTestContentHandlerImpl::CreateHTMLWidgetRootLocal(
64 HTMLWidgetRootLocal::CreateParams* params) {
65 web_widget_proxy_ = new WebWidgetProxy(params);
66 return web_widget_proxy_;
69 HTMLFrame* LayoutTestContentHandlerImpl::CreateHTMLFrame(
70 HTMLFrame::CreateParams* params) {
71 // The test harness isn't correctly set-up for iframes yet. So return a normal
72 // HTMLFrame for iframes.
73 if (params->parent || !params->view || params->view->id() != params->id)
74 return new HTMLFrame(params);
76 using ProxyType =
77 test_runner::WebFrameTestProxy<TestHTMLFrame, HTMLFrame::CreateParams*>;
78 ProxyType* proxy = new ProxyType(params);
80 web_widget_proxy_->SetInterfaces(test_interfaces_);
81 web_widget_proxy_->SetDelegate(test_delegate_);
82 proxy->set_base_proxy(web_widget_proxy_);
83 test_delegate_->set_test_proxy(web_widget_proxy_);
84 test_interfaces_->SetWebView(web_widget_proxy_->web_view(),
85 web_widget_proxy_);
86 web_widget_proxy_->set_widget(web_widget_proxy_->web_view());
87 test_interfaces_->BindTo(web_widget_proxy_->web_view()->mainFrame());
88 return proxy;
91 } // namespace html_viewer