diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 00:33:37 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 00:33:37 +0000 |
commit | 3b33faae96e4cf42ec6b0da5163668b1e482d821 (patch) | |
tree | 05bc5e540fdd3150cdc256d46b0602df0670c441 /webkit/glue/plugins | |
parent | 5f1b0d6b9fb0b529202c63e99a67032cf1a306c9 (diff) | |
download | chromium_src-3b33faae96e4cf42ec6b0da5163668b1e482d821.zip chromium_src-3b33faae96e4cf42ec6b0da5163668b1e482d821.tar.gz chromium_src-3b33faae96e4cf42ec6b0da5163668b1e482d821.tar.bz2 |
linux plugins: eliminate GtkWidget* from plugin process
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@19320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r-- | webkit/glue/plugins/gtk_plugin_container.cc | 16 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_host.cc | 2 | ||||
-rw-r--r-- | webkit/glue/plugins/plugin_instance.h | 8 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.cc | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl.h | 6 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_delegate_impl_gtk.cc | 55 |
6 files changed, 28 insertions, 63 deletions
diff --git a/webkit/glue/plugins/gtk_plugin_container.cc b/webkit/glue/plugins/gtk_plugin_container.cc index 18bdb30..c487fa0 100644 --- a/webkit/glue/plugins/gtk_plugin_container.cc +++ b/webkit/glue/plugins/gtk_plugin_container.cc @@ -14,13 +14,6 @@ namespace { // through GLib's object management. class GtkPluginContainer : public GtkSocket { public: - static GtkWidget* CreateNewWidget() { - GtkWidget* container = GTK_WIDGET(g_object_new(GetType(), NULL)); - g_signal_connect(GTK_SOCKET(container), "plug-removed", - G_CALLBACK(OnPlugRemoved), NULL); - return container; - } - // Sets the requested size of the widget. void set_size(int width, int height) { width_ = width; @@ -33,7 +26,6 @@ class GtkPluginContainer : public GtkSocket { return G_TYPE_CHECK_INSTANCE_CAST(instance, GetType(), GtkPluginContainer); } - private: // Create and register our custom container type with GTK. static GType GetType() { static GType type = 0; // We only want to register our type once. @@ -74,12 +66,6 @@ class GtkPluginContainer : public GtkSocket { requisition->height = container->height_; } - static gboolean OnPlugRemoved(GtkSocket* socket) { - // This is called when the other side of the socket goes away. - // We return TRUE to indicate that we don't want to destroy our side. - return TRUE; - } - int width_; int height_; DISALLOW_IMPLICIT_CONSTRUCTORS(GtkPluginContainer); @@ -89,7 +75,7 @@ class GtkPluginContainer : public GtkSocket { // Create a new instance of our GTK widget object. GtkWidget* gtk_plugin_container_new() { - return GtkPluginContainer::CreateNewWidget(); + return GTK_WIDGET(g_object_new(GtkPluginContainer::GetType(), NULL)); } void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height) { diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc index 815b415..2e1c233 100644 --- a/webkit/glue/plugins/plugin_host.cc +++ b/webkit/glue/plugins/plugin_host.cc @@ -711,7 +711,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) { { #if defined(OS_WIN) || defined(OS_LINUX) scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); - gfx::NativeView handle = plugin->window_handle(); + gfx::PluginWindowHandle handle = plugin->window_handle(); *((void**)value) = (void*)handle; rv = NPERR_NO_ERROR; #else diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h index e73d49f..ba8824f8 100644 --- a/webkit/glue/plugins/plugin_instance.h +++ b/webkit/glue/plugins/plugin_instance.h @@ -70,8 +70,10 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { NPP npp() { return npp_; } // Get/Set for the instance's window handle. - gfx::NativeView window_handle() { return window_handle_; } - void set_window_handle(gfx::NativeView value) { window_handle_ = value; } + gfx::PluginWindowHandle window_handle() const { return window_handle_; } + void set_window_handle(gfx::PluginWindowHandle value) { + window_handle_ = value; + } // Get/Set whether this instance is in Windowless mode. // Default is false. @@ -223,7 +225,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> { scoped_refptr<PluginHost> host_; NPPluginFuncs* npp_functions_; std::vector<scoped_refptr<PluginStream> > open_streams_; - gfx::NativeView window_handle_; + gfx::PluginWindowHandle window_handle_; bool windowless_; bool transparent_; WebPlugin* webplugin_; diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc index 5cf00a5..d197fb11 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl.cc @@ -71,7 +71,7 @@ base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor( WebPluginDelegate* WebPluginDelegate::Create( const FilePath& filename, const std::string& mime_type, - gfx::NativeView containing_view) { + gfx::PluginWindowHandle containing_view) { scoped_refptr<NPAPI::PluginLib> plugin = NPAPI::PluginLib::CreatePluginLib(filename); if (plugin.get() == NULL) @@ -140,7 +140,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook( } WebPluginDelegateImpl::WebPluginDelegateImpl( - gfx::NativeView containing_view, + gfx::PluginWindowHandle containing_view, NPAPI::PluginInstance *instance) : parent_(containing_view), instance_(instance), diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h index 61a41cd..d3cbdbf 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl.h +++ b/webkit/glue/plugins/webplugin_delegate_impl.h @@ -91,7 +91,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { private: friend class DeleteTask<WebPluginDelegateImpl>; - WebPluginDelegateImpl(gfx::NativeView containing_view, + WebPluginDelegateImpl(gfx::PluginWindowHandle containing_view, NPAPI::PluginInstance *instance); ~WebPluginDelegateImpl(); @@ -154,7 +154,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { void DestroyInstance(); // used for windowed plugins - gfx::NativeView windowed_handle_; + gfx::PluginWindowHandle windowed_handle_; bool windowed_did_set_window_; #if defined(OS_WIN) gfx::Rect windowed_last_pos_; @@ -190,7 +190,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate { void EnsurePixmapAtLeastSize(int width, int height); #endif - gfx::NativeView parent_; + gfx::PluginWindowHandle parent_; NPWindow window_; #if defined(OS_MACOSX) NP_CGContext cg_context_; diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc index f583876..49670fc 100644 --- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc +++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc @@ -38,7 +38,7 @@ using WebKit::WebMouseEvent; WebPluginDelegate* WebPluginDelegate::Create( const FilePath& filename, const std::string& mime_type, - gfx::NativeView containing_view) { + gfx::PluginWindowHandle containing_view) { scoped_refptr<NPAPI::PluginLib> plugin = NPAPI::PluginLib::CreatePluginLib(filename); if (plugin.get() == NULL) @@ -54,7 +54,7 @@ WebPluginDelegate* WebPluginDelegate::Create( } WebPluginDelegateImpl::WebPluginDelegateImpl( - gfx::NativeView containing_view, + gfx::PluginWindowHandle containing_view, NPAPI::PluginInstance *instance) : windowed_handle_(0), @@ -263,63 +263,40 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() { return false; } - windowed_handle_ = gtk_plugin_container_new(); - gtk_container_add(GTK_CONTAINER(parent_), windowed_handle_); - gtk_widget_show(windowed_handle_); - gtk_widget_realize(windowed_handle_); - - window_.window = GINT_TO_POINTER( - gtk_socket_get_id(GTK_SOCKET(windowed_handle_))); + 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_ = parent_; if (!window_.ws_info) window_.ws_info = new NPSetWindowCallbackStruct; NPSetWindowCallbackStruct* extra = static_cast<NPSetWindowCallbackStruct*>(window_.ws_info); - extra->display = GDK_WINDOW_XDISPLAY(windowed_handle_->window); - GdkVisual* visual = gdk_drawable_get_visual(windowed_handle_->window); - extra->visual = GDK_VISUAL_XVISUAL(visual); - extra->depth = visual->depth; - extra->colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(windowed_handle_->window)); + extra->display = GDK_DISPLAY(); + extra->visual = DefaultVisual(GDK_DISPLAY(), 0); + extra->depth = DefaultDepth(GDK_DISPLAY(), 0); + extra->colormap = DefaultColormap(GDK_DISPLAY(), 0); return true; } void WebPluginDelegateImpl::WindowedDestroyWindow() { - if (windowed_handle_ != NULL) { - gtk_widget_destroy(windowed_handle_); - windowed_handle_ = NULL; - } + // We have no window to destroy; see comment in WindowedCreatePlugin + // where windowed_handle_ is set. + windowed_handle_ = 0; } bool WebPluginDelegateImpl::WindowedReposition( const gfx::Rect& window_rect, const gfx::Rect& clip_rect) { - if (!windowed_handle_) { - NOTREACHED(); - return false; - } - - if (window_rect_ == window_rect && clip_rect_ == clip_rect) + if (window_rect == window_rect_ && clip_rect == clip_rect_) return false; - // We only set the plugin's size here. Its position is moved elsewhere, which - // allows the window moves/scrolling/clipping to be synchronized with the page - // and other windows. - if (window_rect.size() != window_rect_.size()) { - gtk_plugin_container_set_size(windowed_handle_, window_rect.width(), - window_rect.height()); - GtkAllocation allocation = { 0, 0, - window_rect.width(), window_rect.height() }; - gtk_widget_size_allocate(windowed_handle_, &allocation); - } - window_rect_ = window_rect; clip_rect_ = clip_rect; - // TODO(deanm): Is this really needed? - // Ensure that the entire window gets repainted. - gtk_widget_queue_draw(windowed_handle_); - return true; } |