| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ |
| 6 #define WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/gfx/native_widget_types.h" | 11 #include "base/gfx/native_widget_types.h" |
| 12 #include "base/gfx/rect.h" | 12 #include "base/gfx/rect.h" |
| 13 #include "webkit/tools/test_shell/webwidget_host.h" | 13 #include "webkit/tools/test_shell/webwidget_host.h" |
| 14 #if defined(OS_LINUX) |
| 15 #include "webkit/glue/plugins/gtk_plugin_container_host.h" |
| 16 #endif |
| 14 | 17 |
| 15 struct WebPreferences; | 18 struct WebPreferences; |
| 16 class WebView; | 19 class WebView; |
| 17 class WebViewDelegate; | 20 class WebViewDelegate; |
| 18 | 21 |
| 19 #if defined(OS_LINUX) | |
| 20 typedef struct _GtkSocket GtkSocket; | |
| 21 #endif | |
| 22 | |
| 23 // This class is a simple NativeView-based host for a WebView | 22 // This class is a simple NativeView-based host for a WebView |
| 24 class WebViewHost : public WebWidgetHost { | 23 class WebViewHost : public WebWidgetHost { |
| 25 public: | 24 public: |
| 26 // The new instance is deleted once the associated NativeView is destroyed. | 25 // The new instance is deleted once the associated NativeView is destroyed. |
| 27 // The newly created window should be resized after it is created, using the | 26 // The newly created window should be resized after it is created, using the |
| 28 // MoveWindow (or equivalent) function. | 27 // MoveWindow (or equivalent) function. |
| 29 static WebViewHost* Create(gfx::NativeView parent_view, | 28 static WebViewHost* Create(gfx::NativeView parent_view, |
| 30 WebViewDelegate* delegate, | 29 WebViewDelegate* delegate, |
| 31 const WebPreferences& prefs); | 30 const WebPreferences& prefs); |
| 32 | 31 |
| 33 WebView* webview() const; | 32 WebView* webview() const; |
| 34 | 33 |
| 35 #if defined(OS_LINUX) | 34 #if defined(OS_LINUX) |
| 36 // Create a new plugin parent container, returning its X window id for | 35 // Create a new plugin parent container, returning its X window id for |
| 37 // embedders to use. | 36 // embedders to use. |
| 38 GdkNativeWindow CreatePluginContainer(); | 37 GdkNativeWindow CreatePluginContainer(); |
| 39 | 38 |
| 40 // Map a GdkNativeWindow returned by CreatePluginContainer() back to | |
| 41 // the GtkWidget hosting it. Used when we get a message back from the | |
| 42 // renderer indicating a plugin needs to move. | |
| 43 GtkWidget* MapIDToWidget(GdkNativeWindow id); | |
| 44 | |
| 45 // Called when a plugin has been destroyed. Lets us clean up our side. | 39 // Called when a plugin has been destroyed. Lets us clean up our side. |
| 46 void OnPluginWindowDestroyed(GdkNativeWindow id); | 40 void OnPluginWindowDestroyed(GdkNativeWindow id); |
| 47 #endif | 41 #endif |
| 48 | 42 |
| 43 #if defined(OS_LINUX) |
| 44 GtkPluginContainerHost& plugin_container_host() { |
| 45 return plugin_container_host_; |
| 46 } |
| 47 #endif |
| 48 |
| 49 protected: | 49 protected: |
| 50 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 51 virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) { | 51 virtual bool WndProc(UINT message, WPARAM wparam, LPARAM lparam) { |
| 52 return false; | 52 return false; |
| 53 } | 53 } |
| 54 #endif | 54 #endif |
| 55 | 55 |
| 56 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
| 57 // A map used for MapIDToWidget() above. | 57 // Helper class that creates and moves plugin containers. |
| 58 typedef std::map<GdkNativeWindow, GtkWidget*> NativeWindowToWidgetMap; | 58 GtkPluginContainerHost plugin_container_host_; |
| 59 NativeWindowToWidgetMap native_window_to_widget_map_; | |
| 60 | |
| 61 // Callback for when one of our plugins goes away. | |
| 62 static gboolean OnPlugRemovedThunk(GtkSocket* socket, | |
| 63 WebViewHost* web_view_host) { | |
| 64 return web_view_host->OnPlugRemoved(socket); | |
| 65 } | |
| 66 gboolean OnPlugRemoved(GtkSocket* socket); | |
| 67 #endif | 59 #endif |
| 68 }; | 60 }; |
| 69 | 61 |
| 70 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ | 62 #endif // WEBKIT_TOOLS_TEST_SHELL_WEBVIEW_HOST_H_ |
| OLD | NEW |