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

Add canShare() method #177

Merged
merged 19 commits into from
Aug 20, 2021
Merged
Changes from all commits
Commits
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
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ <h2>
display a picker or chooser dialog, allowing the user to select a
target to share this title and the page URL to.
</p>
<p>
Calling {{Navigator/canShare()}} method with a {{ShareData}} dictionary
[=validate share data|validates=] the shared data. unlike
{{Navigator/share()}}, it can be called without [=transient
activation=].
</p>
<pre class="js example">
const file = new File([], "some.png", { type: "image/png" });

// Check if files are supported
if (navigates.canShare({files: [file]})) {
// Sharing a png file would probably be ok...
}

// Check if a URL is ok to share...
if (navigates.canShare({ url: someURL })) {
// The URL is valid and can probably be shared...
}
</pre>
</section>
<section>
<h2>
Expand All @@ -104,6 +123,8 @@ <h3>
<pre class="idl">
partial interface Navigator {
[SecureContext] Promise&lt;undefined&gt; share(optional ShareData data = {});

[SecureContext] boolean canShare(optional ShareData data = {});
};
</pre>
<p>
Expand Down Expand Up @@ -257,6 +278,25 @@ <h4>
or bypassing the UI if there is only a single share target.
</div>
</section>
<section>
<h3>
`canShare(data)` method
Copy link
Member

Choose a reason for hiding this comment

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

Should this be marked as historical if we think this is a broken approach?

Copy link
Member Author

Choose a reason for hiding this comment

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

Only if we are not going to ship an alternative - but I don't think anyone plans to.

Copy link
Member

Choose a reason for hiding this comment

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

Only if we are not going to ship an alternative

Are going to?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, yes... there is no plans for any engine to ship anything different. Let's just ship this and be done for now. If we need a new method, we can add it when there is demand for it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think Gecko would want to ship anything proven to be broken as a sole solution 🤔

cc @annevk, context: #108 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's ok, but if we can't shift the other implementers then we need to make a process call here (i.e., Mozilla can "formally object" and we figure it out from there).

We have two engines that already ship .canShare() already (and have now for over a year).

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 it depends on real world usage of canShare.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, that too... however, we (you and I) are kinda limited in that we can't actually get that data.

We are at an impasse here :( without input from other implementers willing to change (or even respond to issues), I don't know what we can do 😭

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are right, that too... however, we (you and I) are kinda limited in that we can't actually get that data.

https://chromestatus.com/metrics/feature/timeline/popularity/2737

</h3>
<p>
When the <dfn>canShare(data)</dfn> method is called with argument
{{ShareData}} |data:ShareData|, run the following steps:
</p>
<ol class="algorithm">
<li>If the [=current settings object=]'s [=environment settings
object/responsible document=] is not <a>allowed to use</a>
<a>"web-share"</a>, return false.
</li>
<li>Return the result of [=validate share data=] with |data| and
[=this=]'s [=relevant settings object=]'s [=environment settings
object/API base URL=].
</li>
</ol>
</section>
<section>
<h3>
Validate share data
Expand Down