summaryrefslogtreecommitdiffstats
path: root/content/browser/web_contents/web_drag_dest_gtk.cc
diff options
context:
space:
mode:
authormthiesse@chromium.org <mthiesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:25:43 +0000
committermthiesse@chromium.org <mthiesse@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-16 09:25:43 +0000
commitd866d17fddb39f49dd9ee6fd64145a60b6d958dd (patch)
tree69c96e47ad85375857797797cc85ea52ddf87ed4 /content/browser/web_contents/web_drag_dest_gtk.cc
parent2b1767cf508a22ca32767ce3ed0a25c9506d855d (diff)
downloadchromium_src-d866d17fddb39f49dd9ee6fd64145a60b6d958dd.zip
chromium_src-d866d17fddb39f49dd9ee6fd64145a60b6d958dd.tar.gz
chromium_src-d866d17fddb39f49dd9ee6fd64145a60b6d958dd.tar.bz2
Prevented connecting events to a SwappedOut RenderViewHost in WebContentsViewGtk
Added a check to see if the RenderWidgetHost passed to CreateViewForWidget is SwappedOut before connecting events to it, or creating a DragDest from it. Needed for: https://chromiumcodereview.appspot.com/12086095/ When a postMessage is sent to a guest process, like a BrowserPlugin guest, WebContentsViewGtk::CreateViewForWidget is called with a swapped out RenderWidgetHost. This RenderWidgetHost is then used as the WebDragDest for the window, preventing the window from receiving Drag and Drop events. BUG= 161112, 177667 Review URL: https://chromiumcodereview.appspot.com/12252016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/web_contents/web_drag_dest_gtk.cc')
-rw-r--r--content/browser/web_contents/web_drag_dest_gtk.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/content/browser/web_contents/web_drag_dest_gtk.cc b/content/browser/web_contents/web_drag_dest_gtk.cc
index dcd89b0..fd2763f 100644
--- a/content/browser/web_contents/web_drag_dest_gtk.cc
+++ b/content/browser/web_contents/web_drag_dest_gtk.cc
@@ -27,6 +27,7 @@ using WebKit::WebDragOperationNone;
namespace content {
namespace {
+const int kNumGtkHandlers = 5;
int GetModifierFlags(GtkWidget* widget) {
int modifier_state = 0;
@@ -58,25 +59,30 @@ WebDragDestGtk::WebDragDestGtk(WebContents* web_contents, GtkWidget* widget)
static_cast<GdkDragAction>(GDK_ACTION_COPY |
GDK_ACTION_LINK |
GDK_ACTION_MOVE));
- g_signal_connect(widget, "drag-motion",
- G_CALLBACK(OnDragMotionThunk), this);
- g_signal_connect(widget, "drag-leave",
- G_CALLBACK(OnDragLeaveThunk), this);
- g_signal_connect(widget, "drag-drop",
- G_CALLBACK(OnDragDropThunk), this);
- g_signal_connect(widget, "drag-data-received",
- G_CALLBACK(OnDragDataReceivedThunk), this);
+
+ // If adding a handler, make sure to update kNumGtkHandlers and add it to the
+ // |handlers_| array so that it can be disconnected later on.
+ handlers_.reset(new int[kNumGtkHandlers]);
+ handlers_.get()[0] = g_signal_connect(
+ widget, "drag-motion", G_CALLBACK(OnDragMotionThunk), this);
+ handlers_.get()[1] = g_signal_connect(
+ widget, "drag-leave", G_CALLBACK(OnDragLeaveThunk), this);
+ handlers_.get()[2] = g_signal_connect(
+ widget, "drag-drop", G_CALLBACK(OnDragDropThunk), this);
+ handlers_.get()[3] = g_signal_connect(
+ widget, "drag-data-received", G_CALLBACK(OnDragDataReceivedThunk), this);
// TODO(tony): Need a drag-data-delete handler for moving content out of
// the WebContents. http://crbug.com/38989
- destroy_handler_ = g_signal_connect(
+ handlers_.get()[4] = g_signal_connect(
widget, "destroy", G_CALLBACK(gtk_widget_destroyed), &widget_);
}
WebDragDestGtk::~WebDragDestGtk() {
if (widget_) {
gtk_drag_dest_unset(widget_);
- g_signal_handler_disconnect(widget_, destroy_handler_);
+ for (int i = 0; i < kNumGtkHandlers; ++i)
+ g_signal_handler_disconnect(widget_, handlers_.get()[i]);
}
}