NavigatorGeolocation.cpp [plain text]
#include "config.h"
#if ENABLE(GEOLOCATION)
#include "NavigatorGeolocation.h"
#include "Document.h"
#include "Frame.h"
#include "Geolocation.h"
#include "Navigator.h"
namespace WebCore {
NavigatorGeolocation::NavigatorGeolocation(Frame* frame)
: DOMWindowProperty(frame)
{
}
NavigatorGeolocation::~NavigatorGeolocation()
{
}
const char* NavigatorGeolocation::supplementName()
{
return "NavigatorGeolocation";
}
NavigatorGeolocation* NavigatorGeolocation::from(Navigator* navigator)
{
NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(navigator, supplementName()));
if (!supplement) {
auto newSupplement = std::make_unique<NavigatorGeolocation>(navigator->frame());
supplement = newSupplement.get();
provideTo(navigator, supplementName(), WTF::move(newSupplement));
}
return supplement;
}
#if PLATFORM(IOS)
void NavigatorGeolocation::resetAllGeolocationPermission()
{
if (m_geolocation)
m_geolocation->resetAllGeolocationPermission();
}
#endif // PLATFORM(IOS)
Geolocation* NavigatorGeolocation::geolocation(Navigator* navigator)
{
return NavigatorGeolocation::from(navigator)->geolocation();
}
Geolocation* NavigatorGeolocation::geolocation() const
{
if (!m_geolocation && frame())
m_geolocation = Geolocation::create(frame()->document());
return m_geolocation.get();
}
}
#endif // ENABLE(GEOLOCATION)