diff options
| author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
|---|---|---|
| committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-03-12 14:11:15 +0100 |
| commit | dd91e772430dc294e3bf478c119ef8d43c0a3358 (patch) | |
| tree | 6f33ce4d5872a5691e0291eb45bf6ab373a5f567 /Source/WebCore/Modules/geolocation | |
| parent | ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (diff) | |
| download | qtwebkit-dd91e772430dc294e3bf478c119ef8d43c0a3358.tar.gz | |
Imported WebKit commit 3db4eb1820ac8fb03065d7ea73a4d9db1e8fea1a (http://svn.webkit.org/repository/webkit/trunk@110422)
This includes build fixes for the latest qtbase/qtdeclarative as well as the final QML2 API.
Diffstat (limited to 'Source/WebCore/Modules/geolocation')
4 files changed, 95 insertions, 99 deletions
diff --git a/Source/WebCore/Modules/geolocation/Geolocation.cpp b/Source/WebCore/Modules/geolocation/Geolocation.cpp index ae1f4fcbc..a689a1812 100644 --- a/Source/WebCore/Modules/geolocation/Geolocation.cpp +++ b/Source/WebCore/Modules/geolocation/Geolocation.cpp @@ -225,38 +225,57 @@ void Geolocation::Watchers::getNotifiersVector(GeoNotifierVector& copy) const copyValuesToVector(m_idToNotifierMap, copy); } -Geolocation::Geolocation(Frame* frame) - : DOMWindowProperty(frame) +PassRefPtr<Geolocation> Geolocation::create(ScriptExecutionContext* context) +{ + RefPtr<Geolocation> geolocation = adoptRef(new Geolocation(context)); + geolocation->suspendIfNeeded(); + return geolocation.release(); +} + +Geolocation::Geolocation(ScriptExecutionContext* context) + : ActiveDOMObject(context, this) #if !ENABLE(CLIENT_BASED_GEOLOCATION) , m_service(GeolocationService::create(this)) #endif , m_allowGeolocation(Unknown) { - if (!m_frame) - return; - ASSERT(m_frame->document()); - m_frame->document()->setUsingGeolocation(true); } Geolocation::~Geolocation() { ASSERT(m_allowGeolocation != InProgress); - ASSERT(!m_frame); +} + +Document* Geolocation::document() const +{ + ASSERT(!scriptExecutionContext() || scriptExecutionContext()->isDocument()); + return static_cast<Document*>(scriptExecutionContext()); +} + +Frame* Geolocation::frame() const +{ + return document() ? document()->frame() : 0; } Page* Geolocation::page() const { - return m_frame ? m_frame->page() : 0; + return document() ? document()->page() : 0; } -void Geolocation::reset() +void Geolocation::stop() { + // FIXME: We should ideally allow existing Geolocation activities to continue + // when the Geolocation's iframe is reparented. (Assuming we continue to + // support reparenting iframes.) + // See https://bugs.webkit.org/show_bug.cgi?id=55577 + // and https://bugs.webkit.org/show_bug.cgi?id=52877 + Page* page = this->page(); if (page && m_allowGeolocation == InProgress) { #if ENABLE(CLIENT_BASED_GEOLOCATION) page->geolocationController()->cancelPermissionRequest(this); #else - page->chrome()->client()->cancelGeolocationPermissionRequestForFrame(m_frame, this); + page->chrome()->client()->cancelGeolocationPermissionRequestForFrame(frame(), this); #endif } // The frame may be moving to a new page and we want to get the permissions from the new page's client. @@ -268,15 +287,6 @@ void Geolocation::reset() #endif } -void Geolocation::disconnectFrame() -{ - // Once we are disconnected from the Frame, it is no longer possible to perform any operations. - reset(); - if (m_frame && m_frame->document()) - m_frame->document()->setUsingGeolocation(false); - DOMWindowProperty::disconnectFrame(); -} - Geoposition* Geolocation::lastPosition() { #if ENABLE(CLIENT_BASED_GEOLOCATION) @@ -294,7 +304,7 @@ Geoposition* Geolocation::lastPosition() void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { - if (!m_frame) + if (!frame()) return; RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); @@ -305,7 +315,7 @@ void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallbac int Geolocation::watchPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { - if (!m_frame) + if (!frame()) return 0; RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); @@ -620,7 +630,7 @@ void Geolocation::requestPermission() #if ENABLE(CLIENT_BASED_GEOLOCATION) page->geolocationController()->requestPermission(this); #else - page->chrome()->client()->requestGeolocationPermissionForFrame(m_frame, this); + page->chrome()->client()->requestGeolocationPermissionForFrame(frame(), this); #endif } @@ -757,17 +767,11 @@ void Geolocation::handlePendingPermissionNotifiers() namespace WebCore { -void Geolocation::clearWatch(int) {} - -void Geolocation::reset() {} - -void Geolocation::disconnectFrame() {} - -Geolocation::Geolocation(Frame*) : DOMWindowProperty(0) {} - -Geolocation::~Geolocation() {} - -void Geolocation::setIsAllowed(bool) {} +void Geolocation::clearWatch(int) { } +void Geolocation::stop() { } +Geolocation::Geolocation(ScriptExecutionContext* context) : ActiveDOMObject(context, this) { } +Geolocation::~Geolocation() { } +void Geolocation::setIsAllowed(bool) { } } diff --git a/Source/WebCore/Modules/geolocation/Geolocation.h b/Source/WebCore/Modules/geolocation/Geolocation.h index ea55cbf1f..2c6bab8bd 100644 --- a/Source/WebCore/Modules/geolocation/Geolocation.h +++ b/Source/WebCore/Modules/geolocation/Geolocation.h @@ -27,7 +27,7 @@ #ifndef Geolocation_h #define Geolocation_h -#include "DOMWindowProperty.h" +#include "ActiveDOMObject.h" #include "Geoposition.h" #include "PositionCallback.h" #include "PositionError.h" @@ -41,24 +41,27 @@ namespace WebCore { +class Document; class Frame; #if ENABLE(CLIENT_BASED_GEOLOCATION) class GeolocationPosition; class GeolocationError; #endif class Page; +class ScriptExecutionContext; -class Geolocation : public RefCounted<Geolocation>, public DOMWindowProperty +class Geolocation : public RefCounted<Geolocation>, public ActiveDOMObject #if !ENABLE(CLIENT_BASED_GEOLOCATION) && ENABLE(GEOLOCATION) , public GeolocationServiceClient #endif { public: - static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); } + static PassRefPtr<Geolocation> create(ScriptExecutionContext*); ~Geolocation(); - virtual void disconnectFrame() OVERRIDE; - void reset(); + virtual void stop() OVERRIDE; + Document* document() const; + Frame* frame() const; void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -79,7 +82,7 @@ private: bool isAllowed() const { return m_allowGeolocation == Yes; } bool isDenied() const { return m_allowGeolocation == No; } - explicit Geolocation(Frame*); + explicit Geolocation(ScriptExecutionContext*); Page* page() const; diff --git a/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp b/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp index b8a47c1f5..da0ebf54a 100644 --- a/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp +++ b/Source/WebCore/Modules/geolocation/NavigatorGeolocation.cpp @@ -1,31 +1,33 @@ /* - * Copyright (C) 2012, Google Inc. All rights reserved. + * Copyright (C) 2000 Harri Porten (porten@kde.org) + * Copyright (c) 2000 Daniel Molkentin (molkentin@kde.org) + * Copyright (c) 2000 Stefan Schimanski (schimmi@kde.org) + * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. + * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" + +#if ENABLE(GEOLOCATION) + #include "NavigatorGeolocation.h" +#include "Document.h" +#include "Frame.h" #include "Geolocation.h" #include "Navigator.h" @@ -40,21 +42,10 @@ NavigatorGeolocation::~NavigatorGeolocation() { } -void NavigatorGeolocation::willDetachPage() -{ - // FIXME: We should ideally allow existing Geolocation activities to continue - // when the Geolocation's iframe is reparented. (Assuming we continue to - // support reparenting iframes.) - // See https://bugs.webkit.org/show_bug.cgi?id=55577 - // and https://bugs.webkit.org/show_bug.cgi?id=52877 - if (m_geolocation) - m_geolocation->reset(); -} - NavigatorGeolocation* NavigatorGeolocation::from(Navigator* navigator) { DEFINE_STATIC_LOCAL(AtomicString, name, ("NavigatorGeolocation")); - NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(NavigatorSupplement::from(navigator, name)); + NavigatorGeolocation* supplement = static_cast<NavigatorGeolocation*>(Supplement<Navigator>::from(navigator, name)); if (!supplement) { supplement = new NavigatorGeolocation(navigator->frame()); provideTo(navigator, name, adoptPtr(supplement)); @@ -69,9 +60,11 @@ Geolocation* NavigatorGeolocation::geolocation(Navigator* navigator) Geolocation* NavigatorGeolocation::geolocation() const { - if (!m_geolocation) - m_geolocation = Geolocation::create(frame()); + if (!m_geolocation && frame()) + m_geolocation = Geolocation::create(frame()->document()); return m_geolocation.get(); } } // namespace WebCore + +#endif // ENABLE(GEOLOCATION) diff --git a/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h b/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h index b8c92e6a3..6f9d8057f 100644 --- a/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h +++ b/Source/WebCore/Modules/geolocation/NavigatorGeolocation.h @@ -1,33 +1,29 @@ /* - * Copyright (C) 2011, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - */ + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ #ifndef NavigatorGeolocation_h #define NavigatorGeolocation_h +#if ENABLE(GEOLOCATION) + #include "DOMWindowProperty.h" -#include "NavigatorSupplement.h" +#include "Supplementable.h" namespace WebCore { @@ -35,7 +31,7 @@ class Frame; class Geolocation; class Navigator; -class NavigatorGeolocation : public NavigatorSupplement, public DOMWindowProperty { +class NavigatorGeolocation : public Supplement<Navigator>, public DOMWindowProperty { public: virtual ~NavigatorGeolocation(); static NavigatorGeolocation* from(Navigator*); @@ -46,11 +42,11 @@ public: private: NavigatorGeolocation(Frame*); - virtual void willDetachPage() OVERRIDE; - mutable RefPtr<Geolocation> m_geolocation; }; } // namespace WebCore +#endif // ENABLE(GEOLOCATION) + #endif // NavigatorGeolocation_h |
