This source file includes following definitions.
- setGeolocationClientMock
- setGeolocationPosition
- setGeolocationPositionUnavailableError
- setGeolocationPermission
- numberOfPendingGeolocationPermissionRequests
- geolocationClient
#include "config.h"
#include "InternalsGeolocation.h"
#include "core/dom/Document.h"
#include "core/testing/Internals.h"
#include "modules/geolocation/GeolocationController.h"
#include "modules/geolocation/GeolocationError.h"
#include "modules/geolocation/GeolocationPosition.h"
#include "modules/geolocation/testing/GeolocationClientMock.h"
#include "wtf/CurrentTime.h"
namespace WebCore {
void InternalsGeolocation::setGeolocationClientMock(Internals&, Document* document)
{
ASSERT(document && document->page());
GeolocationController* controller = GeolocationController::from(document->page());
GeolocationClientMock* client = new GeolocationClientMock();
controller->setClientForTest(client);
client->setController(controller);
}
void InternalsGeolocation::setGeolocationPosition(Internals&, Document* document, double latitude, double longitude, double accuracy)
{
ASSERT(document && document->page());
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
client->setPosition(GeolocationPosition::create(currentTime(), latitude, longitude, accuracy));
}
void InternalsGeolocation::setGeolocationPositionUnavailableError(Internals&, Document* document, const String& message)
{
ASSERT(document && document->page());
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
client->setPositionUnavailableError(message);
}
void InternalsGeolocation::setGeolocationPermission(Internals&, Document* document, bool allowed)
{
ASSERT(document && document->page());
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return;
client->setPermission(allowed);
}
int InternalsGeolocation::numberOfPendingGeolocationPermissionRequests(Internals&, Document* document)
{
ASSERT(document && document->page());
GeolocationClientMock* client = geolocationClient(document);
if (!client)
return -1;
return client->numberOfPendingPermissionRequests();
}
GeolocationClientMock* InternalsGeolocation::geolocationClient(Document* document)
{
GeolocationController* controller = GeolocationController::from(document->page());
if (!controller->hasClientForTest())
return 0;
return static_cast<GeolocationClientMock*>(controller->client());
}
}