summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-28 17:42:56 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-28 17:42:56 +0000
commitbb64e11d986551e16b51f67034335ef4cc5c2a8c (patch)
tree7c0ece07e4712baa5f5ae86d9963087a68fc73f3 /webkit
parent76a51ac85ab739064c2c6b224d489cfa1767ae8a (diff)
downloadchromium_src-bb64e11d986551e16b51f67034335ef4cc5c2a8c.zip
chromium_src-bb64e11d986551e16b51f67034335ef4cc5c2a8c.tar.gz
chromium_src-bb64e11d986551e16b51f67034335ef4cc5c2a8c.tar.bz2
linux: cleanup browser-side GtkSockets when plugins are destroyed
WillDestroyWindow is already plumbed over to the browser process in the multiproc case; we want to plumb it to our RenderView delegate so we can do similar cleanup in test_shell. BUG=15423 Review URL: http://codereview.chromium.org/147251 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19475 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc12
-rw-r--r--webkit/glue/webplugin_impl.cc9
-rw-r--r--webkit/glue/webplugin_impl.h2
-rw-r--r--webkit/glue/webview_delegate.h5
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h3
-rw-r--r--webkit/tools/test_shell/test_webview_delegate_gtk.cc4
-rw-r--r--webkit/tools/test_shell/webview_host.h3
-rw-r--r--webkit/tools/test_shell/webview_host_gtk.cc13
8 files changed, 41 insertions, 10 deletions
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 49670fc..c20fee0 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -266,8 +266,8 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
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_. So let's set it to the one window handle we
- // actually have available.
+ // windowed_handle_. It is still used as a token to represent "this
+ // plugin" in messages to the browser.
windowed_handle_ = parent_;
if (!window_.ws_info)
@@ -283,9 +283,11 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
}
void WebPluginDelegateImpl::WindowedDestroyWindow() {
- // We have no window to destroy; see comment in WindowedCreatePlugin
- // where windowed_handle_ is set.
- windowed_handle_ = 0;
+ if (windowed_handle_) {
+ plugin_->WillDestroyWindow(windowed_handle_);
+
+ windowed_handle_ = 0;
+ }
}
bool WebPluginDelegateImpl::WindowedReposition(
diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc
index 69f6259..35ea7b2 100644
--- a/webkit/glue/webplugin_impl.cc
+++ b/webkit/glue/webplugin_impl.cc
@@ -398,6 +398,15 @@ void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) {
}
}
+void WebPluginImpl::WillDestroyWindow(gfx::PluginWindowHandle window) {
+ WebCore::Frame* frame = element_->document()->frame();
+ WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame);
+ WebViewImpl* webview = webframe->GetWebViewImpl();
+ if (!webview->delegate())
+ return;
+ webview->delegate()->WillDestroyPluginWindow(window);
+}
+
bool WebPluginImpl::CompleteURL(const std::string& url_in,
std::string* url_out) {
if (!frame() || !frame()->document()) {
diff --git a/webkit/glue/webplugin_impl.h b/webkit/glue/webplugin_impl.h
index 9082820..7d51f39 100644
--- a/webkit/glue/webplugin_impl.h
+++ b/webkit/glue/webplugin_impl.h
@@ -149,7 +149,7 @@ class WebPluginImpl : public WebPlugin,
// WebPlugin implementation:
void SetWindow(gfx::PluginWindowHandle window);
- void WillDestroyWindow(gfx::PluginWindowHandle window) { }
+ void WillDestroyWindow(gfx::PluginWindowHandle window);
#if defined(OS_WIN)
void SetWindowlessPumpEvent(HANDLE pump_messages_event) { }
#endif
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 917c9d1..7fe792f 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -28,6 +28,7 @@
#include <vector>
+#include "base/gfx/native_widget_types.h"
#include "webkit/api/public/WebNavigationType.h"
#include "webkit/glue/context_menu.h"
#include "webkit/glue/webwidget_delegate.h"
@@ -132,6 +133,10 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
return NULL;
}
+ // 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) { }
+
// This method is called when the renderer creates a worker object.
virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client) {
return NULL;
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 2c85b8c..1b5a99e 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -88,6 +88,9 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
const std::string& mime_type,
const std::string& clsid,
std::string* actual_mime_type);
+#if defined(OS_LINUX)
+ virtual void WillDestroyPluginWindow(gfx::PluginWindowHandle handle);
+#endif
virtual WebKit::WebMediaPlayer* CreateWebMediaPlayer(
WebKit::WebMediaPlayerClient* client);
virtual WebKit::WebWorker* CreateWebWorker(WebKit::WebWorkerClient* client);
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
index 74586e5..cd21c17 100644
--- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc
+++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc
@@ -98,6 +98,10 @@ WebPluginDelegate* TestWebViewDelegate::CreatePluginDelegate(
return WebPluginDelegateImpl::Create(info.path, mtype, plugin_parent);
}
+void TestWebViewDelegate::WillDestroyPluginWindow(unsigned long id) {
+ shell_->webViewHost()->OnPluginWindowDestroyed(id);
+}
+
void TestWebViewDelegate::ShowJavaScriptAlert(const std::wstring& message) {
GtkWidget* dialog = gtk_message_dialog_new(
shell_->mainWnd(), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO,
diff --git a/webkit/tools/test_shell/webview_host.h b/webkit/tools/test_shell/webview_host.h
index 0cd62ee..9c7c489 100644
--- a/webkit/tools/test_shell/webview_host.h
+++ b/webkit/tools/test_shell/webview_host.h
@@ -41,6 +41,9 @@ class WebViewHost : public WebWidgetHost {
// the GtkWidget hosting it. Used when we get a message back from the
// renderer indicating a plugin needs to move.
GtkWidget* MapIDToWidget(GdkNativeWindow id);
+
+ // Called when a plugin has been destroyed. Lets us clean up our side.
+ void OnPluginWindowDestroyed(GdkNativeWindow id);
#endif
protected:
diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc
index cd491af..e089052 100644
--- a/webkit/tools/test_shell/webview_host_gtk.cc
+++ b/webkit/tools/test_shell/webview_host_gtk.cc
@@ -58,11 +58,16 @@ GtkWidget* WebViewHost::MapIDToWidget(GdkNativeWindow 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);
+void WebViewHost::OnPluginWindowDestroyed(GdkNativeWindow id) {
+ GtkWidget* plugin_container = MapIDToWidget(id);
+ if (!plugin_container)
+ return;
+
native_window_to_widget_map_.erase(id);
+ gtk_widget_destroy(plugin_container);
+}
- return FALSE; // Destroy our widget.
+gboolean WebViewHost::OnPlugRemoved(GtkSocket* socket) {
+ return TRUE; // Don't destroy our widget; we manage it ourselves.
}