WebGeolocationManagerProxy.cpp [plain text]
#include "config.h"
#include "WebGeolocationManagerProxy.h"
#include "WebContext.h"
#include "WebGeolocationManagerMessages.h"
#include "WebGeolocationManagerProxyMessages.h"
namespace WebKit {
const char* WebGeolocationManagerProxy::supplementName()
{
return "WebGeolocationManagerProxy";
}
PassRefPtr<WebGeolocationManagerProxy> WebGeolocationManagerProxy::create(WebContext* context)
{
return adoptRef(new WebGeolocationManagerProxy(context));
}
WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebContext* context)
: WebContextSupplement(context)
, m_isUpdating(false)
{
WebContextSupplement::context()->addMessageReceiver(Messages::WebGeolocationManagerProxy::messageReceiverName(), this);
}
WebGeolocationManagerProxy::~WebGeolocationManagerProxy()
{
}
void WebGeolocationManagerProxy::initializeProvider(const WKGeolocationProvider* provider)
{
m_provider.initialize(provider);
}
void WebGeolocationManagerProxy::contextDestroyed()
{
stopUpdating();
}
void WebGeolocationManagerProxy::processDidClose(WebProcessProxy*)
{
stopUpdating();
}
void WebGeolocationManagerProxy::refWebContextSupplement()
{
APIObject::ref();
}
void WebGeolocationManagerProxy::derefWebContextSupplement()
{
APIObject::deref();
}
void WebGeolocationManagerProxy::providerDidChangePosition(WebGeolocationPosition* position)
{
if (!context())
return;
context()->sendToAllProcesses(Messages::WebGeolocationManager::DidChangePosition(position->data()));
}
void WebGeolocationManagerProxy::providerDidFailToDeterminePosition(const String& errorMessage)
{
if (!context())
return;
context()->sendToAllProcesses(Messages::WebGeolocationManager::DidFailToDeterminePosition(errorMessage));
}
void WebGeolocationManagerProxy::startUpdating()
{
if (m_isUpdating)
return;
m_provider.startUpdating(this);
m_isUpdating = true;
}
void WebGeolocationManagerProxy::stopUpdating()
{
if (!m_isUpdating)
return;
m_provider.stopUpdating(this);
m_isUpdating = false;
}
}