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

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

Issue 2543803002: Fix crash where a RenderWidgetHost can be deleted in the middle of a (Closed)
Patch Set: addressing comments Created 4 years 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_contents_view_aura.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_contents_view_aura.cc
diff --git a/content/browser/web_contents/web_contents_view_aura.cc b/content/browser/web_contents/web_contents_view_aura.cc
index 091cb0e4712f47a583e7b9c0df27ca3e7a58d3c0..709ea5dd5d1cbccdfe063040cbdc20419c3638c7 100644
--- a/content/browser/web_contents/web_contents_view_aura.cc
+++ b/content/browser/web_contents/web_contents_view_aura.cc
@@ -550,7 +550,8 @@ void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) {
rwhv->SetSize(size);
}
-void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) {
+void WebContentsViewAura::EndDrag(RenderWidgetHost* source_rwh,
+ blink::WebDragOperationsMask ops) {
if (!web_contents_)
return;
@@ -566,7 +567,9 @@ void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) {
// the coordinates local to |drag_start_rwh_|? See crbug.com/647249.
web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(),
screen_loc.x(), screen_loc.y(), ops,
- drag_start_rwh_.get());
+ source_rwh);
+
+ web_contents_->SystemDragEnded(source_rwh);
}
void WebContentsViewAura::InstallOverscrollControllerDelegate(
@@ -896,7 +899,13 @@ void WebContentsViewAura::StartDragging(
return;
}
- drag_start_rwh_ = source_rwh->GetWeakPtr();
+ // Grab a weak pointer to the RenderWidgetHost, since it can be destroyed
+ // during the drag and drop nested message loop in StartDragAndDrop.
+ // For example, the RenderWidgetHost can be deleted if a cross-process
+ // transfer happens while dragging, since the RenderWidgetHost is deleted in
+ // that case.
+ base::WeakPtr<RenderWidgetHostImpl> source_rwh_weak_ptr =
+ source_rwh->GetWeakPtr();
ui::TouchSelectionController* selection_controller = GetSelectionController();
if (selection_controller)
@@ -940,8 +949,7 @@ void WebContentsViewAura::StartDragging(
return;
}
- EndDrag(ConvertToWeb(result_op));
- web_contents_->SystemDragEnded(source_rwh);
+ EndDrag(source_rwh_weak_ptr.get(), ConvertToWeb(result_op));
}
void WebContentsViewAura::UpdateDragCursor(blink::WebDragOperation operation) {
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698