diff options
author | Steve Block <steveblock@google.com> | 2010-05-24 04:29:35 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-05-24 04:29:35 -0700 |
commit | fc79bbb3ba729acaeee5f96e24ec8b48e4234ebe (patch) | |
tree | c07bce0a9fe652f047a40d07a025f23f336e9974 /WebCore | |
parent | bad8b91f026f7b63252113590bab4c73a7092214 (diff) | |
parent | 400e786798d320e3c9f4c9d82ea18ecc492a525a (diff) | |
download | external_webkit-fc79bbb3ba729acaeee5f96e24ec8b48e4234ebe.zip external_webkit-fc79bbb3ba729acaeee5f96e24ec8b48e4234ebe.tar.gz external_webkit-fc79bbb3ba729acaeee5f96e24ec8b48e4234ebe.tar.bz2 |
Merge "Update Android to reflect upstreamed code to avoid Geolocation leaks"
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/dom/EventListener.h | 3 | ||||
-rw-r--r-- | WebCore/loader/FrameLoader.cpp | 7 | ||||
-rw-r--r-- | WebCore/page/Geolocation.cpp | 48 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 15 |
4 files changed, 21 insertions, 52 deletions
diff --git a/WebCore/dom/EventListener.h b/WebCore/dom/EventListener.h index 249d3eb..d7c950f 100644 --- a/WebCore/dom/EventListener.h +++ b/WebCore/dom/EventListener.h @@ -41,8 +41,7 @@ namespace WebCore { InspectorDOMAgentType, InspectorDOMStorageResourceType, ObjCEventListenerType, - ConditionEventListenerType, - GeolocationEventListenerType }; + ConditionEventListenerType }; virtual ~EventListener() { } virtual bool operator==(const EventListener&) = 0; diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 125ee9b..f6b8f52 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -59,6 +59,7 @@ #include "FrameLoaderClient.h" #include "FrameTree.h" #include "FrameView.h" +#include "Geolocation.h" #include "HTMLAnchorElement.h" #include "HTMLAppletElement.h" #include "HTMLFormElement.h" @@ -76,6 +77,7 @@ #include "Logging.h" #include "MIMETypeRegistry.h" #include "MainResourceLoader.h" +#include "Navigator.h" #include "Page.h" #include "PageCache.h" #include "PageGroup.h" @@ -605,6 +607,11 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy, DatabasePolic #endif } + // Stop the Geolocation object, if present. This call is made after the unload + // event has fired, so no new Geolocation activity is possible. + if (m_frame->domWindow()->navigator()->optionalGeolocation()) + m_frame->domWindow()->navigator()->optionalGeolocation()->stop(); + // tell all subframes to stop as well for (Frame* child = m_frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) child->loader()->stopLoading(unloadEventPolicy); 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*); |