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

Remove clipboard-write permission #164

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
76 changes: 6 additions & 70 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,11 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=]
saschanaz marked this conversation as resolved.
Show resolved Hide resolved

1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException
1. If |r| is not true, then reject |p| with a "NotAllowedError" DOMException
saschanaz marked this conversation as resolved.
Show resolved Hide resolved

1. Let |data| be a copy of the [=system clipboard data=] represented as
a sequence of {{ClipboardItem}}s.

Note: As further described in [[#image-transcode]] this explicitly does not transcode images.
Rather the original unmodified image data should be exposed to the website.

Expand Down Expand Up @@ -650,7 +650,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;

1. Let |r| be the result of running [=check clipboard read permission=] [=in parallel=]

1. If |r| is not "granted", then reject |p| with a "NotAllowedError" DOMException
1. If |r| is not true, then reject |p| with a "NotAllowedError" DOMException

1. Let |data| be a copy of the [=system clipboard data=].

Expand Down Expand Up @@ -920,54 +920,7 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
</div><!-- algorithm -->


<h2 id="clipboard-permissions">Permissions API Integration</h2>

The [[permissions]] API provides a uniform way for websites to access
<a>powerful feature</a>s like the clipboard. It allows websites to request permissions
from users and query which permissions they have.

For the clipboard, one permission is defined:
<dfn enum-value for="PermissionName">"clipboard-write"</dfn>

Note: Clipboard permissions currently only apply to the Async Clipboard API.
Future versions of this specification may be updated to apply this permission
to other Clipboard interactions.

These clipboard permissions are <a>powerful feature</a>s
permission-related algorithms and types are defined as follows:

<dl>
<dt>
<a>permission descriptor type</a>
</dt>
<dd>
<pre class="idl">
dictionary ClipboardPermissionDescriptor : PermissionDescriptor {
boolean allowWithoutGesture = false;
};
</pre>
</dd>

There are 4 clipboard permissions:

* { name: "clipboard-write", allowWithoutGesture: false }
* { name: "clipboard-write", allowWithoutGesture: true }

With the following relationships:

* <code>{ "clipboard-write" + true }</code> is stronger than <code>{ "clipboard-write" + false }</code>

While user agents MUST support the {{ClipboardPermissionDescriptor}} as described
in this specification, they, of course, retain complete control over the default
settings and how (or if) they are exposed to the user.

<div class="example">
A user agent that wants to have separate user-settable write controls over the clipboard
and always require a user gesture would handle each descriptor as follows:

* <code class="perm">{ "clipboard-write" + false }</code> is exposed for user control
* <code class="perm">{ "clipboard-write" + true }</code> is always <a>denied</a>
</div>
<h2 id="clipboard-permissions">Permission checks</h2>

<h3 id="read-permission">Clipboard read permission</h3>

Expand All @@ -993,34 +946,17 @@ urlPrefix: https://w3c.github.io/FileAPI/#dfn-; type: dfn;
<div class="algorithm" data-algorithm="clipboard-write-permission">
<h4 id="h-clipboard-write-permission"><dfn>check clipboard write permission</dfn></h4>

1. Let |writeWithoutGesture| be the [=permission state=] of the
<code>{ name: "clipboard-write", allowWithoutGesture: true }</code>
permission.

1. If |writeWithoutGesture| is <a>granted</a>, then return true.

1. Let |hasGesture| be true if the [=relevant global object=] of [=this=]
has [=transient activation=], false otherwise.

1. If |hasGesture| then,

<!-- System paste buttons don't require permission -->
1. Let |systemCopy| be true if the current script is running as a result of user
1. Return true if the current script is running as a result of user
interaction with a "cut" or "copy" element created by the user agent or operating
system.

1. If |systemCopy| is true, then return true.

1. Return the result of [=request permission to use=] the
<code>{ name: "clipboard-write", allowWithoutGesture: false }</code>
permission.

Note: User agents may choose to request a stronger permission that
will implicitly update this permission.

1. Return the result of [=request permission to use=] the
<code>{ name: "clipboard-write", allowWithoutGesture: true }</code>
permission.
1. Return false.
saschanaz marked this conversation as resolved.
Show resolved Hide resolved

</div><!-- algorithm -->

Expand Down