fune/dom/geolocation/GeolocationSystem.h
David Parks 5f342def31 Bug 1900225: Part 6 - Wait for Windows permission dialog to be dismissed before requesting geolocation r=emilio,win-reviewers,gstoll a=RyanVM
When Windows presents the dialog asking the user to give geolocation permission
to Firefox, we need to wait for the user to make a choice before running the
geolocation request.    Previously, we were not waiting for the user's response
so most requests would timeout and fail, even if the user replied "Yes".

This dialog is only ever presented once -- the first time that Firefox asks
Windows for a wifi scan.  It does not reappear on restarts or reinstalls.   This
dedicated Yes/No system prompt is a bit more user-friendly than system settings.

This "system will prompt for permission" case could be completely avoided since
wifi scanning is not useful to us when it requires geolocation permissions as
geolocation would override it.  We would need the MLSFallback behavior to skip
scanning wifi when geolocation permission wasn't already granted, or else the
MLSFallback would present the system prompt in question, despite the user having
already denied permission.  On the other hand, we need the old scanning behavior
for this case when running versions of Windows 10 and 11 that don't have these
updates.  (The updates are set to appear in the 24H2 version of Windows 11.)
This approach avoids that kind of version special-casing.

Differential Revision: https://phabricator.services.mozilla.com/D218589
2024-08-27 22:47:33 +00:00

55 lines
1.9 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_GeolocationSystem_h
#define mozilla_dom_GeolocationSystem_h
#include "mozilla/dom/PContentParent.h"
#include "GeolocationIPCUtils.h"
namespace mozilla::dom {
class BrowsingContext;
namespace geolocation {
/**
* Get the behavior that Gecko should perform when the user asks for
* geolocation. The result isn't guaranteed to be accurate on all platforms
* (for example, some may prompt the user for permission without Gecko's
* knowledge). It is, however, guaranteed to be sensible. For example, this
* will never return "SystemWillPromptUser" if that is not true, nor will it
* return "GeckoWillPromptUser" if Gecko doesn't know how to open OS settings.
*/
SystemGeolocationPermissionBehavior GetGeolocationPermissionBehavior();
class SystemGeolocationPermissionRequest {
public:
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
// Stop watching for permission
virtual void Stop() = 0;
protected:
virtual ~SystemGeolocationPermissionRequest() = default;
};
using ParentRequestResolver =
PContentParent::RequestGeolocationPermissionFromUserResolver;
/**
* Opens the relevant system dialog to request permission from the user.
* Resolves aResolver when permission is granted, an error occurs, or Stop has
* been called on the SystemGeolocationPermissionRequest.
*/
already_AddRefed<SystemGeolocationPermissionRequest>
RequestLocationPermissionFromUser(BrowsingContext* aBrowsingContext,
ParentRequestResolver&& aResolver);
} // namespace geolocation
} // namespace mozilla::dom
#endif /* mozilla_dom_GeolocationSystem_h */