Index: ui/app_list/views/apps_grid_view.cc |
diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc |
index f1f1a05bf58cce6dbdf8a79c32e7ee5f9bf442d3..00141ffd1f19f6b96dc0ae134ab943db8a26342a 100644 |
--- a/ui/app_list/views/apps_grid_view.cc |
+++ b/ui/app_list/views/apps_grid_view.cc |
@@ -556,7 +556,8 @@ void AppsGridView::OnGotShortcutPath( |
bool AppsGridView::UpdateDragFromItem(Pointer pointer, |
const ui::LocatedEvent& event) { |
- DCHECK(drag_view_); |
+ if (!drag_view_) |
+ return false; // Drag canceled. |
gfx::Point drag_point_in_grid_view; |
ExtractDragLocation(event, &drag_point_in_grid_view); |
@@ -578,9 +579,8 @@ void AppsGridView::UpdateDrag(Pointer pointer, const gfx::Point& point) { |
if (folder_delegate_) |
UpdateDragStateInsideFolder(pointer, point); |
- // EndDrag was called before if |drag_view_| is NULL. |
if (!drag_view_) |
- return; |
+ return; // Drag canceled. |
if (RunSynchronousDrag()) |
return; |
@@ -674,6 +674,14 @@ void AppsGridView::EndDrag(bool cancel) { |
return; |
} |
+ if (IsDraggingForReparentInRootLevelGridView()) { |
+ // An EndDrag can be received during a reparent via a model change. This |
+ // is always a cancel and needs to be forwarded to the folder. |
+ DCHECK(cancel); |
+ delegate_->CancelDragInActiveFolder(); |
+ return; |
+ } |
+ |
if (!cancel && dragging()) { |
// Regular drag ending path, ie, not for reparenting. |
CalculateDropTarget(last_drag_point_, true); |
@@ -797,6 +805,9 @@ void AppsGridView::InitiateDragFromReparentItemInRootLevelGridView( |
void AppsGridView::UpdateDragFromReparentItem(Pointer pointer, |
const gfx::Point& drag_point) { |
+ // Note that if a cancel ocurrs while reparenting, the |drag_view_| in both |
+ // root and folder grid views is cleared, so the check in UpdateDragFromItem() |
+ // for |drag_view_| being NULL (in the folder grid) is sufficient. |
DCHECK(drag_view_); |
DCHECK(IsDraggingForReparentInRootLevelGridView()); |