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..5b5effaef8634a8a0b0634bd5c084303ce4b5433 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() && content_view == drag_dest_->widget()) |
Charlie Reis
2013/03/14 22:08:38
nit: I think this would be easier to read if you r
mthiesse
2013/03/15 15:26:49
Done.
|
+ return; |
+ |
+ // Clear the currently connected drag drop signals by deleting the old |
+ // drag_dest_ before creating the new one. |
+ drag_dest_.reset(NULL); |
Charlie Reis
2013/03/14 22:08:38
nit: reset()
mthiesse
2013/03/15 15:26:49
Done.
|
+ // Create the new drag_dest_; |
Charlie Reis
2013/03/14 22:08:38
End comment with a period, not a semicolon. :)
mthiesse
2013/03/15 15:26:49
Haha oh boy was I ever not paying attention when w
|
+ 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 |