summaryrefslogtreecommitdiffstats
path: root/WebCore/page
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-05-12 13:58:00 +0100
committerSteve Block <steveblock@google.com>2010-05-24 12:20:17 +0100
commit400e786798d320e3c9f4c9d82ea18ecc492a525a (patch)
tree00b6219b69b36945245ba5b9fd4fc2f826ce9c2f /WebCore/page
parentcbb11248c4cee2a74b3352860b1cf703552483fb (diff)
downloadexternal_webkit-400e786798d320e3c9f4c9d82ea18ecc492a525a.zip
external_webkit-400e786798d320e3c9f4c9d82ea18ecc492a525a.tar.gz
external_webkit-400e786798d320e3c9f4c9d82ea18ecc492a525a.tar.bz2
Update Android to reflect upstreamed code to avoid Geolocation leaks
This is a cherry-pick of WebKit change http://trac.webkit.org/changeset/60069 This releases references to JS callbacks in the page and allows the Frame and thus the Geolocation object to be cleaned up. This change allows us to remove the Android-specific code which achieved the same through an unload listener. Bug: 2169518 Change-Id: I1ed97d40d7f69ec94a58eaa21bfa4979737cc84d
Diffstat (limited to 'WebCore/page')
-rw-r--r--WebCore/page/Geolocation.cpp48
-rw-r--r--WebCore/page/Geolocation.h15
2 files changed, 13 insertions, 50 deletions
diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp
index 88e8941..49a4d84 100644
--- a/WebCore/page/Geolocation.cpp
+++ b/WebCore/page/Geolocation.cpp
@@ -31,10 +31,6 @@
#if ENABLE(GEOLOCATION)
#include "Chrome.h"
-// ANDROID
-#include "DOMWindow.h"
-#include "EventNames.h"
-// END ANDROID
#include "Frame.h"
#include "Page.h"
#if PLATFORM(ANDROID)
@@ -208,10 +204,7 @@ void Geolocation::Watchers::getNotifiersVector(Vector<RefPtr<GeoNotifier> >& cop
}
Geolocation::Geolocation(Frame* frame)
-// ANDROID
- : EventListener(GeolocationEventListenerType)
- , m_frame(frame)
-// END ANDROID
+ : m_frame(frame)
#if !ENABLE(CLIENT_BASED_GEOLOCATION)
, m_service(GeolocationService::create(this))
#endif
@@ -222,26 +215,23 @@ Geolocation::Geolocation(Frame* frame)
return;
ASSERT(m_frame->document());
m_frame->document()->setUsingGeolocation(true);
-
-// ANDROID
- if (m_frame->domWindow())
- m_frame->domWindow()->addEventListener(eventNames().unloadEvent, this, false);
-// END ANDROID
}
Geolocation::~Geolocation()
{
-// ANDROID
- if (m_frame && m_frame->domWindow())
- m_frame->domWindow()->removeEventListener(eventNames().unloadEvent, this, false);
-// END ANDROID
+}
+
+void Geolocation::stop()
+{
+ m_oneShots.clear();
+ m_watchers.clear();
+ stopUpdating();
}
void Geolocation::disconnectFrame()
{
if (m_frame && m_frame->page() && m_allowGeolocation == InProgress)
m_frame->page()->chrome()->cancelGeolocationPermissionRequestForFrame(m_frame, this);
- stopUpdating();
if (m_frame && m_frame->document())
m_frame->document()->setUsingGeolocation(false);
m_frame = 0;
@@ -684,26 +674,6 @@ void Geolocation::stopUpdating()
}
-// ANDROID
-bool Geolocation::operator==(const EventListener& listener)
-{
- if (listener.type() != GeolocationEventListenerType)
- return false;
- const Geolocation* geolocation = static_cast<const Geolocation*>(&listener);
- return m_frame == geolocation->m_frame;
-}
-
-void Geolocation::handleEvent(ScriptExecutionContext*, Event* event)
-{
- ASSERT_UNUSED(event, event->type() == eventNames().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();
-}
-// END ANDROID
-
} // namespace WebCore
#else
@@ -720,6 +690,8 @@ Geolocation::~Geolocation() {}
void Geolocation::setIsAllowed(bool) {}
+void Geolocation::stop() {}
+
}
#endif // ENABLE(GEOLOCATION)
diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h
index ba4f149..8803703 100644
--- a/WebCore/page/Geolocation.h
+++ b/WebCore/page/Geolocation.h
@@ -27,9 +27,6 @@
#ifndef Geolocation_h
#define Geolocation_h
-// ANDROID
-#include "EventListener.h"
-// END ANDROID
#include "GeolocationPositionCache.h"
#include "GeolocationService.h"
#include "Geoposition.h"
@@ -48,9 +45,7 @@ class GeolocationPosition;
class GeolocationError;
#endif
-// ANDROID
-class Geolocation : public EventListener
-// END ANDROID
+class Geolocation : public RefCounted<Geolocation>
#if !ENABLE(CLIENT_BASED_GEOLOCATION) && ENABLE(GEOLOCATION)
, public GeolocationServiceClient
#endif
@@ -70,6 +65,8 @@ public:
void suspend();
void resume();
+ void stop();
+
void setIsAllowed(bool);
Frame* frame() const { return m_frame; }
@@ -154,12 +151,6 @@ private:
PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>);
-// ANDROID
- // EventListener
- virtual bool operator==(const EventListener&);
- virtual void handleEvent(ScriptExecutionContext*, Event*);
-// END ANDROID
-
void fatalErrorOccurred(GeoNotifier*);
void requestTimedOut(GeoNotifier*);
void requestUsesCachedPosition(GeoNotifier*);