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 a fourth permission state "grantable without a prompt"? #250

Open
mkruisselbrink opened this issue Jul 19, 2021 · 6 comments
Open

Add a fourth permission state "grantable without a prompt"? #250

mkruisselbrink opened this issue Jul 19, 2021 · 6 comments

Comments

@mkruisselbrink
Copy link

In chrome we have (or will have) some permissions that under certain circumstances are in a state where the permission isn't granted yet, but will be granted without showing a prompt if the permission is requested. That state is not currently something that can really be expressed by the permissions API, with the closest equivalent being simply "prompt". However sometimes websites would really like to know if requesting a permission will actually show a prompt or not, to be able to provide better UI to their users.

Not sure if adding a fourth permission state for this case makes sense, and changing this for existing permissions would likely not be web compatible either, but was mostly wondering what other people think of this...

(currently Chrome uses this state for the Persistent Storage permission, but we're also considering using this in some cases for the file system permission).

@tomayac
Copy link
Contributor

tomayac commented Jul 20, 2021

What is the de facto difference to granted then?

granted: The "granted" state represents that the caller will be able to successfu[l]ly access the feature without having the user agent asking the user’s permission.spec

@marcoscaceres
Copy link
Member

marcoscaceres commented Jul 20, 2021

Maybe we can finally introduce "default" and get it to align with the Notifications API?

Where "default" is: This is equivalent to "denied", but the user has made no explicit choice thus far.

So:

  • "default" - is denied, may be granted without (*maybe!) showing a prompt.
  • "prompt" - is denied, and it will show a prompt.
  • "denied" - denied.
  • "granted" - granted.

@marcoscaceres
Copy link
Member

Noting, in hindsight, "prompt" was probably a mistake, as we shouldn't of tied this to UI at all... but given we are here... "default" might just work. And perhaps we can move more things to "default" without breaking thing.

@mkruisselbrink
Copy link
Author

The difference between granted and this extra state chrome sometimes uses, is that in this "will-be-granted" state you still have to actually request the permission. For the case of persistent storage there isn't really any "accessing the feature" other than requesting permission.

@miketaylr
Copy link
Member

So now we have the following,

Every permission has a default state (usually prompt), which is the state that the permission is in when the user has not yet given express permission to use the feature or it has been reset because its lifetime has expired.

But I'm not sure that solves what @mkruisselbrink is asking for. We want something that means "granted when its been requested, but not yet requested". Maybe "default" is the way to go. Or we spell "default" as "grantable". 🤔

A spec like persistent-storage could define the default as "granted", but I think that would be misleading and then devs wouldn't know they should request it. But maybe Storage is a bad example, because devs can just use navigator.storage.persisted() (where false means "grantable but not yet requested" and true means "granted" instead of navigator.permissions.query()).

@miketaylr
Copy link
Member

Another way to tackling this is to modify https://w3c.github.io/permissions/#dfn-request-permission-to-use to take an optional "override" flag that skips the whole "express permission" thing. I'm not sure it's a great idea, but it's an idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants