Skip to content

Commit 6ed85d1

Browse files
Integrate with Permissions API (#341)
1 parent 772c0fe commit 6ed85d1

File tree

1 file changed

+28
-64
lines changed

1 file changed

+28
-64
lines changed

index.html

Lines changed: 28 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
};
5151
</script>
5252
</head>
53-
<body data-cite="service-workers FILEAPI secure-contexts hr-time ECMASCRIPT">
53+
<body data-cite="service-workers FILEAPI secure-contexts hr-time permissions ECMASCRIPT">
5454
<section id="abstract">
5555
<p>
5656
The <cite>Push API</cite> enables sending of a <a>push message</a> to a web application via
@@ -303,9 +303,24 @@ <h2>
303303
Permission
304304
</h2>
305305
<p>
306-
The term <dfn>express permission</dfn> refers to an act by the user, e.g. via user
307-
interface or host device platform features, via which the user approves the use of the
308-
Push API by the web application.
306+
The Push API is a [=powerful feature=], requiring [=express permission=] to be used.
307+
</p>
308+
<p>
309+
For integration with the [[[Permissions]]] specification, this specification defines the
310+
{{PushPermissionDescriptor}} [=powerful feature/permission descriptor type=].
311+
</p>
312+
<pre class="idl">
313+
dictionary PushPermissionDescriptor : PermissionDescriptor {
314+
boolean userVisibleOnly = false;
315+
};
316+
</pre>
317+
<p data-dfn-for="PushPermissionDescriptor">
318+
The <dfn>userVisibleOnly</dfn> has the same semantics as
319+
{{PushSubscriptionOptionsInit/userVisibleOnly}}.
320+
</p>
321+
<p>
322+
`{name: "push", userVisibleOnly: false}` is [=PermissionDescriptor/stronger than=]
323+
`{name: "push", userVisibleOnly: true}`.
309324
</p>
310325
</section>
311326
</section>
@@ -518,7 +533,7 @@ <h2>
518533

519534
Promise&lt;PushSubscription&gt; subscribe(optional PushSubscriptionOptionsInit options = {});
520535
Promise&lt;PushSubscription?&gt; getSubscription();
521-
Promise&lt;PushPermissionState&gt; permissionState(optional PushSubscriptionOptionsInit options = {});
536+
Promise&lt;PermissionState&gt; permissionState(optional PushSubscriptionOptionsInit options = {});
522537
};
523538
</pre>
524539
<p>
@@ -570,13 +585,9 @@ <h2>
570585
|promise| with a {{DOMException}} whose name is {{"InvalidStateError"}} and terminate these
571586
steps.
572587
</li>
573-
<li>Ask the user whether they allow the web application to receive <a>push messages</a>,
574-
unless a prearranged trust relationship applies or the user has already granted or denied
575-
permission explicitly for this web application. Note that a <a>user agent</a> that needs to
576-
request permission might be unable to do so if {{PushManager/subscribe}} is invoked from a
577-
service worker, in which case permission will be denied automatically.
588+
<li>Let |permission| be [=request permission to use=] "push".
578589
</li>
579-
<li>If not granted, reject |promise| with a {{DOMException}} whose name is
590+
<li>If |permission| is "denied", reject |promise| with a {{DOMException}} whose name is
580591
{{"NotAllowedError"}} and terminate these steps.
581592
</li>
582593
<li>If the <a>Service Worker</a> is already subscribed, run the following substeps:
@@ -630,21 +641,20 @@ <h2>
630641
</li>
631642
</ol>
632643
<p>
633-
The <dfn data-dfn-for="PushManager">permissionState</dfn> method when invoked MUST run the
634-
following steps:
644+
The <dfn data-dfn-for="PushManager">permissionState()</dfn> method when invoked MUST run
645+
the following steps:
635646
</p>
636647
<ol>
637648
<li>Let |promise| be <a>a new promise</a>.
638649
</li>
639650
<li>Return |promise| and continue the following steps asynchronously.
640651
</li>
641-
<li>Retrieve the push permission status (<a>PushPermissionState</a>) of the requesting web
642-
application.
652+
<li>Let |descriptor| be a new {{PermissionDescriptor}} with the
653+
{{PermissionDescriptor/name}}} initialized to "push".
643654
</li>
644-
<li>If there is an error, reject |promise| with no arguments and terminate these steps.
655+
<li>let |state| be the [=permission state=] of |descriptor| and the result.
645656
</li>
646-
<li>When the request has been completed, resolve |promise| with <a>PushPermissionState</a>
647-
providing the push permission status.
657+
<li>Resolve |promise| with |state|.
648658
</li>
649659
</ol>
650660
<p>
@@ -1219,52 +1229,6 @@ <h2>
12191229
</section>
12201230
</section>
12211231
</section>
1222-
<section data-dfn-for="PushPermissionState">
1223-
<h2>
1224-
<dfn>PushPermissionState</dfn> Enumeration
1225-
</h2>
1226-
<pre class="idl">
1227-
enum PushPermissionState {
1228-
"denied",
1229-
"granted",
1230-
"prompt",
1231-
};
1232-
</pre>
1233-
<table class="simple">
1234-
<tr>
1235-
<th>
1236-
Enumeration
1237-
</th>
1238-
<th>
1239-
Description
1240-
</th>
1241-
</tr>
1242-
<tr>
1243-
<td>
1244-
<dfn>granted</dfn>
1245-
</td>
1246-
<td>
1247-
The web application has permission to use the Push API.
1248-
</td>
1249-
</tr>
1250-
<tr>
1251-
<td>
1252-
<dfn>denied</dfn>
1253-
</td>
1254-
<td>
1255-
The web application has been denied permission to use the Push API.
1256-
</td>
1257-
</tr>
1258-
<tr>
1259-
<td>
1260-
<dfn>prompt</dfn>
1261-
</td>
1262-
<td>
1263-
The web application needs to ask for permission in order to use the Push API.
1264-
</td>
1265-
</tr>
1266-
</table>
1267-
</section>
12681232
<section>
12691233
<h2>
12701234
Accessibility

0 commit comments

Comments
 (0)