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..94067b4c2fe89bacc63770d2353a6a062e3022f0 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 "content/common/geolocation_service.mojom.h" |
+#include "content/common/permission_service.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 content::GeolocationService, public content::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; |
+ // content::GeolocationService |
+ void SetHighAccuracy(bool highAccuracy) override; |
+ void QueryNextPosition(const QueryNextPositionCallback&) override; |
- DECLARE_VIRTUAL_TRACE(); |
+ // content::PermissionService |
+ void HasPermission(content::PermissionName, const mojo::String& origin, const HasPermissionCallback&) override; |
+ void RequestPermission(content::PermissionName, const mojo::String& origin, bool userGesture, const RequestPermissionCallback&) override; |
+ void RequestPermissions(mojo::Array<content::PermissionName> permissions, const mojo::String& origin, bool userGesture, const RequestPermissionsCallback&) override; |
+ void RevokePermission(content::PermissionName, const mojo::String& origin, const RevokePermissionCallback&) override; |
+ void GetNextPermissionChange(content::PermissionName, const mojo::String& origin, content::PermissionStatus 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(Document*); |
+ void runGeolocationCallbacks(); |
+ void runPermissionCallbacks(); |
- typedef WillBeHeapHashSet<RawPtrWillBeWeakMember<GeolocationController>> GeolocationControllers; |
- GeolocationControllers m_controllers; |
+ Document* m_document; |
- PersistentWillBeMember<GeolocationPosition> m_lastPosition; |
- bool m_hasError; |
- String m_errorMessage; |
- Timer<GeolocationClientMock> m_controllerTimer; |
- Timer<GeolocationClientMock> m_permissionTimer; |
- bool m_isActive; |
+ content::MojoGeopositionPtr m_lastPosition; |
- enum PermissionState { |
- PermissionStateUnset, |
- PermissionStateAllowed, |
- PermissionStateDenied |
- }; |
+ Vector<QueryNextPositionCallback> m_pendingGeolocations; |
- PermissionState m_permissionState; |
+ content::PermissionStatus m_permissionState; |
+ Vector<RequestPermissionCallback> m_pendingPermissions; |
- typedef PersistentHeapHashSetWillBeHeapHashSet<Member<Geolocation>> GeolocationSet; |
- GeolocationSet m_pendingPermissions; |
+ mojo::Binding<content::GeolocationService> m_geolocationBinding; |
+ mojo::Binding<content::PermissionService> m_permissionBinding; |
}; |
} |