Skip to content

Commit 3fa8869

Browse files
author
Alvin Ji
committed
feat: Define custom permission flow for geolocation
1 parent 9578188 commit 3fa8869

File tree

1 file changed

+82
-18
lines changed

1 file changed

+82
-18
lines changed

index.html

Lines changed: 82 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ <h3>
562562
</section>
563563
<section id="check-permission">
564564
<h2>
565-
Checking permission to use the API
565+
<dfn data-local-lt="check permission">Checking permission to use the
566+
API</dfn>
566567
</h2>
567568
<p>
568569
<cite>Geolocation</cite> is a [=default powerful feature=] identified
@@ -572,24 +573,87 @@ <h2>
572573
for [=approximate position=].
573574
</p>
574575
<p>
575-
When a website requests location access, the user agent [=check
576-
permission|checks permission=] for the level of accuracy specified by
577-
the {{PositionOptions/accuracyMode}} option. A grant for the
578-
"geolocation" permission implies a grant for the
579-
"geolocation-approximate" permission, while if the
580-
"geolocation-approximate" is denied, then so is "geolocation".
576+
To <dfn>request geolocation permission</dfn> for a given
577+
{{PermissionDescriptor}} |descriptor|, the user agent MUST run the
578+
following steps. These steps override the default behavior of
579+
[=request permission to use=] for these features.
581580
</p>
581+
<ol class="algorithm">
582+
<li>If |descriptor|.{{PermissionDescriptor/name}} is "geolocation":
583+
<ol>
584+
<li>Prompt the user to choose between granting permission for
585+
[=precise position=], granting permission for [=approximate
586+
position=], or denying permission.
587+
</li>
588+
<li>If the user grants permission for [=precise position=]:
589+
<ol>
590+
<li>Set the permission state of "geolocation" to "granted".
591+
</li>
592+
<li>Set the permission state of "geolocation-approximate" to
593+
"granted".
594+
</li>
595+
<li>Return "granted".
596+
</li>
597+
</ol>
598+
</li>
599+
<li>If the user grants permission for [=approximate position=]:
600+
<ol>
601+
<li>Set the permission state of "geolocation-approximate" to
602+
"granted".
603+
</li>
604+
<li>Return "prompt".
605+
</li>
606+
</ol>
607+
</li>
608+
<li>If the user denies permission:
609+
<ol>
610+
<li>Set the permission state of "geolocation" to "denied".
611+
</li>
612+
<li>Set the permission state of "geolocation-approximate" to
613+
"denied".
614+
</li>
615+
<li>Return "denied".
616+
</li>
617+
</ol>
618+
</li>
619+
</ol>
620+
</li>
621+
<li>If |descriptor|.{{PermissionDescriptor/name}} is
622+
"geolocation-approximate":
623+
<ol>
624+
<li>Prompt the user to choose between granting permission for
625+
[=approximate position=] or denying permission.
626+
</li>
627+
<li>If the user grants permission for [=approximate position=]:
628+
<ol>
629+
<li>Set the permission state of "geolocation-approximate" to
630+
"granted".
631+
</li>
632+
<li>Return "granted".
633+
</li>
634+
</ol>
635+
</li>
636+
<li>If the user denies permission:
637+
<ol>
638+
<li>Set the permission state of "geolocation" to "denied".
639+
</li>
640+
<li>Set the permission state of "geolocation-approximate" to
641+
"denied".
642+
</li>
643+
<li>Return "denied".
644+
</li>
645+
</ol>
646+
</li>
647+
</ol>
648+
</li>
649+
</ol>
582650
<p>
583-
When <dfn data-local-lt="check permission">checking permission</dfn>
584-
to use the API, a user agent SHOULD present the user with a choice to
585-
grant access to their [=precise position=], their [=approximate
586-
position=], or to deny the request. A user agent MAY also suggest
587-
time-based [=permission=] [=permission/lifetimes=], such as "24
588-
hours", "1 week", or choose to remember the permission
589-
[=permission/grant=] indefinitely. However, it is RECOMMENDED that a
590-
user agent prioritize restricting the [=permission=]
591-
[=permission/lifetime=] to a single session: This can be, for
592-
example, until the [=environment settings object/realm=] is
651+
A user agent MAY also suggest time-based [=permission=]
652+
[=permission/lifetimes=], such as "24 hours", "1 week", or choose to
653+
remember the permission [=permission/grant=] indefinitely. However,
654+
it is RECOMMENDED that a user agent prioritize restricting the
655+
[=permission=] [=permission/lifetime=] to a single session: This can
656+
be, for example, until the [=environment settings object/realm=] is
593657
destroyed, the end-user [=navigates=] away from the [=origin=], or
594658
the relevant browser tab is closed.
595659
</p>
@@ -881,7 +945,7 @@ <h2>
881945
</li>
882946
<li>[=In parallel=]:
883947
<ol>
884-
<li>Set |permission| to [=request permission to use=]
948+
<li>Set |permission| to [=request geolocation permission=] for
885949
|descriptor|.
886950
</li>
887951
<li>Let |handle permission denial| be the following steps:

0 commit comments

Comments
 (0)