Index: third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h |
diff --git a/third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h b/third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h |
index e9db20eb64cee23c3f44ee65883215c2eef60065..4c36bae47952e88321263eab2abb6583a6f56be4 100644 |
--- a/third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h |
+++ b/third_party/WebKit/Source/modules/geolocation/testing/GeolocationClientMock.h |
@@ -32,10 +32,14 @@ |
#ifndef GeolocationClientMock_h |
#define GeolocationClientMock_h |
-#include "modules/geolocation/GeolocationClient.h" |
-#include "platform/Timer.h" |
+#include "components/geolocation/public/interfaces/geolocation.mojom.h" |
+#include "components/permission/public/interfaces/permission.mojom.h" |
+#include "modules/geolocation/GeolocationController.h" |
+#include "mojo/application/public/interfaces/service_provider.mojom.h" |
#include "platform/heap/Handle.h" |
+#include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" |
#include "wtf/HashSet.h" |
+#include "wtf/Vector.h" |
#include "wtf/text/WTFString.h" |
namespace blink { |
@@ -44,57 +48,51 @@ class GeolocationController; |
class GeolocationPosition; |
// Provides a mock object for the geolocation client. |
-class GeolocationClientMock final : public GeolocationClient { |
+// FIXME: Rename this to GeolocationServiceMock. |
+class GeolocationClientMock : public geolocation::GeolocationService, public permission::PermissionService, public mojo::ServiceProvider, public NoBaseWillBeGarbageCollectedFinalized<GeolocationClientMock>, public WillBeHeapSupplement<Document> { |
public: |
- GeolocationClientMock(); |
- ~GeolocationClientMock() override; |
+ ~GeolocationClientMock(); |
+ |
+ static GeolocationClientMock* from(Document*); |
void setPosition(GeolocationPosition*); |
void setPositionUnavailableError(const String& errorMessage); |
void setPermission(bool allowed); |
int numberOfPendingPermissionRequests() const; |
- // GeolocationClient |
- void startUpdating() override; |
- void stopUpdating() override; |
- void setEnableHighAccuracy(bool) override; |
- GeolocationPosition* lastPosition() override; |
- void requestPermission(Geolocation*) override; |
- void cancelPermissionRequest(Geolocation*) override; |
- void controllerForTestAdded(GeolocationController*) override; |
- void controllerForTestRemoved(GeolocationController*) override; |
+ // geolocation::GeolocationService |
+ void SetHighAccuracy(bool highAccuracy) override; |
+ void QueryNextPosition(const QueryNextPositionCallback&) override; |
- DECLARE_VIRTUAL_TRACE(); |
+ // permission::PermissionService |
+ void HasPermission(permission::Name, const mojo::String& origin, const HasPermissionCallback&) override; |
+ void RequestPermission(permission::Name, const mojo::String& origin, bool userGesture, const RequestPermissionCallback&) override; |
+ void RequestPermissions(mojo::Array<permission::Name> permissions, const mojo::String& origin, bool userGesture, const RequestPermissionsCallback&) override; |
+ void RevokePermission(permission::Name, const mojo::String& origin, const RevokePermissionCallback&) override; |
+ void GetNextPermissionChange(permission::Name, const mojo::String& origin, permission::Status lastKnownStatus, const GetNextPermissionChangeCallback&) override; |
-private: |
- void asyncUpdateController(); |
- void controllerTimerFired(Timer<GeolocationClientMock>*); |
+ void ConnectToService(const mojo::String& interfaceName, mojo::ScopedMessagePipeHandle) override; |
- void asyncUpdatePermission(); |
- void permissionTimerFired(Timer<GeolocationClientMock>*); |
+ static const char* supplementName() { return "GeolocationClientMock"; } |
- void clearError(); |
+ DECLARE_VIRTUAL_TRACE(); |
+ |
+private: |
+ GeolocationClientMock(ExecutionContext*); |
+ void runGeolocationCallbacks(); |
+ void runPermissionCallbacks(); |
- typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<GeolocationController>> GeolocationControllers; |
- GeolocationControllers m_controllers; |
+ ExecutionContext* m_context; |
- PersistentWillBeMember<GeolocationPosition> m_lastPosition; |
- bool m_hasError; |
- String m_errorMessage; |
- Timer<GeolocationClientMock> m_controllerTimer; |
- Timer<GeolocationClientMock> m_permissionTimer; |
- bool m_isActive; |
+ geolocation::GeopositionPtr m_lastPosition; |
- enum PermissionState { |
- PermissionStateUnset, |
- PermissionStateAllowed, |
- PermissionStateDenied |
- }; |
+ Vector<QueryNextPositionCallback> m_pendingGeolocations; |
- PermissionState m_permissionState; |
+ permission::Status m_permissionState; |
+ Vector<RequestPermissionCallback> m_pendingPermissions; |
- typedef PersistentHeapHashSetWillBeHeapHashSet<Member<Geolocation>> GeolocationSet; |
- GeolocationSet m_pendingPermissions; |
+ mojo::Binding<geolocation::GeolocationService> m_geolocationBinding; |
+ mojo::Binding<permission::PermissionService> m_permissionBinding; |
}; |
} |