#include "Chrome.h"
#include "CurrentTime.h"
#include "Document.h"
+#include "EventNames.h"
#include "Frame.h"
#include "Page.h"
#include "SQLiteDatabase.h"
return;
ASSERT(m_frame->document());
m_frame->document()->setUsingGeolocation(true);
+
+ if (m_frame->domWindow())
+ m_frame->domWindow()->addEventListener(eventNames().unloadEvent, this, false);
+}
+
+Geolocation::~Geolocation()
+{
+ if (m_frame && m_frame->domWindow())
+ m_frame->domWindow()->removeEventListener(eventNames().unloadEvent, this, false);
}
void Geolocation::disconnectFrame()
handleError(service->lastError());
}
+void Geolocation::handleEvent(Event* event, bool)
+{
+ ASSERT_UNUSED(event, event->type() == eventTypes().unloadEvent);
+ // Cancel any ongoing requests on page unload. This is required to release
+ // references to JS callbacks in the page, to allow the frame to be cleaned up
+ // by WebKit.
+ m_oneShots.clear();
+ m_watchers.clear();
+}
+
void Geolocation::setDatabasePath(String databasePath)
{
CachedPositionManager::setDatabasePath(databasePath);
#ifndef Geolocation_h
#define Geolocation_h
+#include "EventListener.h"
#include "GeolocationService.h"
#include "Geoposition.h"
#include "PositionCallback.h"
class CachedPositionManager;
-class Geolocation : public RefCounted<Geolocation>, public GeolocationServiceClient {
+class Geolocation : public GeolocationServiceClient, public EventListener {
public:
static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); }
- virtual ~Geolocation() {}
+ virtual ~Geolocation();
void disconnectFrame();
virtual void geolocationServicePositionChanged(GeolocationService*);
virtual void geolocationServiceErrorOccurred(GeolocationService*);
+ // EventListener
+ virtual void handleEvent(Event*, bool isWindowEvent);
+
void fatalErrorOccurred(GeoNotifier* notifier);
void requestTimedOut(GeoNotifier* notifier);
void requestReturnedCachedPosition(GeoNotifier* notifier);