NavigatorGeolocation.cpp [plain text]
#include "config.h"
#if ENABLE(GEOLOCATION)
#include "NavigatorGeolocation.h"
#include "DOMWindow.h"
#include "Document.h"
#include "Frame.h"
#include "Geolocation.h"
#include "Navigator.h"
namespace WebCore {
NavigatorGeolocation::NavigatorGeolocation(DOMWindow* window)
: DOMWindowProperty(window)
{
}
NavigatorGeolocation::~NavigatorGeolocation() = default;
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->window());
supplement = newSupplement.get();
provideTo(navigator, supplementName(), WTFMove(newSupplement));
}
return supplement;
}
#if PLATFORM(IOS_FAMILY)
void NavigatorGeolocation::resetAllGeolocationPermission()
{
if (m_geolocation)
m_geolocation->resetAllGeolocationPermission();
}
#endif // PLATFORM(IOS_FAMILY)
Geolocation* NavigatorGeolocation::geolocation(Navigator& navigator)
{
return NavigatorGeolocation::from(&navigator)->geolocation();
}
Geolocation* NavigatorGeolocation::geolocation() const
{
if (!m_geolocation)
m_geolocation = Geolocation::create(window() ? window()->document() : nullptr);
return m_geolocation.get();
}
}
#endif // ENABLE(GEOLOCATION)