summaryrefslogtreecommitdiffstats
path: root/chrome/plugin/webplugin_proxy.cc
diff options
context:
space:
mode:
authorpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 19:26:52 +0000
committerpiman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-30 19:26:52 +0000
commit2f5b1a172cf64e40d9e7ae97ef9ecb5ecd5fa865 (patch)
tree1b5660cd5010281a9fd1ce4d6f9892ec8d5b0534 /chrome/plugin/webplugin_proxy.cc
parent70cc766c4b3e34140ceb3b534a60393a3ba12731 (diff)
downloadchromium_src-2f5b1a172cf64e40d9e7ae97ef9ecb5ecd5fa865.zip
chromium_src-2f5b1a172cf64e40d9e7ae97ef9ecb5ecd5fa865.tar.gz
chromium_src-2f5b1a172cf64e40d9e7ae97ef9ecb5ecd5fa865.tar.bz2
linux: add a GtkPlug / GtkSocket pair in the plugin process
Some plugins assume that the GtkSocket container is in the same process as the plugin, so we give them one. This fixes bug 16928 and the gdk_window_get_origin issue. BUG=16928 Review URL: http://codereview.chromium.org/160380 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/webplugin_proxy.cc')
-rw-r--r--chrome/plugin/webplugin_proxy.cc52
1 files changed, 48 insertions, 4 deletions
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index b4a619e..5483956 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -4,6 +4,11 @@
#include "chrome/plugin/webplugin_proxy.h"
+#include "build/build_config.h"
+#if defined(OS_LINUX)
+#include <gtk/gtk.h>
+#endif
+
#include "app/gfx/canvas.h"
#if defined(OS_WIN)
#include "app/win_util.h"
@@ -50,6 +55,11 @@ WebPluginProxy::WebPluginProxy(
delegate_(delegate),
waiting_for_paint_(false),
page_url_(page_url),
+#if defined(OS_LINUX)
+ container_(0),
+ plug_(NULL),
+ socket_(NULL),
+#endif
ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this))
{
}
@@ -65,13 +75,40 @@ bool WebPluginProxy::Send(IPC::Message* msg) {
#if defined(OS_LINUX)
gfx::PluginWindowHandle WebPluginProxy::CreatePluginContainer() {
- gfx::PluginWindowHandle container;
- Send(new PluginHostMsg_CreatePluginContainer(route_id_, &container));
- return container;
+ DCHECK(!container_);
+ DCHECK(!plug_);
+ DCHECK(!socket_);
+
+ Send(new PluginHostMsg_CreatePluginContainer(route_id_, &container_));
+ if (!container_)
+ return 0;
+
+ plug_ = gtk_plug_new(container_);
+ gtk_widget_show(plug_);
+ socket_ = gtk_socket_new();
+ gtk_widget_show(socket_);
+ gtk_container_add(GTK_CONTAINER(plug_), socket_);
+ gtk_widget_show_all(plug_);
+
+ // Prevent the plug from being destroyed if the browser kills the container
+ // window.
+ g_signal_connect(plug_, "delete-event", G_CALLBACK(gtk_true), NULL);
+ // Prevent the socket from being destroyed when the plugin removes itself.
+ g_signal_connect(socket_, "plug_removed", G_CALLBACK(gtk_true), NULL);
+
+ return gtk_socket_get_id(GTK_SOCKET(socket_));
}
#endif
void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) {
+#if defined(OS_LINUX)
+ if (window) {
+ DCHECK(plug_);
+ DCHECK(socket_);
+ DCHECK_EQ(window, gtk_socket_get_id(GTK_SOCKET(socket_)));
+ window = container_;
+ }
+#endif
Send(new PluginHostMsg_SetWindow(route_id_, window));
}
@@ -81,7 +118,14 @@ void WebPluginProxy::WillDestroyWindow(gfx::PluginWindowHandle window) {
new PluginProcessHostMsg_PluginWindowDestroyed(
window, ::GetParent(window)));
#elif defined(OS_LINUX)
- Send(new PluginHostMsg_DestroyPluginContainer(route_id_, window));
+ DCHECK(plug_);
+ DCHECK(socket_);
+ DCHECK_EQ(window, gtk_socket_get_id(GTK_SOCKET(socket_)));
+ Send(new PluginHostMsg_DestroyPluginContainer(route_id_, container_));
+ gtk_widget_destroy(plug_);
+ container_ = NULL;
+ plug_ = NULL;
+ socket_ = NULL;
#else
NOTIMPLEMENTED();
#endif