Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: content/browser/web_contents/web_drag_dest_gtk.cc

Issue 12252016: Prevented connecting drag drop events to a SwappedOut RenderViewHost in WebContentsViewGtk (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Oops. Fix compile error. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/web_contents/web_drag_dest_gtk.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_drag_dest_gtk.cc
diff --git a/content/browser/web_contents/web_drag_dest_gtk.cc b/content/browser/web_contents/web_drag_dest_gtk.cc
index dcd89b0d8378c7873350e227d53be452c8fb3650..fd2763f05b3b4ca10ef6947f8993553651e4bfb3 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]);
}
}
« no previous file with comments | « content/browser/web_contents/web_drag_dest_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698