2010-10-09 20:23:06 +02:00
|
|
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
2010-10-03 23:04:50 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef _WEBVIEW_HOST_H
|
|
|
|
#define _WEBVIEW_HOST_H
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
2011-02-15 19:07:24 +01:00
|
|
|
#include "ui/gfx/native_widget_types.h"
|
2010-10-03 23:04:50 +02:00
|
|
|
#include "webwidget_host.h"
|
|
|
|
|
2010-10-09 20:23:06 +02:00
|
|
|
#if defined(TOOLKIT_USES_GTK)
|
2011-01-07 22:34:20 +01:00
|
|
|
#include "webkit/plugins/npapi/gtk_plugin_container_manager.h"
|
2010-10-09 20:23:06 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
struct WebPreferences;
|
|
|
|
class BrowserWebViewDelegate;
|
|
|
|
|
|
|
|
namespace WebKit {
|
|
|
|
class WebDevToolsAgentClient;
|
|
|
|
class WebView;
|
|
|
|
}
|
|
|
|
|
2010-10-09 20:23:06 +02:00
|
|
|
// This class is a simple NativeView-based host for a WebView
|
2010-10-03 23:04:50 +02:00
|
|
|
class WebViewHost : public WebWidgetHost {
|
|
|
|
public:
|
2010-10-09 20:23:06 +02:00
|
|
|
// The new instance is deleted once the associated NativeView is destroyed.
|
2010-10-03 23:04:50 +02:00
|
|
|
// The newly created window should be resized after it is created, using the
|
|
|
|
// MoveWindow (or equivalent) function.
|
2010-10-09 20:23:06 +02:00
|
|
|
static WebViewHost* Create(gfx::NativeView parent_view,
|
2010-11-15 16:39:56 +01:00
|
|
|
const gfx::Rect& rect,
|
2010-10-03 23:04:50 +02:00
|
|
|
BrowserWebViewDelegate* delegate,
|
2011-03-24 21:36:47 +01:00
|
|
|
PaintDelegate* paint_delegate,
|
2010-10-03 23:04:50 +02:00
|
|
|
WebKit::WebDevToolsAgentClient* devtools_client,
|
|
|
|
const WebPreferences& prefs);
|
|
|
|
|
2011-03-24 21:36:47 +01:00
|
|
|
virtual ~WebViewHost();
|
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
WebKit::WebView* webview() const;
|
|
|
|
|
2010-10-09 20:23:06 +02:00
|
|
|
#if defined(TOOLKIT_USES_GTK)
|
|
|
|
// Create a new plugin parent container for a given plugin XID.
|
|
|
|
void CreatePluginContainer(gfx::PluginWindowHandle id);
|
|
|
|
|
|
|
|
// Destroy the plugin parent container when a plugin has been destroyed.
|
|
|
|
void DestroyPluginContainer(gfx::PluginWindowHandle id);
|
|
|
|
|
2011-01-07 22:34:20 +01:00
|
|
|
webkit::npapi::GtkPluginContainerManager* plugin_container_manager() {
|
2010-10-09 20:23:06 +02:00
|
|
|
return &plugin_container_manager_;
|
|
|
|
}
|
2011-11-04 19:19:14 +01:00
|
|
|
|
|
|
|
virtual void KeyEvent(GdkEventKey* event);
|
2010-10-09 20:23:06 +02:00
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
void SetIsActive(bool active);
|
2011-08-02 18:50:06 +02:00
|
|
|
virtual void MouseEvent(NSEvent *);
|
2011-11-04 19:19:14 +01:00
|
|
|
virtual void KeyEvent(NSEvent *);
|
2011-08-02 18:50:06 +02:00
|
|
|
virtual void SetFocus(bool enable);
|
2010-10-09 20:23:06 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
protected:
|
2011-11-04 19:19:14 +01:00
|
|
|
WebViewHost(BrowserWebViewDelegate* delegate);
|
2011-03-24 21:36:47 +01:00
|
|
|
|
2010-10-03 23:04:50 +02:00
|
|
|
#if defined(OS_WIN)
|
2011-06-14 17:45:00 +02:00
|
|
|
virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam);
|
2011-02-28 01:33:11 +01:00
|
|
|
virtual void MouseEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
2011-11-04 19:19:14 +01:00
|
|
|
virtual void KeyEvent(UINT message, WPARAM wparam, LPARAM lparam);
|
2010-10-03 23:04:50 +02:00
|
|
|
#endif
|
2010-10-09 20:23:06 +02:00
|
|
|
|
|
|
|
#if defined(TOOLKIT_USES_GTK)
|
|
|
|
// Helper class that creates and moves plugin containers.
|
2011-01-07 22:34:20 +01:00
|
|
|
webkit::npapi::GtkPluginContainerManager plugin_container_manager_;
|
2010-10-09 20:23:06 +02:00
|
|
|
#endif
|
2011-11-04 19:19:14 +01:00
|
|
|
|
|
|
|
// The delegate pointer will always outlive the WebViewHost object.
|
|
|
|
BrowserWebViewDelegate* delegate_;
|
2010-10-03 23:04:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _WEBVIEW_HOST_H
|