Closed Bug 1351741 Opened 7 years ago Closed 7 years ago

Add a simple API to open a file dialog without needing to go through content scripts.

Categories

(WebExtensions :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: wisniewskit, Unassigned)

References

Details

Attachments

(1 file)

Attached patch openDialogExt.diff (deleted) — Splinter Review
Consider an extension which wishes to bring up a file picker dialog from the background script (for instance when the user presses a hotkey command).

Right now, the only way (in theory) would be to inject a <input type=file> into the active tab's DOM, trigger a click event on it, then transfer any resulting file objects back to the background script. Unfortunately that isn't always possible to do.

There is not always a content-script available to work with (about: pages, especially about:newtab). Addons would therefore need to open a new tab to be sure they can have a file input to work with. Unfortunately, popups are blocked in addon pages, and that includes the popup triggered when one calls .click on a file input.

Whether or not such popups could be allowed, this all strikes me as needlessly convoluted. The background script should be able to avoid the need for content scripts, opening tabs or messing with the DOM of existing ones, and having to sendMessage a file object (or multiple file objects).

I've attached a quick proof-of-concept patch which just adds a browser.windows.openDialog method. I'm using it for an internal project of mine, and don't mind helping it across the finish line if this proposal is deemed desirable.
You don't need to go through a content script, but you do need to have some UI page visible. It can be a tab page, for example. It can't currently be a popup due to bug 1292701.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
I'm not sure what you mean, could you elaborate? Say the user is looking at about:newtab or about:debugging, and trigger an onCommand via hotkey. How would I open a file dialog in that case?
Flags: needinfo?(kmaglione+bmo)
Product: Toolkit → WebExtensions
Flags: needinfo?(kmaglione+bmo)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: