diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index e8b62f4861a3..b23f4652c5ed 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -1302,11 +1302,27 @@ nsBaseDragSession::SendStoreDropTargetAndDelayEndDragSession( NS_IMETHODIMP nsBaseDragSession::SendDispatchToDropTargetAndResumeEndDragSession( - bool aShouldDrop) { + bool aShouldDrop, const nsTArray>& aAllowedFiles) { MOZ_ASSERT(mDelayedDropBrowserParent); + nsTHashSet allowedFilePaths; + if (aShouldDrop) { + for (const auto& allowedFile : aAllowedFiles) { + nsString filePath; + nsresult rv = allowedFile->GetPath(filePath); + if (NS_FAILED(rv)) { + // Something has gone wrong, cancel the drop + Unused << mDelayedDropBrowserParent + ->SendDispatchToDropTargetAndResumeEndDragSession( + false /* aShouldDrop */, nsTHashSet()); + mDelayedDropBrowserParent = nullptr; + return rv; + } + allowedFilePaths.Insert(filePath); + } + } Unused << mDelayedDropBrowserParent ->SendDispatchToDropTargetAndResumeEndDragSession( - aShouldDrop, allowedFilePaths); + aShouldDrop, std::move(allowedFilePaths)); mDelayedDropBrowserParent = nullptr; return NS_OK; } diff --git a/widget/nsIDragSession.idl b/widget/nsIDragSession.idl index 7bd03608b4a3..1d0228892547 100644 --- a/widget/nsIDragSession.idl +++ b/widget/nsIDragSession.idl @@ -26,6 +26,7 @@ class BrowserParent; %} interface nsIContentSecurityPolicy; +interface nsIFile; [ptr] native BrowserParentPtr(mozilla::dom::BrowserParent); native EventMessage(mozilla::EventMessage); @@ -235,7 +236,7 @@ interface nsIDragSession : nsISupports * @param aShouldDrop True to send drop event, false to send dragexit event */ void sendDispatchToDropTargetAndResumeEndDragSession( - in boolean aShouldDrop); + in boolean aShouldDrop, in Array aAllowedFiles); /** * Store aElement and aDocFrame as the future drop/dragexit context, and