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(Navigator& navigator)
: m_navigator(navigator)
{
}
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 = makeUnique<NavigatorGeolocation>(navigator);
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(m_navigator);
return m_geolocation.get();
}
}
#endif // ENABLE(GEOLOCATION)