Re: [storage] Allow script to request permission only if there would be no prompt (#9)

If a site assumed `persistentPermission() => "granted"` indicates the storage is persistent it would not bother to call `requestPersistent()`:

```js
navigator.storage.persistentPermission()
  .then(function(permission) {
    if (permission === 'default') {
      return navigator.storage.requestPermission();
    } else if (permission === 'denied') {
      // oh well
      return false;
    } else if (permission === 'granted') {
      // yay!
      return true;
    }
  })
  .then(function(hasPersistent) {
   // ...
  });
```
Now, obviously, if the goal is just to get the permission, the above is silly - the script should simply call `requestPermission()` and be done with it. But an extremely common practice (on mobile, at least) is to determine if the user will be prompted and, if so, have a UX flow that explains the benefits of accepting before the request is made.

If it's not the case that `granted` implies that the storage is persistent, it seems like we need Yet Another Way to query the state without changing it, so it's possible for the origin to introspect.


---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/storage/issues/9#issuecomment-132277082

Received on Tuesday, 18 August 2015 16:57:25 UTC