Closed Bug 1421190 Opened 7 years ago Closed 7 years ago

Implement extension event API for user reading file: URL

Categories

(WebExtensions :: General, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1356397

People

(Reporter: danny0838, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0
Build ID: 20171024165158

Steps to reproduce:

N/A


Actual results:

N/A


Expected results:

A frequently requested of filesystem access functionality is to load the file content when the user explicitly specified. For example, when the user opens a file with Firefox, the user opens a directory with Firefox and then clicks on a listed file, or the user enters or pastes a file URL in the address bar to view it.

Currently, if the opened file is a web page and the extension has activeTab permission, it can inject contentScript to access the DOM. However, if the file is not a web page, Firefox simply prompts a dialog to ask for download, and the extension cannot access the file content.

As a result, an extension can never allow the user to double click to open a MAFF, EPUB, or similar file in Firefox. The currently nearest approach available is to let the user open an extension page, drag a file into it, and then process it, which is very inconvenient.

In contrast, in Chrome, the extension can use a onBeforeRequest to redirect the file URL request of a file with specific extension to an extension page, and read the file content via AJAX or so, if "Allow access to file URL" is checked.

I have checked this page: https://wiki.mozilla.org/WebExtensions/Filesystem, and it seems that there's no active plan to support such feature.

Suggestion: Implement an event API onUserOpenFile, which fires when the user visits a file URL, and provides a param FilesystemFileEntry or FilesystemDirectoryEntry object of the file or directory corresponding to the file URL the user explicitly specified, and allows a redirect like onBeforeRequest. In this way the extension can handle a local file/directory the user explictly requested without have to be granted permission of full filesystem access.
Severity: normal → enhancement
Component: Untriaged → WebExtensions: General
Product: Firefox → Toolkit
I think the use case presented here would be better addressed by bug 1356397 (that would also work for maff/epub/etc files loaded over the network as well as just from the filesystem)
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.