summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 23:57:54 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-29 23:57:54 +0000
commit9fa82bb8872a34275f3e0832f33339a4d07fa33b (patch)
treec5bafa8a9d5f0cf931834ad750f909b17e4c9534
parent893a5ccce13082aa85686ad142c0d8be0fb5cd70 (diff)
downloadchromium_src-9fa82bb8872a34275f3e0832f33339a4d07fa33b.zip
chromium_src-9fa82bb8872a34275f3e0832f33339a4d07fa33b.tar.gz
chromium_src-9fa82bb8872a34275f3e0832f33339a4d07fa33b.tar.bz2
linux: only create browser-side plugin container after plugin requests it
On Windows, windowed plugins are parented in a two-stage process: initially, the plugin is parented to the render view, then later it's reparented to a special per-plugin window. On Linux, plugin embedding always needs a special per-plugin window before it can be initialized. So there's no way to do the two-stage initialization process, and we only want to construct the browser-side plugin container for windowed plugins after the plugin requests it. Plumbing this through the WebPlugin interface will also allow us to side-route this request for window creation out to the browser process in the multi-process case. BUG=15421 TEST=plugins still work in test_shell Review URL: http://codereview.chromium.org/150034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/plugin/webplugin_proxy.h5
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc10
-rw-r--r--webkit/glue/webplugin.h7
-rw-r--r--webkit/glue/webplugin_impl.cc11
-rw-r--r--webkit/glue/webplugin_impl.h5
-rw-r--r--webkit/glue/webview_delegate.h4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h1
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_gtk.cc13
8 files changed, 46 insertions, 10 deletions
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index e143297..c7bbe91 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -37,6 +37,11 @@ class WebPluginProxy : public WebPlugin {
~WebPluginProxy();
// WebPlugin overrides
+#if defined(OS_LINUX)
+ gfx::PluginWindowHandle CreatePluginContainer() {
+ return 0; // Temporary empty stub while we restructure test_shell.
+ }
+#endif
void SetWindow(gfx::PluginWindowHandle window);
void WillDestroyWindow(gfx::PluginWindowHandle window);
#if defined(OS_WIN)
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index c20fee0..9f9838b 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -263,12 +263,10 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
return false;
}
- window_.window = reinterpret_cast<void*>(parent_);
- // The remainder of the code expects windowed_handle_ to exist for
- // windowed mode, despite not actually ever reaching through
- // windowed_handle_. It is still used as a token to represent "this
- // plugin" in messages to the browser.
- windowed_handle_ = parent_;
+ // Xembed plugins need a window created for them browser-side.
+ // Do that now.
+ windowed_handle_ = plugin_->CreatePluginContainer();
+ window_.window = reinterpret_cast<void*>(windowed_handle_);
if (!window_.ws_info)
window_.ws_info = new NPSetWindowCallbackStruct;
diff --git a/webkit/glue/webplugin.h b/webkit/glue/webplugin.h
index 2debf9a..07d2470 100644
--- a/webkit/glue/webplugin.h
+++ b/webkit/glue/webplugin.h
@@ -52,6 +52,13 @@ class WebPlugin {
WebPlugin() { }
virtual ~WebPlugin() { }
+#if defined(OS_LINUX)
+ // Called by the plugin delegate to request a container for a new
+ // windowed plugin. This handle will later get destroyed with
+ // WillDestroyWindow.
+ virtual gfx::PluginWindowHandle CreatePluginContainer() = 0;
+#endif
+
// Called by the plugin delegate to let the WebPlugin know if the plugin is
// windowed (i.e. handle is not NULL) or windowless (handle is NULL). This
// tells the WebPlugin to send mouse/keyboard events to the plugin delegate,
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 35ea7b2..e554255 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -388,6 +388,17 @@ WebPluginImpl::WebPluginImpl(WebCore::HTMLPlugInElement* element,
WebPluginImpl::~WebPluginImpl() {
}
+#if defined(OS_LINUX)
+gfx::PluginWindowHandle WebPluginImpl::CreatePluginContainer() {
+ WebCore::Frame* frame = element_->document()->frame();
+ WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
+ WebViewImpl* webview = webframe->GetWebViewImpl();
+ if (!webview->delegate())
+ return 0;
+ return webview->delegate()->CreatePluginContainer();
+}
+#endif
+
void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) {
if (window) {
DCHECK(!windowless_); // Make sure not called twice.
diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h
index 7d51f39..b81e8a9 100644
--- a/webkit/glue/webplugin_impl.h
+++ b/webkit/glue/webplugin_impl.h
@@ -113,7 +113,7 @@ class WebPluginContainer : public WebCore::Widget {
};
// This is the WebKit side of the plugin implementation that forwards calls,
-// after changing out of WebCore types, to a delegate. The delegate will
+// after changing out of WebCore types, to a delegate. The delegate may
// be in a different process.
class WebPluginImpl : public WebPlugin,
public WebKit::WebURLLoaderClient {
@@ -148,6 +148,9 @@ class WebPluginImpl : public WebPlugin,
int arg_count, char** arg_names, char** arg_values);
// WebPlugin implementation:
+#if defined(OS_LINUX)
+ gfx::PluginWindowHandle CreatePluginContainer();
+#endif
void SetWindow(gfx::PluginWindowHandle window);
void WillDestroyWindow(gfx::PluginWindowHandle window);
#if defined(OS_WIN)
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 7fe792f..6106d1d 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -133,6 +133,10 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // Called when a windowed plugin is initializing, to request a container
+ // for the plugin. Only used on Linux.
+ virtual gfx::PluginWindowHandle CreatePluginContainer() { return 0; }
+
// Called when a windowed plugin is closing.
// Lets the view delegate shut down anything it is using to wrap the plugin.
virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle) { }
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 1b5a99e..221943e 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -89,6 +89,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
const std::string& clsid,
std::string* actual_mime_type);
#if defined(OS_LINUX)
+ virtual gfx::PluginWindowHandle CreatePluginContainer();
virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
#endif
virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer(
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index cd21c17..10ba40f 100644
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -7,6 +7,7 @@
#include "webkit/tools/test_shell/test_webview_delegate.h"
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
#include "base/gfx/gtk_util.h"
#include "base/gfx/point.h"
@@ -91,13 +92,18 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
const std::string& mtype =
(actual_mime_type && !actual_mime_type->empty()) ? *actual_mime_type
: mime_type;
-
+ // TODO(evanm): we probably shouldn't be doing this mapping to X ids at
+ // this level.
GdkNativeWindow plugin_parent =
- shell_->webViewHost()->CreatePluginContainer();
+ GDK_WINDOW_XWINDOW(shell_->webViewHost()->view_handle()->window);
return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent);
}
+gfx::PluginWindowHandle TestWebViewDelegate::CreatePluginContainer() {
+ return shell_->webViewHost()->CreatePluginContainer();
+}
+
void TestWebViewDelegate::WillDestroyPluginWindow(unsigned long id) {
shell_->webViewHost()->OnPluginWindowDestroyed(id);
}
@@ -232,7 +238,8 @@ void TestWebViewDelegate::DidMove(WebWidget* webwidget,
// window?), ignore the message.
if (!widget)
return;
- DCHECK(!GTK_WIDGET_NO_WINDOW(widget) && GTK_WIDGET_REALIZED(widget));
+ DCHECK(!GTK_WIDGET_NO_WINDOW(widget));
+ DCHECK(GTK_WIDGET_REALIZED(widget));
if (!move.visible) {
gtk_widget_hide(widget);