Fix download drag and drop for PWA by adding BeginFileDrag Mojo interface for cross-process drag initiation

提交: f36a3d19 | 2026-02-05 00:21:30

← 返回列表

Fix download drag and drop for PWA by adding BeginFileDrag Mojo interface for cross-process drag initiation

Minor
提交哈希: f36a3d19aa90f050b6b8a94ad7e1e00d94ce7fad
提交时间: 2026-02-05 00:21:30
影响等级: Minor
生成工具: webview2-upstream-sentry
上游审核链接: 查看上游审核 🔗

📋 摘要

This commit fixes download file drag-and-drop failing in PWA windows on macOS. The issue was that PWA windows run in a separate app shim process, and the previous DragDownloadItem() called beginDraggingSessionWithItems directly on the local NSView, which doesn't work for remote windows. Changes include: a new FileDragData struct and BeginFileDrag() Mojo interface in NativeWidgetNSWindow.mojom; BeginFileDrag() implementation in NativeWidgetNSWindowBridge that performs the actual drag via bridged_view_ in the app shim process; DragDownloadItem() refactored to use NativeWidgetMacNSWindowHost::GetNSWindowMojo() for drag initiation, working for both in-process and out-of-process scenarios. The old DragDownloadItemSource ObjC class is removed.

🎯 影响分析

This change has minor direct impact on WebView2Mac. The new BeginFileDrag Mojo interface is added to NativeWidgetNSWindow.mojom, and Edge downstream's HostingNSWindowBridge inherits from NativeWidgetNSWindowBridge which implements this Mojo interface. Since BeginFileDrag is a newly added method with no downstream override, WebView2Mac will directly inherit the upstream base class implementation. However, as an embedded WebView control, WebView2Mac typically does not involve browser download shelf drag operations (DragDownloadItem resides in chrome/browser/download/, which is the Chrome browser layer rather than the content layer), so this code path is unlikely to be triggered in WebView2Mac scenarios. The Mojo interface change affects the IPC protocol but is purely additive (backward compatible). No downstream patch is needed.

受影响的类:

remote_cocoa::NativeWidgetNSWindowBridge remote_cocoa::mojom::NativeWidgetNSWindow remote_cocoa::mojom::FileDragData embedded_browser_webview::HostingNSWindowBridge