Closed Bug 1852839 Opened 2 years ago Closed 2 years ago

Add something like nsIFilePicker.isModeSupported()

Categories

(Core :: Widget, task)

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: mconley, Assigned: mconley)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Most platforms have traditionally allowed us to open a native file picker that selects folders (modeGetFolder).

When installed as a Snap package on Linux, Firefox uses the xdg-desktop-portal mechanism to show file pickers, and only recently (since version 3) does xdg-desktop-portal allow clients to request pickers for folders.

In lieu of a better solution, the browser migration wizard plans to use the native file picker / xdg-desktop-portal to gain access to browser data outside of the Firefox sandbox. This is similar to what we do for Safari (see bug 1493103).

We need a way of detecting whether or not folder selection is even possible so that we don't offer instructions that simply don't work on versions of Linux with xdg-desktop-portal < 3.

What I propose is a new method on nsIFilePicker that returns a Promise that resolves if the passed in mode is supported. For Windows and macOS, this should just resolve to true on the next tick. For Linux, if dbus-enabled, we'll need to do some dbus spelunking to get the portal version number and only return true for modeGetFolder if that version number is greater or equal to 3.

Assignee: nobody → mconley
Attachment #9353007 - Attachment description: WIP: Bug 1852839 - Part 1: Add nsIFilePicker.modeSupported method. r?spohl! → Bug 1852839 - Part 1: Add nsIFilePicker.modeSupported method. r?spohl!
Summary: Add something like nsIFilePicker.modeSupported() → Add something like nsIFilePicker.isModeSupported()
Attachment #9353007 - Attachment description: Bug 1852839 - Part 1: Add nsIFilePicker.modeSupported method. r?spohl! → Bug 1852839 - Part 1: Add nsIFilePicker.isModeSupported method. r?spohl!
Attachment #9353442 - Attachment description: Bug 1852839 - Part 2: Implement nsIFilePicker.modeSupported for the GTK backend. r?stransky → Bug 1852839 - Part 2: Implement nsIFilePicker.isModeSupported for the GTK backend. r?stransky
Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6235d3df9ecf Part 1: Add nsIFilePicker.isModeSupported method. r=spohl https://hg.mozilla.org/integration/autoland/rev/ac93fddded79 Part 2: Implement nsIFilePicker.isModeSupported for the GTK backend. r=emilio
Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c4e3a40b1d54 Part 1: Add nsIFilePicker.isModeSupported method. r=spohl https://hg.mozilla.org/integration/autoland/rev/37701fa21006 Part 2: Implement nsIFilePicker.isModeSupported for the GTK backend. r=emilio
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
Flags: needinfo?(mconley)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: