Commit c2174d8b authored by Trent Apted's avatar Trent Apted Committed by Commit Bot

MacViewsBrowser: Release capture before starting the native download shelf drag.

Normally drags initiated via views::View::ProcessMouseDragged() complete
in views::View::DoDrag() once exceeding their drag distance threshold.
However, DownloadItemView doesn't set a views::DragController or override
View::GetDragOperations(). Instead, it runs its own drag in an override
of View::OnMouseDragged().

This drag code path isn't aware of the Widget::SetCapture() call done in
Widget::OnMouseEvent(), which needs to be released before an OS-level drag
can take place. Usually this is done by views::DragDropClientMac, which
gets skipped.

To fix, ensure the custom OS-level drag codepath in download_item_drag_mac.mm
releases capture instead.

Bug: 863377
Change-Id: Ib2f7c80a00dd3b38fe5a98475bddb4e595f3f83c
Reviewed-on: https://chromium-review.googlesource.com/1156192Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579563}
parent 9c6521a0
...@@ -7,10 +7,18 @@ ...@@ -7,10 +7,18 @@
#include "chrome/browser/ui/cocoa/download/download_util_mac.h" #include "chrome/browser/ui/cocoa/download/download_util_mac.h"
#include "components/download/public/common/download_item.h" #include "components/download/public/common/download_item.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ui/views/widget/widget.h"
void DragDownloadItem(const download::DownloadItem* download, void DragDownloadItem(const download::DownloadItem* download,
gfx::Image* icon, gfx::Image* icon,
gfx::NativeView view) { gfx::NativeView view) {
// If this drag was initiated from a views::Widget, that widget may have
// mouse capture. Drags via View::DoDrag() usually release it. The code below
// bypasses that, so release manually. See https://crbug.com/863377.
views::Widget* widget = views::Widget::GetWidgetForNativeView(view);
if (widget)
widget->ReleaseCapture();
DCHECK_EQ(download::DownloadItem::COMPLETE, download->GetState()); DCHECK_EQ(download::DownloadItem::COMPLETE, download->GetState());
NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard]; NSPasteboard* pasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
download_util::AddFileToPasteboard(pasteboard, download->GetTargetFilePath()); download_util::AddFileToPasteboard(pasteboard, download->GetTargetFilePath());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment