Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp
- index 9418d5afe965..199a4542c5bb 100644
- --- a/dom/geolocation/nsGeolocation.cpp
- +++ b/dom/geolocation/nsGeolocation.cpp
- @@ -1228,25 +1228,53 @@ void Geolocation::NotifyAllowedRequest(nsGeolocationRequest* aRequest) {
- }
- }
- -bool Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) {
- +bool Geolocation::RegisterRequestWithPromptImpl(
- + nsGeolocationRequest* aRequest) {
- nsIEventTarget* target = MainThreadTarget(this);
- - ContentPermissionRequestBase::PromptResult pr = request->CheckPromptPrefs();
- + ContentPermissionRequestBase::PromptResult pr = aRequest->CheckPromptPrefs();
- if (pr == ContentPermissionRequestBase::PromptResult::Granted) {
- - request->RequestDelayedTask(target,
- - nsGeolocationRequest::DelayedTaskType::Allow);
- + aRequest->RequestDelayedTask(target,
- + nsGeolocationRequest::DelayedTaskType::Allow);
- return true;
- }
- if (pr == ContentPermissionRequestBase::PromptResult::Denied) {
- - request->RequestDelayedTask(target,
- - nsGeolocationRequest::DelayedTaskType::Deny);
- + aRequest->RequestDelayedTask(target,
- + nsGeolocationRequest::DelayedTaskType::Deny);
- return true;
- }
- - request->RequestDelayedTask(target,
- - nsGeolocationRequest::DelayedTaskType::Request);
- + aRequest->RequestDelayedTask(target,
- + nsGeolocationRequest::DelayedTaskType::Request);
- return true;
- }
- +bool Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) {
- +#ifdef MOZ_WIDGET_COCOA
- + nsCOMPtr<nsISerialEventTarget> serialTarget =
- + SystemGroup::EventTargetFor(TaskCategory::Other);
- + ContentChild* cpc = ContentChild::GetSingleton();
- + cpc->SendGetGeoSysPermission()->Then(
- + serialTarget, __func__,
- + [request, this](bool aSysPermIsGranted) {
- + if (!aSysPermIsGranted) {
- + nsIEventTarget* target = MainThreadTarget(this);
- + request->RequestDelayedTask(
- + target, nsGeolocationRequest::DelayedTaskType::Deny);
- + } else {
- + RegisterRequestWithPromptImpl(request);
- + }
- + },
- + [request, this](mozilla::ipc::ResponseRejectReason aReason) {
- + nsIEventTarget* target = MainThreadTarget(this);
- + request->RequestDelayedTask(
- + target, nsGeolocationRequest::DelayedTaskType::Deny);
- + });
- + return true;
- +#else
- + return RegisterRequestWithPromptImpl(request);
- +#endif
- +}
- +
- JSObject* Geolocation::WrapObject(JSContext* aCtx,
- JS::Handle<JSObject*> aGivenProto) {
- return Geolocation_Binding::Wrap(aCtx, this, aGivenProto);
- diff --git a/dom/geolocation/nsGeolocation.h b/dom/geolocation/nsGeolocation.h
- index 5c991368a8a7..43f2a35340e8 100644
- --- a/dom/geolocation/nsGeolocation.h
- +++ b/dom/geolocation/nsGeolocation.h
- @@ -197,6 +197,8 @@ class Geolocation final : public nsIGeolocationUpdate, public nsWrapperCache {
- bool RegisterRequestWithPrompt(nsGeolocationRequest* request);
- + bool RegisterRequestWithPromptImpl(nsGeolocationRequest* aRequest);
- +
- // Check if clearWatch is already called
- bool IsAlreadyCleared(nsGeolocationRequest* aRequest);
- diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
- index 74dc3aebae49..31433dcd53f9 100644
- --- a/dom/ipc/ContentParent.cpp
- +++ b/dom/ipc/ContentParent.cpp
- @@ -234,6 +234,7 @@
- #if defined(XP_MACOSX)
- # include "nsMacUtilsImpl.h"
- +# include "CoreLocationLocationProvider.h"
- #endif
- #if defined(ANDROID) || defined(LINUX)
- @@ -4026,6 +4027,14 @@ mozilla::ipc::IPCResult ContentParent::RecvAddGeolocationListener(
- return IPC_OK();
- }
- +mozilla::ipc::IPCResult ContentParent::RecvGetGeoSysPermission(
- + std::function<void(const bool)>&& aCallback) {
- +#ifdef MOZ_WIDGET_COCOA
- + aCallback(isMacGeoSystemPermissionEnabled());
- +#endif
- + return IPC_OK();
- +}
- +
- mozilla::ipc::IPCResult ContentParent::RecvRemoveGeolocationListener() {
- if (mGeolocationWatchID != -1) {
- RefPtr<Geolocation> geo = Geolocation::NonWindowSingleton();
- diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h
- index 01f2f511c063..aebc6c77dcd6 100644
- --- a/dom/ipc/ContentParent.h
- +++ b/dom/ipc/ContentParent.h
- @@ -1017,6 +1017,9 @@ class ContentParent final : public PContentParent,
- const IPC::Principal& aPrincipal, const bool& aHighAccuracy);
- mozilla::ipc::IPCResult RecvRemoveGeolocationListener();
- + mozilla::ipc::IPCResult RecvGetGeoSysPermission(
- + std::function<void(const bool)>&& aCallback);
- +
- // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we don't have MOZ_CAN_RUN_SCRIPT bits
- // in IPC code yet.
- MOZ_CAN_RUN_SCRIPT_BOUNDARY
- diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl
- index a3ed1f8cde81..8cba388dec75 100644
- --- a/dom/ipc/PContent.ipdl
- +++ b/dom/ipc/PContent.ipdl
- @@ -951,6 +951,8 @@ parent:
- async RemoveGeolocationListener();
- async SetGeolocationHigherAccuracy(bool enable);
- + async GetGeoSysPermission() returns (bool isok);
- +
- async ConsoleMessage(nsString message);
- async ScriptError(nsString message, nsString sourceName, nsString sourceLine,
- uint32_t lineNumber, uint32_t colNumber, uint32_t flags,
- diff --git a/dom/system/mac/CoreLocationLocationProvider.h b/dom/system/mac/CoreLocationLocationProvider.h
- index 6f13c3cab92c..1e9137d9e252 100644
- --- a/dom/system/mac/CoreLocationLocationProvider.h
- +++ b/dom/system/mac/CoreLocationLocationProvider.h
- @@ -25,6 +25,8 @@
- class CoreLocationObjects;
- class MLSFallback;
- +bool isMacGeoSystemPermissionEnabled();
- +
- class CoreLocationLocationProvider : public nsIGeolocationProvider {
- public:
- NS_DECL_ISUPPORTS
- diff --git a/dom/system/mac/CoreLocationLocationProvider.mm b/dom/system/mac/CoreLocationLocationProvider.mm
- index 5d56780682ad..d65b2054ddef 100644
- --- a/dom/system/mac/CoreLocationLocationProvider.mm
- +++ b/dom/system/mac/CoreLocationLocationProvider.mm
- @@ -32,6 +32,8 @@ using namespace mozilla;
- static const CLLocationAccuracy kHIGH_ACCURACY = kCLLocationAccuracyBest;
- static const CLLocationAccuracy kDEFAULT_ACCURACY = kCLLocationAccuracyNearestTenMeters;
- +bool isMacGeoSystemPermissionEnabled() { return [CLLocationManager locationServicesEnabled]; }
- +
- @interface LocationDelegate : NSObject <CLLocationManagerDelegate> {
- CoreLocationLocationProvider* mProvider;
- }
- diff --git a/dom/system/mac/moz.build b/dom/system/mac/moz.build
- index 8fb85bbe309e..a9596053821d 100644
- --- a/dom/system/mac/moz.build
- +++ b/dom/system/mac/moz.build
- @@ -10,6 +10,7 @@ SOURCES += [
- ]
- EXPORTS += [
- + 'CoreLocationLocationProvider.h',
- 'nsOSPermissionRequest.h',
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement