Closed Bug 1396280 Opened 7 years ago Closed 4 years ago

downloads.download should support filtering based of file extension

Categories

(WebExtensions :: General, enhancement, P5)

enhancement

Tracking

(firefox57 wontfix)

RESOLVED DUPLICATE of bug 1651175
Tracking Status
firefox57 --- wontfix

People

(Reporter: kernp25, Unassigned)

Details

(Whiteboard: [design-decision-approved])

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:57.0) Gecko/20100101 Firefox/57.0
Build ID: 20170902100317




Expected results:

For example:
downloads.download({
  url: "http:example.com/test.pdf",
  filename: "test.pdf",
  saveAs: true
})

The example above should use the filter "*.pdf" instead of Ci.nsIFilePicker.filterAll [1].

Google Chrome also supports filtering based of file extension.

[1] http://searchfox.org/mozilla-central/source/toolkit/components/extensions/ext-downloads.js#522
What do you think?
Flags: needinfo?(aswan)
I don't know much about nsIFilePicker but a filter doesn't seem to make sense for a file picker in "save" mode (as opposed to "open" mode).
Flags: needinfo?(aswan)
Whiteboard: [design-decision-needed]
Severity: normal → enhancement
Priority: -- → P5
Hi kernp25, this has been added to the agenda for the February 13, 2018 WebExtensions APIs triage. Would you be able to join us? 

Here’s a quick overview of what to expect at the triage: 

* We normally spend 5 minutes per bug
* The more information in the bug, the better
* The goal of the triage is to give a general thumbs up or thumbs down on a proposal; we won't be going deep into implementation details

Relevant Links: 

* Wiki for the meeting: https://wiki.mozilla.org/WebExtensions/Triage#Next_Meeting
* Meeting agenda: https://docs.google.com/document/d/1lB8M4WhF2xRrf4A5DlUNkKKiiuxfpxfx6CfHLv-FoAM/edit#
* Vision doc for WebExtensions: https://wiki.mozilla.org/WebExtensions/Vision
(In reply to Andrew Swan [:aswan] from comment #2)
> I don't know much about nsIFilePicker but a filter doesn't seem to make
> sense for a file picker in "save" mode (as opposed to "open" mode).

But Firefox also has a filter when using Save Link/Page feature [1].

[1] https://dxr.mozilla.org/mozilla-central/rev/80ca8e45becbf8f38a06d94d14899947ed834c4d/toolkit/content/contentAreaUtils.js#857-873
The default filter (*) lists all files but with the filter "*.doc" it will only list files with the "doc" extension.
This will improve the list view.
Flags: needinfo?(lgreco)
Whiteboard: [design-decision-needed] → [design-decision-approved]
We discussed about this feature request and we agreed that it can be approved, an the file picker should include both the filter based on the suggested file name and the default "All Files" filter (so that the user can switch the file picked into a mode that shows all the files available in the target this,

I briefly took a look at the chrome behavior on this scenario and I confirm that in Chrome the file picker is set to filter all the file with the same extension of the suggested filename, and the file picker also has the default "All Files" filter.

The underlying nsIFilePicker already supports filters that are specified by providing a filter name and a string which describes the extensions to match:

- https://searchfox.org/mozilla-central/rev/5536f71c3833018c4f4e2c73f37eae635aab63ff/widget/nsIFilePicker.idl#81-89
- https://searchfox.org/mozilla-central/search?q=.appendFilter(&case=false&regexp=false&path=
Flags: needinfo?(lgreco)
Product: Toolkit → WebExtensions

This was implemented in bug 1651175

Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.