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

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: Use RenderViewSwappedIn to ensure we have a drag dest Created 7 years, 10 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..a89a32faee7fb4be0cae441b984dde4de3ba37fc 100644
--- a/content/browser/web_contents/web_contents_view_gtk.cc
+++ b/content/browser/web_contents/web_contents_view_gtk.cc
@@ -223,11 +223,20 @@ 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());
+ if (render_widget_host->IsRenderView()) {
+ RenderViewHost* rvh = RenderViewHost::From(render_widget_host);
+ // According to WebContentsImpl::RenderViewCreated, if the RVH is swapped
+ // out on creation then we are just creating a swapped-out RVH for the
+ // opener chain that won't be used for WebUI, so it won't be expected to
+ // receive any events.
Charlie Reis 2013/02/27 01:42:35 This comment doesn't make sense to me. First, cre
mthiesse 2013/02/27 14:57:13 Done.
+ if (!static_cast<RenderViewHostImpl*>(rvh)->is_swapped_out()) {
+ // Renderer target DnD.
+ drag_dest_.reset(new WebDragDestGtk(web_contents_, content_view));
+
+ if (delegate_.get())
+ drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
+ }
+ }
return view;
}
@@ -262,7 +271,20 @@ void WebContentsViewGtk::SizeContents(const gfx::Size& size) {
void WebContentsViewGtk::RenderViewCreated(RenderViewHost* host) {
}
-void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* host) {
+void WebContentsViewGtk::RenderViewSwappedIn(RenderViewHost* new_host,
+ RenderViewHost* old_host) {
Charlie Reis 2013/02/27 01:42:35 Shouldn't we update drag_dest_ every time we get h
mthiesse 2013/02/27 14:57:13 No, if we update the drag_dest_ every time here, j
Charlie Reis 2013/02/27 20:01:44 This sounds like an issue with drag n drop, which
+ // If we don't have a drag_dest yet, then we should set the drag test to the
+ // new RVH.
+ // Also, not sure if this ever happens, but if the renderViewHost we're
+ // swapping out is used by the drag_dest, then we need to reset the drag_dest
+ // to the new host.
+ if (!drag_dest_.get() || (old_host &&
+ (old_host->GetView()->GetNativeView() == drag_dest_->widget()))) {
+ drag_dest_.reset(new WebDragDestGtk(web_contents_,
+ new_host->GetView()->GetNativeView()));
+ if (delegate_.get())
+ drag_dest_->set_delegate(delegate_->GetDragDestDelegate());
+ }
}
WebContents* WebContentsViewGtk::web_contents() {

Powered by Google App Engine
This is Rietveld 408576698