From 9195cb181ec705f03bd42ad03d118d7565fbb69d Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Wed, 25 Mar 2015 10:01:53 +0000 Subject: [PATCH] Have an instance of Permissions on Navigator and WorkerNavigator. Closes issue 11. --- index.html | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 5337ea2..0743723 100644 --- a/index.html +++ b/index.html @@ -153,9 +153,9 @@

handle permissions on the Web platform. Web APIs have different ways to deal with permissions. The [[notifications]] API allows developers to request a permission and check the permission status explicitly. Others - might only expose the status to web pages. Some, like [[geolocation-API]] - will keep the page unaware of the permission associated with the - feature. + might only expose the status to web pages. Some, like + [[geolocation-API]] will keep the page unaware of the permission + associated with the feature.

Being able to know whether an API call is going to prompt is mandatory @@ -410,14 +410,33 @@

+
+

+ Navigator and WorkerNavigator extension +

+

+ A Permissions instance is exposed on the navigator + object for Window and Worker contexts. +

+
+
+ readonly attribute Permissions permissions; +
+
+
+
+ readonly attribute Permissions permissions; +
+
+

Permissions interface

- static Promise<PermissionStatus> query((Permission or - PermissionName) permission) + Promise<PermissionStatus> query(PermissionName name)

@@ -427,17 +446,12 @@

the following steps:

    -
  1. Let permission be permission argument if - permission is of type Permission, otherwise, - create a Permission instead for which name is - set to the permission argument value. -
  2. Let promise be a newly-created Promise.
  3. Return promise and continue those steps asynchronously.
  4. Run the steps to create a PermissionStatus using the - global object and permission and resolve + global object and name and resolve promise with the result of those steps.
@@ -445,8 +459,8 @@

If a developer wants to check multiple permissions at once, the editors recommend them to use Promises.all(). It should yield to the same result and allow this API to stay simple. If it happens to be a very - common use case, it should be easy to extend Permissions.query() to - accept a sequence<> too. + common use case, it should be easy to extend + permissions.query() to accept a sequence<> too.

@@ -460,7 +474,7 @@

 <script>
-  Permissions.query('geolocation').then(function(result) {
+  navigator.permissions.query('geolocation').then(function(result) {
     if (result.status == 'granted') {
       showLocalNewsWithGeolocation();
     } else if (result.status == 'prompt') {
@@ -482,7 +496,7 @@ 

document.getElementById('chat-notification-button').disabled = (permission.status == 'denied'); } - Permissions.query('notifications').then(function(result) { + navigator.permissions.query('notifications').then(function(result) { updateNotificationButton(result); result.addEventListener('change', function() { @@ -493,7 +507,6 @@

-

Acknowledgments