Chromium Code Reviews| Index: third_party/WebKit/Source/modules/geolocation/Geolocation.h |
| diff --git a/third_party/WebKit/Source/modules/geolocation/Geolocation.h b/third_party/WebKit/Source/modules/geolocation/Geolocation.h |
| index 6518b959b7977789051bfb3c7acc4774cf8be38b..8b780393e2e8218c46214cd57342812f24bef10e 100644 |
| --- a/third_party/WebKit/Source/modules/geolocation/Geolocation.h |
| +++ b/third_party/WebKit/Source/modules/geolocation/Geolocation.h |
| @@ -29,6 +29,7 @@ |
| #include "bindings/core/v8/ScriptWrappable.h" |
| #include "core/dom/ActiveDOMObject.h" |
| +#include "core/page/PageLifecycleObserver.h" |
| #include "modules/ModulesExport.h" |
| #include "modules/geolocation/GeoNotifier.h" |
| #include "modules/geolocation/GeolocationWatchers.h" |
| @@ -39,6 +40,9 @@ |
| #include "modules/geolocation/PositionOptions.h" |
| #include "platform/Timer.h" |
| #include "platform/heap/Handle.h" |
| +#include "third_party/WebKit/public/platform/modules/geolocation/geolocation.mojom-blink.h" |
| +#include "third_party/WebKit/public/platform/modules/permissions/permission.mojom-blink.h" |
| +#include "third_party/WebKit/public/platform/modules/permissions/permission_status.mojom-blink.h" |
| namespace blink { |
| @@ -50,9 +54,11 @@ class ExecutionContext; |
| class MODULES_EXPORT Geolocation final |
| : public GarbageCollectedFinalized<Geolocation> |
| , public ScriptWrappable |
| - , public ActiveDOMObject { |
| + , public ActiveDOMObject |
|
Michael van Ouwerkerk
2016/05/09 17:22:31
Sorry to comment on existing code you didn't chang
Sam McNally
2016/05/10 10:06:08
Done.
|
| + , public PageLifecycleObserver { |
| DEFINE_WRAPPERTYPEINFO(); |
| USING_GARBAGE_COLLECTED_MIXIN(Geolocation); |
| + USING_PRE_FINALIZER(Geolocation, stop); |
| public: |
| static Geolocation* create(ExecutionContext*); |
| ~Geolocation() override; |
| @@ -73,17 +79,12 @@ public: |
| // Removes all references to the watcher, it will not be updated again. |
| void clearWatch(int watchID); |
| - void setIsAllowed(bool); |
| - |
| bool isAllowed() const { return m_geolocationPermission == PermissionAllowed; } |
| // Notifies this that a new position is available. Must never be called |
| // before permission is granted by the user. |
| void positionChanged(); |
| - // Notifies this that an error has occurred, it must be handled immediately. |
| - void setError(GeolocationError*); |
| - |
| // Discards the notifier because a fatal error occurred for it. |
| void fatalErrorOccurred(GeoNotifier*); |
| @@ -95,10 +96,10 @@ public: |
| // Discards the notifier if it is a oneshot because it timed it. |
| void requestTimedOut(GeoNotifier*); |
| -private: |
| - // Returns the last known position, if any. May return null. |
| - Geoposition* lastPosition(); |
| + // Inherited from PageLifecycleObserver. |
| + void pageVisibilityChanged() override; |
| +private: |
| bool isDenied() const { return m_geolocationPermission == PermissionDenied; } |
| explicit Geolocation(ExecutionContext*); |
| @@ -141,33 +142,37 @@ private: |
| // Requests permission to share positions with the page. |
| void requestPermission(); |
| - // Attempts to register this with the controller for receiving updates. |
| - // Returns false if there is no controller to register with. |
| - bool startUpdating(GeoNotifier*); |
| + // Connects to the Geolocation mojo service and starts polling for updates. |
| + void startUpdating(GeoNotifier*); |
| void stopUpdating(); |
| - // Processes the notifiers that were waiting for a permission decision. If |
| - // granted and this can be registered with the controller then the |
| - // notifier's timers are started. Otherwise, a fatal error is set on them. |
| - void handlePendingPermissionNotifiers(); |
| + void updateGeolocationServiceConnection(); |
| + void queryNextPosition(); |
| // Attempts to obtain a position for the given notifier, either by using |
| - // the cached position or by requesting one from the controller. Sets a |
| - // fatal error if permission is denied or no position can be obtained. |
| + // the cached position or by requesting one from the GeolocationService. |
| + // Sets a fatal error if permission is denied or no position can be |
| + // obtained. |
| void startRequest(GeoNotifier*); |
| bool haveSuitableCachedPosition(const PositionOptions&); |
| - // Runs the success callbacks for the set of notifiers awaiting a cached |
| - // position, the set is then cleared. The oneshots are removed everywhere. |
| - void makeCachedPositionCallbacks(); |
| - |
| // Record whether the origin trying to access Geolocation would be allowed |
| // to access a feature that can only be accessed by secure origins. |
| // See https://goo.gl/Y0ZkNV |
| void recordOriginTypeAccess() const; |
| + void onPositionUpdated(mojom::blink::GeopositionPtr); |
| + |
| + // Processes the notifiers that were waiting for a permission decision. If |
| + // granted then the notifier's timers are started. Otherwise, a fatal error |
| + // is set on them. |
| + void onGeolocationPermissionUpdated(mojom::blink::PermissionStatus); |
| + |
| + void onGeolocationConnectionError(); |
| + void onPermissionConnectionError(); |
| + |
| GeoNotifierSet m_oneShots; |
| GeolocationWatchers m_watchers; |
| GeoNotifierSet m_pendingForPermissionNotifiers; |
| @@ -184,8 +189,17 @@ private: |
| }; |
| Permission m_geolocationPermission; |
| + mojom::blink::GeolocationServicePtr m_geolocationService; |
| + bool m_enableHighAccuracy = false; |
| + mojom::blink::PermissionServicePtr m_permissionService; |
| + |
| + // Whether a GeoNotifier is waiting for a position update. |
| + bool m_updating = false; |
| - GeoNotifierSet m_requestsAwaitingCachedPosition; |
| + // Set to true when m_geolocationService is disconnected. This is used to |
| + // detect when m_geolocationService is disconnected and reconnected while |
| + // running callbacks in response to a call to onPositionUpdated(). |
| + bool m_disconnectedGeolocationService = false; |
| }; |
| } // namespace blink |