W3C home > Mailing lists > Public > public-geolocation@w3.org > March 2011

Re: Mechanism to determine whether location is currently being shared

From: Andrei Popescu <andreip@google.com>
Date: Thu, 3 Mar 2011 13:01:50 +0000
Message-ID: <AANLkTikv-kBJphtq42tC+TN7x4R2BFnJt8WjdgHEg8xQ@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: public-geolocation@w3.org, olalonde@gmail.com
Hi Tab,

Thanks for the comments!

On Wed, Mar 2, 2011 at 10:02 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> Heya, Geoloc people!
>
> (Note: I am not subscribed to this list, nor is the developer that I
> discussed this issue with (cc'd).  Please ensure that I and the cc'd
> developer stay on the cc list for this thread.)
>
> A developer recently asked me for some way to tell, in the
> getCurrentPosition callback, whether the permission grant was due to
> the user actually seeing the permissions prompt and clicking "Allow"
> (or the equivalent), or if it was an automatic grant due to the user
> previously granting the site permanent access to their location.  This
> can alternately be cast as a request to know if the user has already
> granted permission to grab their location, such that a call to
> getCurrentPosition() will return a position without prompting the
> user, or not.
>

I see. There is this Feature Permissions spec:

http://dev.w3.org/2006/webapi/WebNotifications/publish/FeaturePermissions.html

but it hasn't been updated in a while. Do you happen to know what is
the status with that spec? It looks like it would solve your problem?

> By carefully reading the Geolocation spec, I learned that this case
> had already thought about, and can be addressed as follows:
>
> Geolocation.getCurrentPosition(
>  function(){ /* This fires if the user has previously granted permission.*/ },
>  function(){ /* This fires if they didn't. */ },
>  { maximumAge: 1e20, timeout: 0 }
> );
>
> However, this still misses one case - when the user has already
> granted permission to share their location, but there are no cached
> positions.  This can happen if, for example, the user instructs their
> browser to always share their location, or if the browser's position
> cache is cleaned (either automatically or at the user's instruction).
>
> As well, having to specify an arbitrary large value for maximumAge to
> ensure that you'll get a cached position if one exists is pretty
> hacky.
>
> Finally, it requires careful reading of the spec to determine that
> this is even possible.  An example or two would have helped.  ^_^
>

Yeah, we had quite a lot of discussions on this topic and concluded
that this was the cleanest way. In fact, we have examples for all
scenarios (as far as I can tell) in the Introduction section:

http://dev.w3.org/geo/api/spec-source.html#introduction

Please see "Forcing the user agent to return any available cached position".

> I propose that Geolocation address this use-case directly, either by
> providing a boolean property on Geolocation reflecting whether the
> user has granted the site permission to grab their location, or a
> function that takes a single callback and provides the boolean value
> as an argument to the callback.
>

Hmm, since there is already a spec that addresses this problem,
perhaps it's best to let our spec as it is? The issue isn't specific
to Geolocation so I think it makes sense to treat it in a generic way.

Thanks,
Andrei
Received on Thursday, 3 March 2011 13:02:20 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:51:02 UTC