summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/webview_host_gtk.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 18:22:54 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 18:22:54 +0000
commit140c303f6227f870bb269bd6810c907c99004b55 (patch)
treeec3522f3193bc2688d7777fcd022e808a530dc49 /webkit/tools/test_shell/webview_host_gtk.cc
parent487c2873c78595f5ec78629a5ca92304b34ce317 (diff)
downloadchromium_src-140c303f6227f870bb269bd6810c907c99004b55.zip
chromium_src-140c303f6227f870bb269bd6810c907c99004b55.tar.gz
chromium_src-140c303f6227f870bb269bd6810c907c99004b55.tar.bz2
linux plugins: eliminate GtkWidget* from plugin process
[retry with mac hopefully fixed this time] GtkWidget* (and its wrapper, gfx::NativeView) only work within a single process. Plugins already work with a lower-level type that works across processes -- an X Window id. The parent of a plugin is an HWND on windows, but it's an X Window id on X. So we introduce a new typedef wrapping that and push it through all the places in the code that needs it. Since we no longer have a GtkSocket in the WebPluginDelegateImpl, we need to do a bit more work in the WebViewDelegate (aka the browser process in the multiproc world). We also need the plugin host (the browser) to track the GtkSockets that are hosting the plugin, as well as destroy them when necessary. To do this we require the plugin owner to grab the plug-removed signal rather than putting its handler in GtkPluginContainer; this is the way it worked before I'd refactored into GtkPluginContainer so it shouldn't be so bad. This change still only works in test_shell, but the refactoring should translate to the multiprocess case pretty easily. Review URL: http://codereview.chromium.org/146009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19387 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/webview_host_gtk.cc')
-rw-r--r--webkit/tools/test_shell/webview_host_gtk.cc37
1 files changed, 37 insertions, 0 deletions
diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc
index 54e3ec8..cd491af 100644
--- a/webkit/tools/test_shell/webview_host_gtk.cc
+++ b/webkit/tools/test_shell/webview_host_gtk.cc
@@ -6,9 +6,11 @@
#include "webkit/tools/test_shell/webview_host.h"
+#include "base/logging.h"
#include "base/gfx/rect.h"
#include "base/gfx/size.h"
#include "skia/ext/platform_canvas.h"
+#include "webkit/glue/plugins/gtk_plugin_container.h"
#include "webkit/glue/webview.h"
// static
@@ -29,3 +31,38 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view,
WebView* WebViewHost::webview() const {
return static_cast<WebView*>(webwidget_);
}
+
+GdkNativeWindow WebViewHost::CreatePluginContainer() {
+ GtkWidget* plugin_container = gtk_plugin_container_new();
+ g_signal_connect(G_OBJECT(plugin_container), "plug-removed",
+ G_CALLBACK(OnPlugRemovedThunk), this);
+ gtk_container_add(GTK_CONTAINER(view_handle()), plugin_container);
+ gtk_widget_show(plugin_container);
+ gtk_widget_realize(plugin_container);
+
+ GdkNativeWindow id = gtk_socket_get_id(GTK_SOCKET(plugin_container));
+
+ native_window_to_widget_map_.insert(std::make_pair(id, plugin_container));
+
+ return id;
+}
+
+GtkWidget* WebViewHost::MapIDToWidget(GdkNativeWindow id) {
+ NativeWindowToWidgetMap::const_iterator i =
+ native_window_to_widget_map_.find(id);
+ if (i != native_window_to_widget_map_.end())
+ return i->second;
+
+ LOG(ERROR) << "Request for widget host for unknown window id " << id;
+
+ return NULL;
+}
+
+gboolean WebViewHost::OnPlugRemoved(GtkSocket* socket) {
+ // Remove the socket's id from our list of widgets.
+ GdkNativeWindow id = gtk_socket_get_id(socket);
+ native_window_to_widget_map_.erase(id);
+
+ return FALSE; // Destroy our widget.
+}
+