Re: [w3c/manifest] Add a means to associate a PWA with a file extension (#626)

Some more thoughts on how this could work: have a manifest field similar to the following

```json
{
    "file_extension_associations": {
        "abc": {
            "name": "My document format",
            "url": "path/to/open/abc",
            "icon": "/abc.png"
        },
        "def": {
            "name": "My other document format",
            "url": "path/to/open/def",
            "icon": "/def.png"
        }
    }
}
```

Notes:
- You can specify more than one kind of file extension association
- `name` is an optional description that can be used in the OS
- `icon` is an optional icon file
- `url` is the optional path to open when launching the PWA to open that file extension; if not provided, simply launches the default URL of the PWA
- all fields are optional, so a file extension association like `"abc": {}` specifies an association with default name (e.g. "ABC file"), default icon, and opens at the default URL of the PWA.

Another question is when should the user be asked if they want to set up a file extension association? Here are some ideas:
- have a user-gesture restricted permission that can be requested
- use browser heuristics, similar to deciding when to show the "add to homescreen" banner
- prompt upon using the following features:
    - downloading a file with a file extension that is present in the manifest (including local downloads using a@download)
    - drag-and-dropping a file with a file extension that is present in the manifest
    - choosing a file in a file input with a file extension that is present in the manifest

Basically any use of a local file with a file extension in the manifest is probably the ideal time to prompt the user to set up file extensions, since it is a strong indicator this would be useful to them if they're already using those kinds of files. That helps make it discoverable and prompt at the most useful time. But I think there ought to be another way to opt-in without having to do that, e.g. requesting a permission in a user gesture. To prevent abuse, the browser could automatically decline if there is not enough engagement (or in cross-origin iframe, etc).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/626#issuecomment-343666937

Received on Saturday, 11 November 2017 14:04:57 UTC