// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include #include "webkit/tools/test_shell/webview_host.h" #include "base/logging.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" #include "webkit/glue/webpreferences.h" #include "webkit/plugins/npapi/gtk_plugin_container.h" #include "webkit/tools/test_shell/test_webview_delegate.h" using WebKit::WebDevToolsAgentClient; using WebKit::WebView; // static WebViewHost* WebViewHost::Create(GtkWidget* parent_view, TestWebViewDelegate* delegate, WebDevToolsAgentClient* dev_tools_client, const webkit_glue::WebPreferences& prefs) { WebViewHost* host = new WebViewHost(); host->view_ = WebWidgetHost::CreateWidget(parent_view, host); host->plugin_container_manager_.set_host_widget(host->view_); host->webwidget_ = WebView::create(delegate); host->webview()->setDevToolsAgentClient(dev_tools_client); prefs.Apply(host->webview()); host->webview()->settings()->setExperimentalCSSGridLayoutEnabled(true); host->webview()->initializeMainFrame(delegate); host->webwidget_->layout(); return host; } WebView* WebViewHost::webview() const { return static_cast(webwidget_); } void WebViewHost::CreatePluginContainer(gfx::PluginWindowHandle id) { plugin_container_manager_.CreatePluginContainer(id); } void WebViewHost::DestroyPluginContainer(gfx::PluginWindowHandle id) { plugin_container_manager_.DestroyPluginContainer(id); }