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

Unified Diff: content/browser/web_contents/web_contents_view_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
Index: content/browser/web_contents/web_contents_view_gtk.cc
diff --git a/content/browser/web_contents/web_contents_view_gtk.cc b/content/browser/web_contents/web_contents_view_gtk.cc
index 7c6683530f4a60386332ae7a92a8d66f343a9ac6..d3b5a3e01c2870147a9a302e4ec98284dc3dd021 100644
--- a/content/browser/web_contents/web_contents_view_gtk.cc
+++ b/content/browser/web_contents/web_contents_view_gtk.cc
@@ -223,11 +223,13 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
GDK_POINTER_MOTION_MASK);
InsertIntoContentArea(content_view);
- // Renderer target DnD.
- drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view));
-
- if (delegate_.get())
- drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
+ // We don't want to change any state in this class for swapped out RVHs
+ // because they will not be visible at this time.
+ if (render_widget_host->IsRenderView()) {
+ RenderViewHost* rvh = RenderViewHost::From(render_widget_host);
+ if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out())
+ UpdateDragDest(rvh);
+ }
return view;
}
@@ -263,6 +265,7 @@ void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
}
void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* host) {
+ UpdateDragDest(host);
}
WebContents* WebContentsViewGtk::web_contents() {
@@ -294,6 +297,24 @@ void WebContentsViewGtk::InsertIntoContentArea(GtkWidget* widget) {
gtk_container_add(GTK_CONTAINER(expanded_.get()), widget);
}
+void WebContentsViewGtk::UpdateDragDest(RenderViewHost* host) {
+ gfx::NativeView content_view = host->GetView()->GetNativeView();
+
+ // If the host is already used by the drag_dest_, there's no point in deleting
+ // the old one to create an identical copy.
+ if (drag_dest_.get() && drag_dest_->widget() == content_view)
+ return;
+
+ // Clear the currently connected drag drop signals by deleting the old
+ // drag_dest_ before creating the new one.
+ drag_dest_.reset();
+ // Create the new drag_dest_.
+ drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view));
+
+ if (delegate_.get())
+ drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
+}
+
// Called when the content view gtk widget is tabbed to, or after the call to
// gtk_widget_child_focus() in TakeFocus(). We return true
// and grab focus if we don't have it. The call to
« no previous file with comments | « content/browser/web_contents/web_contents_view_gtk.h ('k') | content/browser/web_contents/web_drag_dest_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698