Skip to content

Commit

Permalink
Sharing files
Browse files Browse the repository at this point in the history
Add a files member to Web Share dictionary.

Add canShare() so authors can determine if an implementation supports
sharing a given ShareData dictionary. In particular, this allows authors
to determine if an implementation supports sharing files.
  • Loading branch information
ericwilligers committed Oct 10, 2018
1 parent 05a87d5 commit 18e0eff
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions level-2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ <h3>
</p>
<pre class="idl">
partial interface Navigator {
[SecureContext] boolean canShare(optional ShareData data);
[SecureContext] Promise&lt;void&gt; share(optional ShareData data);
};
</pre>
Expand All @@ -123,6 +124,17 @@ <h3>
Clients can use the presence or absence of this method to determine
whether to show UI that triggers its use.
</div>
<section>
<h4>
<dfn>canShare()</dfn> method
</h4>
<p>
<code>canShare(</code><var>data</var><code>)</code> MUST return
<code>true</code> unless
<code>share(</code><var>data</var><code>)</code> would reject with
<a>TypeError</a>, in which case it MUST return <code>false</code>.
</p>
</section>
<section>
<h4>
<dfn>share()</dfn> method
Expand All @@ -136,7 +148,8 @@ <h4>
"!promises-guide#a-new-promise">a new promise</a>.
</li>
<li>If none of <var>data</var>'s members <a>title</a>, <a>text</a>,
or <a>url</a> are present, reject <var>p</var> with
<a>url</a> or (if the implementation supports file sharing)
<a>files</a> are present, reject <var>p</var> with
<a>TypeError</a>, and abort these steps.
</li>
<li>If <var>data</var>'s <a>url</a> member is <a data-cite=
Expand Down Expand Up @@ -218,6 +231,11 @@ <h4>
kind of "always use this target in the future" option, or bypassing
the UI if there is only a single share target.
</div>
<div class="note">
To determine if file sharing is supported by an implementation,
<a>canShare()</a> can be called with a dictionary containing only
<code>files</code>.
</div>
</section>
</section>
<section data-dfn-for="ShareData" data-link-for="ShareData">
Expand All @@ -229,6 +247,7 @@ <h3>
USVString title;
USVString text;
USVString url;
FileList files;
};
</pre>
<p>
Expand All @@ -255,9 +274,17 @@ <h3>
<dd>
A URL string referring to a resource being shared.
</dd>
<dt>
<dfn>files</dfn> member
</dt>
<dd>
A <code><dfn data-cite=
"!FILE-API#filelist-section">FileList</dfn></code> referring to one
or more files being shared.
</dd>
</dl>
<div class="note">
These members are <a data-cite=
The string members are <a data-cite=
"!WEBIDL#idl-USVString"><code>USVString</code></a> (as opposed to
<a data-cite="!WEBIDL#idl-DOMString"><code>DOMString</code></a>)
because they are not allowed to contain invalid <a data-cite=
Expand Down

0 comments on commit 18e0eff

Please sign in to comment.