Пример #1
0
void setupGeolocationProvider(WKContextRef context, void *clientInfo)
{
    WKGeolocationProviderV1 providerCallback;
    memset(&providerCallback, 0, sizeof(WKGeolocationProvider));

    providerCallback.base.version = 1;
    providerCallback.base.clientInfo = clientInfo;
    providerCallback.startUpdating = GeolocationStateTracker::startUpdatingCallback;
    providerCallback.stopUpdating = GeolocationStateTracker::stopUpdatingCallback;
    providerCallback.setEnableHighAccuracy = GeolocationStateTracker::setEnableHighAccuracyCallback;

    WKGeolocationManagerSetProvider(WKContextGetGeolocationManager(context), &providerCallback.base);
}
GeolocationProviderMock::GeolocationProviderMock(WKContextRef context)
    : m_isActive(false)
    , m_hasError(false)
{
    m_geolocationManager = WKContextGetGeolocationManager(context);

    WKGeolocationProvider providerCallback = {
        kWKGeolocationProviderCurrentVersion,
        this,
        startUpdatingCallback,
        stopUpdatingCallback };
    WKGeolocationManagerSetProvider(m_geolocationManager, &providerCallback);
}
GeolocationProviderMock::~GeolocationProviderMock()
{
    WKGeolocationManagerSetProvider(m_geolocationManager, 0);
}