Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp
  2. index 9418d5afe965..199a4542c5bb 100644
  3. --- a/dom/geolocation/nsGeolocation.cpp
  4. +++ b/dom/geolocation/nsGeolocation.cpp
  5. @@ -1228,25 +1228,53 @@ void Geolocation::NotifyAllowedRequest(nsGeolocationRequest* aRequest) {
  6. }
  7. }
  8.  
  9. -bool Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) {
  10. +bool Geolocation::RegisterRequestWithPromptImpl(
  11. + nsGeolocationRequest* aRequest) {
  12. nsIEventTarget* target = MainThreadTarget(this);
  13. - ContentPermissionRequestBase::PromptResult pr = request->CheckPromptPrefs();
  14. + ContentPermissionRequestBase::PromptResult pr = aRequest->CheckPromptPrefs();
  15. if (pr == ContentPermissionRequestBase::PromptResult::Granted) {
  16. - request->RequestDelayedTask(target,
  17. - nsGeolocationRequest::DelayedTaskType::Allow);
  18. + aRequest->RequestDelayedTask(target,
  19. + nsGeolocationRequest::DelayedTaskType::Allow);
  20. return true;
  21. }
  22. if (pr == ContentPermissionRequestBase::PromptResult::Denied) {
  23. - request->RequestDelayedTask(target,
  24. - nsGeolocationRequest::DelayedTaskType::Deny);
  25. + aRequest->RequestDelayedTask(target,
  26. + nsGeolocationRequest::DelayedTaskType::Deny);
  27. return true;
  28. }
  29.  
  30. - request->RequestDelayedTask(target,
  31. - nsGeolocationRequest::DelayedTaskType::Request);
  32. + aRequest->RequestDelayedTask(target,
  33. + nsGeolocationRequest::DelayedTaskType::Request);
  34. return true;
  35. }
  36.  
  37. +bool Geolocation::RegisterRequestWithPrompt(nsGeolocationRequest* request) {
  38. +#ifdef MOZ_WIDGET_COCOA
  39. + nsCOMPtr<nsISerialEventTarget> serialTarget =
  40. + SystemGroup::EventTargetFor(TaskCategory::Other);
  41. + ContentChild* cpc = ContentChild::GetSingleton();
  42. + cpc->SendGetGeoSysPermission()->Then(
  43. + serialTarget, __func__,
  44. + [request, this](bool aSysPermIsGranted) {
  45. + if (!aSysPermIsGranted) {
  46. + nsIEventTarget* target = MainThreadTarget(this);
  47. + request->RequestDelayedTask(
  48. + target, nsGeolocationRequest::DelayedTaskType::Deny);
  49. + } else {
  50. + RegisterRequestWithPromptImpl(request);
  51. + }
  52. + },
  53. + [request, this](mozilla::ipc::ResponseRejectReason aReason) {
  54. + nsIEventTarget* target = MainThreadTarget(this);
  55. + request->RequestDelayedTask(
  56. + target, nsGeolocationRequest::DelayedTaskType::Deny);
  57. + });
  58. + return true;
  59. +#else
  60. + return RegisterRequestWithPromptImpl(request);
  61. +#endif
  62. +}
  63. +
  64. JSObject* Geolocation::WrapObject(JSContext* aCtx,
  65. JS::Handle<JSObject*> aGivenProto) {
  66. return Geolocation_Binding::Wrap(aCtx, this, aGivenProto);
  67. diff --git a/dom/geolocation/nsGeolocation.h b/dom/geolocation/nsGeolocation.h
  68. index 5c991368a8a7..43f2a35340e8 100644
  69. --- a/dom/geolocation/nsGeolocation.h
  70. +++ b/dom/geolocation/nsGeolocation.h
  71. @@ -197,6 +197,8 @@ class Geolocation final : public nsIGeolocationUpdate, public nsWrapperCache {
  72.  
  73. bool RegisterRequestWithPrompt(nsGeolocationRequest* request);
  74.  
  75. + bool RegisterRequestWithPromptImpl(nsGeolocationRequest* aRequest);
  76. +
  77. // Check if clearWatch is already called
  78. bool IsAlreadyCleared(nsGeolocationRequest* aRequest);
  79.  
  80. diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp
  81. index 74dc3aebae49..31433dcd53f9 100644
  82. --- a/dom/ipc/ContentParent.cpp
  83. +++ b/dom/ipc/ContentParent.cpp
  84. @@ -234,6 +234,7 @@
  85.  
  86. #if defined(XP_MACOSX)
  87. # include "nsMacUtilsImpl.h"
  88. +# include "CoreLocationLocationProvider.h"
  89. #endif
  90.  
  91. #if defined(ANDROID) || defined(LINUX)
  92. @@ -4026,6 +4027,14 @@ mozilla::ipc::IPCResult ContentParent::RecvAddGeolocationListener(
  93. return IPC_OK();
  94. }
  95.  
  96. +mozilla::ipc::IPCResult ContentParent::RecvGetGeoSysPermission(
  97. + std::function<void(const bool)>&& aCallback) {
  98. +#ifdef MOZ_WIDGET_COCOA
  99. + aCallback(isMacGeoSystemPermissionEnabled());
  100. +#endif
  101. + return IPC_OK();
  102. +}
  103. +
  104. mozilla::ipc::IPCResult ContentParent::RecvRemoveGeolocationListener() {
  105. if (mGeolocationWatchID != -1) {
  106. RefPtr<Geolocation> geo = Geolocation::NonWindowSingleton();
  107. diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h
  108. index 01f2f511c063..aebc6c77dcd6 100644
  109. --- a/dom/ipc/ContentParent.h
  110. +++ b/dom/ipc/ContentParent.h
  111. @@ -1017,6 +1017,9 @@ class ContentParent final : public PContentParent,
  112. const IPC::Principal& aPrincipal, const bool& aHighAccuracy);
  113. mozilla::ipc::IPCResult RecvRemoveGeolocationListener();
  114.  
  115. + mozilla::ipc::IPCResult RecvGetGeoSysPermission(
  116. + std::function<void(const bool)>&& aCallback);
  117. +
  118. // MOZ_CAN_RUN_SCRIPT_BOUNDARY because we don't have MOZ_CAN_RUN_SCRIPT bits
  119. // in IPC code yet.
  120. MOZ_CAN_RUN_SCRIPT_BOUNDARY
  121. diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl
  122. index a3ed1f8cde81..8cba388dec75 100644
  123. --- a/dom/ipc/PContent.ipdl
  124. +++ b/dom/ipc/PContent.ipdl
  125. @@ -951,6 +951,8 @@ parent:
  126. async RemoveGeolocationListener();
  127. async SetGeolocationHigherAccuracy(bool enable);
  128.  
  129. + async GetGeoSysPermission() returns (bool isok);
  130. +
  131. async ConsoleMessage(nsString message);
  132. async ScriptError(nsString message, nsString sourceName, nsString sourceLine,
  133. uint32_t lineNumber, uint32_t colNumber, uint32_t flags,
  134. diff --git a/dom/system/mac/CoreLocationLocationProvider.h b/dom/system/mac/CoreLocationLocationProvider.h
  135. index 6f13c3cab92c..1e9137d9e252 100644
  136. --- a/dom/system/mac/CoreLocationLocationProvider.h
  137. +++ b/dom/system/mac/CoreLocationLocationProvider.h
  138. @@ -25,6 +25,8 @@
  139. class CoreLocationObjects;
  140. class MLSFallback;
  141.  
  142. +bool isMacGeoSystemPermissionEnabled();
  143. +
  144. class CoreLocationLocationProvider : public nsIGeolocationProvider {
  145. public:
  146. NS_DECL_ISUPPORTS
  147. diff --git a/dom/system/mac/CoreLocationLocationProvider.mm b/dom/system/mac/CoreLocationLocationProvider.mm
  148. index 5d56780682ad..d65b2054ddef 100644
  149. --- a/dom/system/mac/CoreLocationLocationProvider.mm
  150. +++ b/dom/system/mac/CoreLocationLocationProvider.mm
  151. @@ -32,6 +32,8 @@ using namespace mozilla;
  152. static const CLLocationAccuracy kHIGH_ACCURACY = kCLLocationAccuracyBest;
  153. static const CLLocationAccuracy kDEFAULT_ACCURACY = kCLLocationAccuracyNearestTenMeters;
  154.  
  155. +bool isMacGeoSystemPermissionEnabled() { return [CLLocationManager locationServicesEnabled]; }
  156. +
  157. @interface LocationDelegate : NSObject <CLLocationManagerDelegate> {
  158. CoreLocationLocationProvider* mProvider;
  159. }
  160. diff --git a/dom/system/mac/moz.build b/dom/system/mac/moz.build
  161. index 8fb85bbe309e..a9596053821d 100644
  162. --- a/dom/system/mac/moz.build
  163. +++ b/dom/system/mac/moz.build
  164. @@ -10,6 +10,7 @@ SOURCES += [
  165. ]
  166.  
  167. EXPORTS += [
  168. + 'CoreLocationLocationProvider.h',
  169. 'nsOSPermissionRequest.h',
  170. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement