Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding file_handlers and launch consumer #1005

Closed
wants to merge 31 commits into from
Closed
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e8876d1
Initial skeleton of file handlers
dmurph Sep 8, 2021
c192f5b
Filling out skeleton a bit more
dmurph Sep 13, 2021
5d90d95
cleanup
dmurph Sep 13, 2021
0c776d2
Apply suggestions from code review
dmurph Sep 16, 2021
c4bdc45
responding to comments
dmurph Sep 16, 2021
e8fbf0f
added section for launching file handler
dmurph Sep 16, 2021
de162c0
better concepts?
dmurph Sep 17, 2021
0cb99c7
comments, parsing accept, and trying to cite MIMETYPE
dmurph Sep 20, 2021
6751b21
forgot one comment
dmurph Sep 20, 2021
da157af
Moved execution to new section, and finalized
dmurph Sep 24, 2021
d964c0d
comments
dmurph Sep 29, 2021
3e1451b
added file handle 'read' clarification
dmurph Sep 29, 2021
d089331
comments from Jake
dmurph Oct 6, 2021
76082ec
Make some refinements across the board.
Feb 11, 2022
1a35bdd
Merge branch 'w3c:gh-pages' into file-handling
evanstade Feb 11, 2022
f64fc16
Add section for launch queue and launch params
loubrett Feb 17, 2022
f7b32e9
Add section for launch queue and launch params
loubrett Feb 17, 2022
1da420d
Add algorithm for matching file handler item.
Feb 26, 2022
4903da0
Address comments
loubrett Mar 1, 2022
63a06b0
dmurph review
Mar 1, 2022
d1916e2
Comments
loubrett Mar 2, 2022
603b58f
Update index.html
evanstade Mar 2, 2022
dea41ae
Merge pull request #1 from loubrett/file-handling
evanstade Mar 2, 2022
57c0677
Merge branch 'file-handling' of https://github.com/dmurph/manifest in…
Mar 2, 2022
d2b6298
Merge and tidy up
Mar 2, 2022
9af6b9a
Merge pull request #2 from evanstade/file-handling
evanstade Mar 2, 2022
4832e53
update algo for multilaunch
Mar 15, 2022
ed5930f
.
Mar 15, 2022
8061a4e
Edits for clarity
Mar 15, 2022
f9b42fd
Edits for clarity
Mar 15, 2022
0d29fd1
Changes subsequent to Marcos review.
Mar 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,158 @@ <h3>
conventions or limitations of the host operating system.
</p>
</section>
<section>
<h3>
`file_handlers` member
</h3>
<p>
The [=manifest's=] <code><dfn data-export="" data-dfn-for=
"manifest">`file_handlers`</dfn></code> member is a [=list=] that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"manifest">`file_handlers`</dfn></code> member is a [=list=] that
"manifest">file_handlers</dfn></code> member is a [=list=] that

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

represents URLs within the app that handles launches of given [=file
dmurph marked this conversation as resolved.
Show resolved Hide resolved
types=].
</p>
<p>
A <dfn>file type</dfn> refers to file that has a [=mime type=] and/or
dmurph marked this conversation as resolved.
Show resolved Hide resolved
ends with a [=file extension=]. A <dfn>file extension</dfn> is a
string that start with a "." and only contains [=valid suffix code
points=]. A <dfn>valid suffix code point</dfn> is a [=code point=]
that is [=ASCII alphanumeric=], U+002B (+), or U+002E (.).
Additionally, [=file extensions=] are are limited to a length of 16
code points.
</p>
<aside class="note">
<p>
Note: These code points were chosen to support most pre-existing
file formats. The vast majority of file extensions are purely
alphanumeric, but compound extensions (such as .tar.gz) and
extensions such as .c++ for C++ source code are also fairly common,
hence the inclusion of + and . as allowed code points.
</p>
</aside>
<p>
How file handlers are registered and disambiguated is at the
discretion of the operating system.
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</p>
<p>
To <dfn>process the `file_handlers` member</dfn>, given [=ordered
map=] |json:ordered map|, and [=ordered map=] |manifest:ordered map|:
</p>
<ol class="algorithm">
<li>Let |processedFileHandlers:list| be a new [=list=].
</li>
<li>Set |manifest|["file_handlers"] to |processedFileHandlers|.
</li>
marcoscaceres marked this conversation as resolved.
Show resolved Hide resolved
<li>If |json|["file_handlers"] doesn't [=map/exist=] or
|json|["file_handlers"] is not a [=list=], return.
</li>
<li>[=list/For each=] |entry:ordered map| of |json|["file_handlers"]:
<ol>
<li>Let |file_handler:ordered map| be [=process a file handler
item=] with |entry|.
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</li>
<li>If |file_handler| is failure, continue.
</li>
<li>[=list/Append=] |file_handler| to |processedFileHandlers|.
</li>
</ol>
</li>
</ol>
<p>
On [=installation=], a user agent SHOULD register the file handlers

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the technical definition of SHOULD is. For example, on Linux some of these things don't happen, i.e. we don't intend to support iconography on Linux. Does that fit within the definition of SHOULD?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "that are consistent with" here provides some wiggle room based on the OS. I'm not an expert in this though.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this language was suggested by @inexorabletash

with the operating system via interactions that are consistent with:
</p>
<ul>
<li>The [=file handler/icon=] and [=file handler/name=] appear in the
host operating system surfaces presenting options for opening files,
for example within "Open with..." context menus for associated file
types.
</li>
<li>The [=file handler/icon=] appears as the icon of associated files
in the host operating system.
</li>
<li>File types with multiple possible handlers can be disambiguated
dmurph marked this conversation as resolved.
Show resolved Hide resolved
by UX provided by the operating system.
</li>
</ul>
<p>
A user agent MAY prevent registered file handlers from registering as
the 'default' file handler for a given type if the operating system
allows.
</p>
<section data-cite="file-system-access">
<h2>
<dfn>Execute a file handler launch</dfn>
</h2>
<p>
This is the IDL used for executing a file handling launch:
</p>
<pre class="idl">
partial interface Window {
readonly attribute LaunchQueue launchQueue;
};

callback LaunchConsumer = any (LaunchParams params);

[Exposed=Window] interface LaunchQueue {
undefined setConsumer(LaunchConsumer consumer);
};

[Exposed=Window] interface LaunchParams {
readonly attribute FrozenArray&lt;FileSystemHandle&gt; files;
};
</pre>
<p>
When a [=file type=] is registered with a web app and one or more
of these registered files are launched on the platform, run the
following steps, given the launched {{FrozenArray}} of
{{FileSystemHandle}}s |files:FrozenArray&lt;FileSystemHandle&gt;|
and the corresponding [=file handler|file_handler=].
</p>
<ol>
<li>Let |url| be the |file_handler|.[=file handler/action=].
</li>
<li>Let |browsing context| be the result of creating a new
[=top-level browsing context=].
</li>
<li>[=Navigate=] |browsing context| to |url|.
</li>
<li>XXX Wait for navigation to be complete?
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</li>
<li>Let |params:LaunchParams| be {{LaunchParams}} with
{{LaunchParams.files}} set to |files|.
</li>
<li>Iterate through every {{LaunchConsumer}} set by
{{LaunchQueue/setConsumer}} and execute the function with |params|.
</li>
</ol>
</section>
<section>
<h3>
Privacy consideration: Default [=file handler=].
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</h3>
<p>
Depending on the operating system capabilities, the [=manifest/file
handler=] could become a 'default' handler (e.g. handling launches
of a given file type automatically) of a given [=file type=]
without the explicit knowledge of the user. To protect against
possible mis-use, user agents MAY choose to offer the user the
dmurph marked this conversation as resolved.
Show resolved Hide resolved
functionality to not launch the web application, or even unregister
a given file handler for a web application.
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</p>
</section>
<section>
<h3>
Privacy consideration: Name and icon.
</h3>
<p>
The name and icon of each file handler can be sensitive to privacy
and security, as there isn't a specified way for the user to see
and confirm these. Due to this, user agents MAY choose to replace
these with name and icon derived from the application's icon and
dmurph marked this conversation as resolved.
Show resolved Hide resolved
name in the [=process a file handler item=] algorithm.
</p>
</section>
</section>
<section>
<h2>
Manifest life-cycle
Expand Down Expand Up @@ -1118,6 +1270,9 @@ <h3>
<li>[=Process the `shortcuts` member=] passing |json|, |manifest|,
and |manifest URL|.
</li>
<li>[=Process the `file_handlers` member=] passing |json|,
dmurph marked this conversation as resolved.
Show resolved Hide resolved
|manifest|.
</li>
<li>[=application manifest/Processing extension-point=]: process
any proprietary and/or other supported members at this point in the
algorithm.
Expand Down Expand Up @@ -1787,6 +1942,147 @@ <h2>
</ol>
</section>
</section>
<section>
<h2>
File Handler Items
</h2>
<p>
Each <dfn data-local-lt="file handler's">file handler</dfn> represents
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ReSpec require the lt? Can you put the 's outside the link where used instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm matching how it works for shortcut items in this spec here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

a URL in the scope of the application that can handle launches with
[=file types=] it accepts. It has the following members:
</p>
<ul>
<li>[=file handler/action=]
</li>
<li>[=file handler/name=]
</li>
<li>[=file handler/accepts=]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: accept (here and several other places)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

</li>
<li>[=file handler/icons=]
</li>
</ul>
<p>
A user agent can use these members to associate the web application
with [=file type=] on the operating system.
</p>
<aside class="note">
<p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note sounds somewhat normative....

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deleted this text because I believe the idea of it is covered by the normative text under #registering-file-handlers

The disambiguation of file handlers and selecting of default file
dmurph marked this conversation as resolved.
Show resolved Hide resolved
handlers is functionality left to the operating system.
</p>
</aside>
<section>
<h3>
`action` member
</h3>
<p>
The [=file handler's=] <code><dfn data-dfn-for=
"file handler">action</dfn></code> member is a <a>string</a> that
represents a relative URL of the [=manifest/start_url=] origin that
Copy link
Member

@marcoscaceres marcoscaceres Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be resolved relative to the manifest's URL instead (like other URLs in the manifest).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching, done.

is [=manifest/within scope=] of a [=Document/processed manifest=].
This URL will be navigated to in the steps to [=execute a file
handler launch=].
</p>
</section>
<section>
<h3>
`name` member
</h3>
<p>
The [=file handler's=] <code><dfn data-dfn-for=
"file handler">name</dfn></code> member is a <a>string</a> that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should work:

Suggested change
"file handler">name</dfn></code> member is a <a>string</a> that
"manifest/file_handler">name</dfn></code> member is a <a>string</a> that

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This suggestion errors to be displayed whereas the current format works as expected. Is there a problem with the current format?

represents a name to be provided to the user's operating system for
use with "Open with..." UX flows. This MAY be replaced by the user
dmurph marked this conversation as resolved.
Show resolved Hide resolved
agent for privacy & security reasons.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of privacy/security issues with the name member, did you have particular issues in mind?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. can customize the text in window's explorer for a file type, right? It shows up as text on the OS, but maybe it's not an issue?

"Infected File - Please Launch to Fix" or something else to encourage users to launch the file? IDK though - less direct than icon.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fiddled with this section a bit.

</p>
</section>
<section>
<h3>
`accept` member
</h3>
<p>
The [=file handler's=] <code><dfn data-dfn-for=
"file handler">accept</dfn></code> member is a <a>dictionary</a>
mapping [=MIME types=] to a list of extensions. Extensions have to be
strings that start with a "." and only contain [=valid suffix code
points=]. Additionally extensions are limited to a length of 16 code
points.
</p>
<p>
In addition to complete MIME types, "*" can be used as the subtype of

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we link to the definition of a parseable mime type?

Also, I don't think we want to handle mime type parameters, and it's worth noting that the type must be one of these: https://source.chromium.org/chromium/chromium/src/+/main:net/base/mime_util.cc;l=587-591?q=IsValidTopLevelMimeType&ss=chromium

a MIME type to match, for example, all image formats with "image/*".
</p>
<p>
Websites SHOULD always provide both [=MIME types=] and file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mime type is required

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know what you think now

extensions for each accepts entry. This format is required by
operating systems that use [=MIME types=] to specify the [=file
types=]. On platforms that only use extensions, these can easily be
used instead.
</p>
</section>
<section>
<h3>
`icons` member
</h3>
<p>
The <a>file handler</a>'s <code><dfn data-dfn-for=
"file handler">icons</dfn></code> member lists images that serve as
graphical representations of a [=file type=] on a platform. This MAY
be replaced by the user agent for privacy & security reasons.
</p>
</section>
<section>
<h2>
Processing file handler items
</h2>
<p>
To <dfn>process a file handler item</dfn>, given [=ordered map=]
|item:ordered map|, [=URL=] |start_url:URL|, [=URL=] |scope:URL|, and
[=URL=] |manifest URL:URL|.
</p>
<ol class="algorithm">
<li>Return failure if it's the case that:
<ul>
<li>|item| is not [=ordered map=].
</li>
<li>|item|["action"] doesn't [=map/exist=] or is not a
[=string=].
</li>
<li>|item|["name"] doesn't [=map/exist=] or is the empty string.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name should be optional

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

</li>
<li>|item|["accepts"] doesn't [=map/exist=].
</li>
<li>|item|["accepts"] is not a [=sequence=].
</li>
<li>|item|["accepts"] is an empty [=sequence=].
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</li>
</ul>
</li>
<li>Let |url:URL| be the result of [=URL Parser|parsing=]
|item|["action"] with |start_url URL| as the base URL.
</li>
<li>If |url| is failure, return failure.
</li>
<li>If |url| is not [=manifest/within scope=] of |scope|, return
failure.
</li>
<li>TODO - process "accepts"
</li>
<li>Let |file_handler:ordered map| be |ordered map| «[ "action" →
|url|, "name" → |item|["name"] ]».
</li>
<li>[=Process image resources=] passing |item|["icons"],
|file_handler|, |manifest URL|, and "icons".
</li>
<li>The user agent MAY replace |file_handler|["icons"] and
|file_handler|["name"] with the application icon and a string
containing the application name, respectively.
dmurph marked this conversation as resolved.
Show resolved Hide resolved
</li>
<li>Return |file_handler|.
</li>
</ol>
</section>
</section>
<section>
<h2>
External application resource
Expand Down