2011-01-10 02:31:12 +01:00
|
|
|
// Copyright (c) 2006-2008 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 <gtk/gtk.h>
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/webview_host.h"
|
|
|
|
#include "libcef/browser_webview_delegate.h"
|
2011-01-10 02:31:12 +01:00
|
|
|
|
|
|
|
#include "base/logging.h"
|
2011-11-04 19:19:14 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFactory.h"
|
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
|
|
|
#include "ui/gfx/rect.h"
|
|
|
|
#include "ui/gfx/size.h"
|
2011-01-10 02:31:12 +01:00
|
|
|
#include "webkit/glue/webpreferences.h"
|
|
|
|
#include "webkit/plugins/npapi/gtk_plugin_container.h"
|
|
|
|
|
|
|
|
using WebKit::WebDevToolsAgentClient;
|
2011-11-04 19:19:14 +01:00
|
|
|
using WebKit::WebKeyboardEvent;
|
|
|
|
using WebKit::WebInputEvent;
|
|
|
|
using WebKit::WebInputEventFactory;
|
2011-01-10 02:31:12 +01:00
|
|
|
using WebKit::WebView;
|
|
|
|
|
|
|
|
// static
|
|
|
|
WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
|
|
|
|
const gfx::Rect& rect,
|
|
|
|
BrowserWebViewDelegate* delegate,
|
2011-03-24 21:36:47 +01:00
|
|
|
PaintDelegate* paint_delegate,
|
2011-01-10 02:31:12 +01:00
|
|
|
WebDevToolsAgentClient* dev_tools_client,
|
|
|
|
const WebPreferences& prefs) {
|
2011-11-04 19:19:14 +01:00
|
|
|
WebViewHost* host = new WebViewHost(delegate);
|
2011-01-10 02:31:12 +01:00
|
|
|
|
|
|
|
host->view_ = WebWidgetHost::CreateWidget(parent_view, host);
|
|
|
|
host->plugin_container_manager_.set_host_widget(host->view_);
|
|
|
|
|
2011-01-12 00:46:14 +01:00
|
|
|
#if defined(WEBKIT_HAS_WEB_AUTO_FILL_CLIENT)
|
2011-04-05 18:17:33 +02:00
|
|
|
host->webwidget_ = WebView::create(delegate, NULL);
|
2011-01-12 00:46:14 +01:00
|
|
|
#else
|
2011-04-05 18:17:33 +02:00
|
|
|
host->webwidget_ = WebView::create(delegate);
|
2011-01-12 00:46:14 +01:00
|
|
|
#endif
|
2011-04-05 18:17:33 +02:00
|
|
|
host->webview()->setDevToolsAgentClient(dev_tools_client);
|
2012-01-05 20:34:20 +01:00
|
|
|
host->webview()->setPermissionClient(delegate);
|
2011-01-10 02:31:12 +01:00
|
|
|
prefs.Apply(host->webview());
|
|
|
|
host->webview()->initializeMainFrame(delegate);
|
|
|
|
host->webwidget_->layout();
|
|
|
|
|
|
|
|
return host;
|
|
|
|
}
|
|
|
|
|
|
|
|
WebView* WebViewHost::webview() const {
|
|
|
|
return static_cast<WebView*>(webwidget_);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebViewHost::CreatePluginContainer(gfx::PluginWindowHandle id) {
|
|
|
|
plugin_container_manager_.CreatePluginContainer(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebViewHost::DestroyPluginContainer(gfx::PluginWindowHandle id) {
|
|
|
|
plugin_container_manager_.DestroyPluginContainer(id);
|
|
|
|
}
|
2011-11-04 19:19:14 +01:00
|
|
|
|
|
|
|
void WebViewHost::KeyEvent(GdkEventKey* event) {
|
|
|
|
WebKeyboardEvent keyboard_event(WebInputEventFactory::keyboardEvent(event));
|
|
|
|
if (delegate_->OnKeyboardEvent(keyboard_event, false))
|
|
|
|
return;
|
|
|
|
|
|
|
|
WebWidgetHost::KeyEvent(event);
|
|
|
|
}
|