diff options
Diffstat (limited to 'WebCore')
-rw-r--r-- | WebCore/ChangeLog | 79 | ||||
-rw-r--r-- | WebCore/GNUmakefile.am | 5 | ||||
-rw-r--r-- | WebCore/WebCore.base.exp | 14 | ||||
-rw-r--r-- | WebCore/WebCore.gypi | 5 | ||||
-rw-r--r-- | WebCore/WebCore.pro | 1 | ||||
-rw-r--r-- | WebCore/WebCore.vcproj/WebCore.vcproj | 20 | ||||
-rw-r--r-- | WebCore/WebCore.xcodeproj/project.pbxproj | 20 | ||||
-rw-r--r-- | WebCore/WebCoreSources.bkl | 1 | ||||
-rw-r--r-- | WebCore/page/Geolocation.cpp | 148 | ||||
-rw-r--r-- | WebCore/page/Geolocation.h | 29 | ||||
-rw-r--r-- | WebCore/page/GeolocationController.cpp | 85 | ||||
-rw-r--r-- | WebCore/page/GeolocationController.h | 67 | ||||
-rw-r--r-- | WebCore/page/GeolocationControllerClient.h | 45 | ||||
-rw-r--r-- | WebCore/page/GeolocationError.h | 60 | ||||
-rw-r--r-- | WebCore/page/GeolocationPosition.h | 110 | ||||
-rw-r--r-- | WebCore/page/Geoposition.h | 7 | ||||
-rw-r--r-- | WebCore/page/Page.cpp | 13 | ||||
-rw-r--r-- | WebCore/page/Page.h | 10 | ||||
-rw-r--r-- | WebCore/svg/graphics/SVGImage.cpp | 2 |
19 files changed, 690 insertions, 31 deletions
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog index 67567ab..b306b29 100644 --- a/WebCore/ChangeLog +++ b/WebCore/ChangeLog @@ -1,3 +1,82 @@ +2009-12-13 Sam Weinig <sam@webkit.org> + + Reviewed by Dan Bernstein. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=32499 + Add client based Geolocation provider + + Add first cut of a client based Geolocation provider. This is guarded by + ENABLE(CLIENT_BASED_GEOLOCATION) and is off by default for now. This adds a + GeolocationControllerClient interface that no-one currently implements, + but will in a subsequent patch. + + * GNUmakefile.am: + * WebCore.base.exp: + * WebCore.gypi: + * WebCore.pro: + * WebCore.vcproj/WebCore.vcproj: + * WebCore.xcodeproj/project.pbxproj: + * WebCoreSources.bkl: + * page/Geolocation.cpp: + (WebCore::createGeopositionFromGeolocationPosition): + (WebCore::createPositionErrorFromGeolocationError): + (WebCore::Geolocation::Geolocation): + (WebCore::Geolocation::~Geolocation): + (WebCore::Geolocation::disconnectFrame): + (WebCore::Geolocation::lastPosition): + (WebCore::Geolocation::startRequest): + (WebCore::Geolocation::fatalErrorOccurred): + (WebCore::Geolocation::requestTimedOut): + (WebCore::Geolocation::clearWatch): + (WebCore::Geolocation::handleError): + (WebCore::Geolocation::positionChanged): + (WebCore::Geolocation::makeSuccessCallbacks): + (WebCore::Geolocation::errorOccurred): + (WebCore::Geolocation::geolocationServicePositionChanged): + (WebCore::Geolocation::geolocationServiceErrorOccurred): + (WebCore::Geolocation::startUpdating): + (WebCore::Geolocation::stopUpdating): + * page/Geolocation.h: + * page/GeolocationController.cpp: Added. + (WebCore::GeolocationController::GeolocationController): + (WebCore::GeolocationController::~GeolocationController): + (WebCore::GeolocationController::addObserver): + (WebCore::GeolocationController::removeObserver): + (WebCore::GeolocationController::positionChanged): + (WebCore::GeolocationController::errorOccurred): + (WebCore::GeolocationController::lastPosition): + * page/GeolocationController.h: Added. + * page/GeolocationControllerClient.h: Added. + (WebCore::GeolocationControllerClient::~GeolocationControllerClient): + * page/GeolocationError.h: Added. + (WebCore::GeolocationError::): + (WebCore::GeolocationError::create): + (WebCore::GeolocationError::code): + (WebCore::GeolocationError::message): + * page/GeolocationPosition.h: Added. + (WebCore::GeolocationPosition::create): + (WebCore::GeolocationPosition::timestamp): + (WebCore::GeolocationPosition::latitude): + (WebCore::GeolocationPosition::longitude): + (WebCore::GeolocationPosition::accuracy): + (WebCore::GeolocationPosition::altitude): + (WebCore::GeolocationPosition::altitudeAccuracy): + (WebCore::GeolocationPosition::heading): + (WebCore::GeolocationPosition::speed): + (WebCore::GeolocationPosition::canProvideAltitude): + (WebCore::GeolocationPosition::canProvideAltitudeAccuracy): + (WebCore::GeolocationPosition::canProvideHeading): + (WebCore::GeolocationPosition::canProvideSpeed): + (WebCore::GeolocationPosition::GeolocationPosition): + * page/Geoposition.h: + (WebCore::Geoposition::create): + * page/Page.cpp: + (WebCore::Page::Page): + * page/Page.h: + (WebCore::Page::geolocationController): + * svg/graphics/SVGImage.cpp: + (WebCore::SVGImage::dataChanged): + 2009-12-10 Alexey Proskuryakov <ap@apple.com> Reviewed by Darin Adler. diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am index f8fa302..7e32d2e 100644 --- a/WebCore/GNUmakefile.am +++ b/WebCore/GNUmakefile.am @@ -1347,6 +1347,11 @@ webcore_sources += \ WebCore/page/FrameView.h \ WebCore/page/Geolocation.cpp \ WebCore/page/Geolocation.h \ + WebCore/page/GeolocationController.cpp \ + WebCore/page/GeolocationController.h \ + WebCore/page/GeolocationControllerClient.h \ + WebCore/page/GeolocationError.h \ + WebCore/page/GeolocationPosition.h \ WebCore/page/Geoposition.h \ WebCore/page/HaltablePlugin.h \ WebCore/page/History.cpp \ diff --git a/WebCore/WebCore.base.exp b/WebCore/WebCore.base.exp index 8df5524..c29629a 100644 --- a/WebCore/WebCore.base.exp +++ b/WebCore/WebCore.base.exp @@ -292,6 +292,7 @@ __ZN7WebCore14ResourceHandle12releaseProxyEv __ZN7WebCore14ResourceHandle20forceContentSniffingEv __ZN7WebCore14ResourceLoader14cancelledErrorEv __ZN7WebCore14ResourceLoader19setShouldBufferDataEb +__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE __ZN7WebCore14SecurityOrigin16createFromStringERKNS_6StringE __ZN7WebCore14SecurityOrigin18setLocalLoadPolicyENS0_15LocalLoadPolicyE __ZN7WebCore14SecurityOrigin18shouldHideReferrerERKNS_4KURLERKNS_6StringE @@ -414,6 +415,7 @@ __ZN7WebCore21JavaScriptDebugServer23recompileAllJSFunctionsEPNS_5TimerIS0_EE __ZN7WebCore21JavaScriptDebugServer6sharedEv __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent +__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd __ZN7WebCore21SerializedScriptValue11deserializeEPK15OpaqueJSContextPPK13OpaqueJSValue __ZN7WebCore21SerializedScriptValue6createEPK15OpaqueJSContextPK13OpaqueJSValuePS6_ __ZN7WebCore21SerializedScriptValueD1Ev @@ -495,7 +497,7 @@ __ZN7WebCore4Page6goBackEv __ZN7WebCore4Page8goToItemEPNS_11HistoryItemENS_13FrameLoadTypeE __ZN7WebCore4Page9goForwardEv __ZN7WebCore4Page9initGroupEv -__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientE +__ZN7WebCore4PageC1EPNS_12ChromeClientEPNS_17ContextMenuClientEPNS_12EditorClientEPNS_10DragClientEPNS_15InspectorClientEPNS_18PluginHalterClientEPNS_27GeolocationControllerClientE __ZN7WebCore4PageD1Ev __ZN7WebCore4coreEP20NSURLProtectionSpace __ZN7WebCore5Cache11setDisabledEb @@ -601,8 +603,10 @@ __ZN7WebCore7cookiesEPKNS_8DocumentERKNS_4KURLE __ZN7WebCore7nsColorERKNS_5ColorE __ZN7WebCore8Document11createRangeEv __ZN7WebCore8Document13removeMarkersENS_14DocumentMarker10MarkerTypeE +__ZN7WebCore8Document13svgExtensionsEv __ZN7WebCore8Document14setFocusedNodeEN3WTF10PassRefPtrINS_4NodeEEE __ZN7WebCore8Document17getFocusableNodesERN3WTF6VectorINS1_6RefPtrINS_4NodeEEELm0EEE +__ZN7WebCore8Document19accessSVGExtensionsEv __ZN7WebCore8Document22createDocumentFragmentEv __ZN7WebCore8Document23renderedRectsForMarkersENS_14DocumentMarker10MarkerTypeE __ZN7WebCore8Document24setShouldCreateRenderersEb @@ -627,9 +631,9 @@ __ZN7WebCore8Settings20setCursiveFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setFantasyFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings20setJavaScriptEnabledEb __ZN7WebCore8Settings20setXSSAuditorEnabledEb +__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings21setStandardFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings21setWebSecurityEnabledEb -__ZN7WebCore8Settings21setShowRepaintCounterEb __ZN7WebCore8Settings22setLocalStorageEnabledEb __ZN7WebCore8Settings22setSansSerifFontFamilyERKNS_12AtomicStringE __ZN7WebCore8Settings22setShowsURLsInToolTipsEb @@ -961,9 +965,9 @@ __ZNK7WebCore8Document31displayStringModifiedByEncodingERKNS_6StringE __ZNK7WebCore8Document4bodyEv __ZNK7WebCore8Document6domainEv __ZNK7WebCore8IntPointcv8_NSPointEv +__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position25leadingWhitespacePositionENS_9EAffinityEb __ZNK7WebCore8Position26trailingWhitespacePositionENS_9EAffinityEb -__ZNK7WebCore8Position10downstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore8Position8upstreamENS0_27EditingBoundaryCrossingRuleE __ZNK7WebCore9DOMWindow27pendingUnloadEventListenersEv __ZNK7WebCore9FloatRectcv7_NSRectEv @@ -982,10 +986,6 @@ __ZTVN7WebCore12ChromeClientE __ZTVN7WebCore17FileChooserClientE __ZTVN7WebCore17FrameLoaderClientE __ZTVN7WebCore25HistoryPropertyListWriterE -__ZN7WebCore14SVGSMILElement13isSMILElementEPNS_4NodeE -__ZN7WebCore21SVGDocumentExtensions21sampleAnimationAtTimeERKNS_6StringEPNS_14SVGSMILElementEd -__ZN7WebCore8Document19accessSVGExtensionsEv -__ZN7WebCore8Document13svgExtensionsEv _filenameByFixingIllegalCharacters _hasCaseInsensitiveSubstring _hasCaseInsensitiveSuffix diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi index 4a37c79..0115a41 100644 --- a/WebCore/WebCore.gypi +++ b/WebCore/WebCore.gypi @@ -1785,6 +1785,11 @@ 'page/FrameView.h', 'page/Geolocation.cpp', 'page/Geolocation.h', + 'page/GeolocationController.cpp' + 'page/GeolocationController.h' + 'page/GeolocationControllerClient.h' + 'page/GeolocationError.h' + 'page/GeolocationPosition.h' 'page/Geoposition.h', 'page/HaltablePlugin.h', 'page/History.cpp', diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro index bfeee61..474c143 100644 --- a/WebCore/WebCore.pro +++ b/WebCore/WebCore.pro @@ -1160,6 +1160,7 @@ SOURCES += \ page/FrameTree.cpp \ page/FrameView.cpp \ page/Geolocation.cpp \ + page/GeolocationController.cpp \ page/History.cpp \ page/Location.cpp \ page/MouseEventWithHitTestResults.cpp \ diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj index 09945f5..db19ea3 100644 --- a/WebCore/WebCore.vcproj/WebCore.vcproj +++ b/WebCore/WebCore.vcproj/WebCore.vcproj @@ -20645,6 +20645,26 @@ <File
RelativePath="..\page\Geolocation.cpp"
>
+ RelativePath="..\page\GeolocationController.cpp" + > + </File> + <File + RelativePath="..\page\GeolocationController.h" + > + </File> + <File + RelativePath="..\page\GeolocationControllerClient.h" + > + </File> + <File + RelativePath="..\page\GeolocationError.h" + > + </File> + <File + RelativePath="..\page\GeolocationPosition.h" + > + </File> + <File </File>
<File
RelativePath="..\page\Geolocation.h"
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj index 2d0b804..915b509 100644 --- a/WebCore/WebCore.xcodeproj/project.pbxproj +++ b/WebCore/WebCore.xcodeproj/project.pbxproj @@ -4189,6 +4189,11 @@ BC53C6080DA56C570021EB5D /* Gradient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C6070DA56C570021EB5D /* Gradient.cpp */; }; BC53C60B0DA56CF10021EB5D /* GradientCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */; }; BC53C6920DA591140021EB5D /* CSSGradientValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BC53C6910DA591140021EB5D /* CSSGradientValue.h */; }; + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */; }; + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */; }; + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */; }; + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */; }; + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */; }; BC5823F50C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */; }; BC5825F30C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */; }; BC588AF00BFA6CF900EE679E /* HTMLParserErrorCodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */; }; @@ -9356,6 +9361,11 @@ BC53C6070DA56C570021EB5D /* Gradient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Gradient.cpp; sourceTree = "<group>"; }; BC53C60A0DA56CF10021EB5D /* GradientCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GradientCG.cpp; sourceTree = "<group>"; }; BC53C6910DA591140021EB5D /* CSSGradientValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSGradientValue.h; sourceTree = "<group>"; }; + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeolocationController.cpp; sourceTree = "<group>"; }; + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationController.h; sourceTree = "<group>"; }; + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationControllerClient.h; sourceTree = "<group>"; }; + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationError.h; sourceTree = "<group>"; }; + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeolocationPosition.h; sourceTree = "<group>"; }; BC5823F40C0A98DF0053F1B5 /* JSHTMLElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLElementCustom.cpp; sourceTree = "<group>"; }; BC5825F20C0B89380053F1B5 /* JSCSSStyleDeclarationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSStyleDeclarationCustom.cpp; sourceTree = "<group>"; }; BC588AEF0BFA6CF900EE679E /* HTMLParserErrorCodes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLParserErrorCodes.h; sourceTree = "<group>"; }; @@ -11275,6 +11285,11 @@ FE80D7B70E9C1F25000D6F75 /* Geolocation.cpp */, FE80D7B80E9C1F25000D6F75 /* Geolocation.h */, FE80D7B90E9C1F25000D6F75 /* Geolocation.idl */, + BC56CB1C10D5AC8000A77C64 /* GeolocationController.cpp */, + BC56CB1D10D5AC8000A77C64 /* GeolocationController.h */, + BC56CB1E10D5AC8000A77C64 /* GeolocationControllerClient.h */, + BC56CB1F10D5AC8000A77C64 /* GeolocationError.h */, + BC56CB2010D5AC8000A77C64 /* GeolocationPosition.h */, FE80D7BB0E9C1F25000D6F75 /* Geoposition.h */, FE80D7BC0E9C1F25000D6F75 /* Geoposition.idl */, 7693BACE106C2DCA007B0823 /* HaltablePlugin.h */, @@ -18246,6 +18261,10 @@ 7ADE722610CBBB9B006B3B3A /* ContextMenuSelectionHandler.h in Headers */, 0C3F1F5B10C8871200D72CE1 /* WebGLUniformLocation.h in Headers */, 0C45342810CDBBFA00869157 /* JSWebGLUniformLocation.h in Headers */, + BC56CB2210D5AC8000A77C64 /* GeolocationController.h in Headers */, + BC56CB2310D5AC8000A77C64 /* GeolocationControllerClient.h in Headers */, + BC56CB2410D5AC8000A77C64 /* GeolocationError.h in Headers */, + BC56CB2510D5AC8000A77C64 /* GeolocationPosition.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -20403,6 +20422,7 @@ 599D1E3210C97D6E00E0EF12 /* jni_utility_private.cpp in Sources */, 0C3F1F5A10C8871200D72CE1 /* WebGLUniformLocation.cpp in Sources */, 0C45342710CDBBFA00869157 /* JSWebGLUniformLocation.cpp in Sources */, + BC56CB2110D5AC8000A77C64 /* GeolocationController.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/WebCore/WebCoreSources.bkl b/WebCore/WebCoreSources.bkl index cd94ae6..d44e593 100644 --- a/WebCore/WebCoreSources.bkl +++ b/WebCore/WebCoreSources.bkl @@ -777,6 +777,7 @@ This file contains the list of files needed to build WebCore. page/FrameTree.cpp page/FrameView.cpp page/Geolocation.cpp + page/GeolocationController.cpp page/History.cpp page/Location.cpp page/MouseEventWithHitTestResults.cpp diff --git a/WebCore/page/Geolocation.cpp b/WebCore/page/Geolocation.cpp index 0a7205f..f0578a8 100644 --- a/WebCore/page/Geolocation.cpp +++ b/WebCore/page/Geolocation.cpp @@ -39,10 +39,45 @@ #include "SQLValue.h" #include <wtf/CurrentTime.h> +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "Coordinates.h" +#include "GeolocationController.h" +#include "GeolocationError.h" +#include "GeolocationPosition.h" +#include "Geoposition.h" +#include "PositionError.h" +#endif + namespace WebCore { static const char permissionDeniedErrorMessage[] = "User denied Geolocation"; +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +static PassRefPtr<Geoposition> createGeoposition(GeolocationPosition* position) +{ + RefPtr<Coordinates> coordinates = Coordinates::create(position->latitude(), position->longitude(), position->canProvideAltitude(), position->altitude(), + position->accuracy(), position->canProvideAltitudeAccuracy(), position->altitudeAccuracy(), + position->canProvideHeading(), position->heading(), position->canProvideSpeed(), position->speed()); + return Geoposition::create(coordinates.release(), position->timestamp()); +} + +static PassRefPtr<PositionError> createPositionError(GeolocationError* error) +{ + PositionError::ErrorCode code = PositionError::POSITION_UNAVAILABLE; + switch (error->code()) { + case GeolocationError::PermissionDenied: + code = PositionError::PERMISSION_DENIED; + break; + case GeolocationError::PositionUnavailable: + code = PositionError::POSITION_UNAVAILABLE; + break; + } + + return PositionError::create(code, error->message()); +} +#endif + Geolocation::GeoNotifier::GeoNotifier(Geolocation* geolocation, PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) : m_geolocation(geolocation) , m_successCallback(successCallback) @@ -305,7 +340,9 @@ String* CachedPositionManager::s_databaseFile = 0; Geolocation::Geolocation(Frame* frame) : EventListener(GeolocationEventListenerType) , m_frame(frame) +#if !ENABLE(CLIENT_BASED_GEOLOCATION) , m_service(GeolocationService::create(this)) +#endif , m_allowGeolocation(Unknown) , m_shouldClearCache(false) , m_cachedPositionManager(new CachedPositionManager) @@ -327,7 +364,7 @@ Geolocation::~Geolocation() void Geolocation::disconnectFrame() { - m_service->stopUpdating(); + stopUpdating(); if (m_frame && m_frame->document()) m_frame->document()->setUsingGeolocation(false); m_frame = 0; @@ -335,6 +372,24 @@ void Geolocation::disconnectFrame() delete m_cachedPositionManager; } +Geoposition* Geolocation::lastPosition() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return 0; + + Page* page = m_frame->page(); + if (!page) + return 0; + + m_lastPosition = createGeoposition(page->geolocationController()->lastPosition()); +#else + m_lastPosition = m_service->lastPosition(); +#endif + + return m_lastPosition.get(); +} + void Geolocation::getCurrentPosition(PassRefPtr<PositionCallback> successCallback, PassRefPtr<PositionErrorCallback> errorCallback, PassRefPtr<PositionOptions> options) { RefPtr<GeoNotifier> notifier = startRequest(successCallback, errorCallback, options); @@ -391,7 +446,7 @@ void Geolocation::fatalErrorOccurred(Geolocation::GeoNotifier* notifier) m_watchers.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestTimedOut(GeoNotifier* notifier) @@ -400,7 +455,7 @@ void Geolocation::requestTimedOut(GeoNotifier* notifier) m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) @@ -408,11 +463,11 @@ void Geolocation::requestReturnedCachedPosition(GeoNotifier* notifier) // If this is a one-shot request, stop it. m_oneShots.remove(notifier); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); // Otherwise, if the watch still exists, start the service to get updates. if (m_watchers.contains(notifier)) { - if (notifier->hasZeroTimeout() || m_service->startUpdating(notifier->m_options.get())) + if (notifier->hasZeroTimeout() || startUpdating(notifier->m_options.get())) notifier->startTimerIfNeeded(); else notifier->setFatalError(PositionError::create(PositionError::POSITION_UNAVAILABLE, "Failed to start Geolocation service")); @@ -436,7 +491,7 @@ void Geolocation::clearWatch(int watchId) m_watchers.remove(watchId); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::suspend() @@ -553,7 +608,7 @@ void Geolocation::handleError(PositionError* error) sendError(watchersCopy, error); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); } void Geolocation::requestPermission() @@ -574,12 +629,11 @@ void Geolocation::requestPermission() page->chrome()->requestGeolocationPermissionForFrame(m_frame, this); } -void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +void Geolocation::positionChanged(PassRefPtr<Geoposition> newPosition) { - ASSERT_UNUSED(service, service == m_service); - ASSERT(m_service->lastPosition()); + m_currentPosition = newPosition; - m_cachedPositionManager->setCachedPosition(m_service->lastPosition()); + m_cachedPositionManager->setCachedPosition(m_currentPosition.get()); // Stop all currently running timers. stopTimers(); @@ -598,7 +652,7 @@ void Geolocation::geolocationServicePositionChanged(GeolocationService* service) void Geolocation::makeSuccessCallbacks() { - ASSERT(m_service->lastPosition()); + ASSERT(m_currentPosition); ASSERT(isAllowed()); Vector<RefPtr<GeoNotifier> > oneShotsCopy; @@ -612,23 +666,85 @@ void Geolocation::makeSuccessCallbacks() // further callbacks to these notifiers. m_oneShots.clear(); - sendPosition(oneShotsCopy, m_service->lastPosition()); - sendPosition(watchersCopy, m_service->lastPosition()); + sendPosition(oneShotsCopy, m_currentPosition.get()); + sendPosition(watchersCopy, m_currentPosition.get()); if (!hasListeners()) - m_service->stopUpdating(); + stopUpdating(); +} + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +void Geolocation::setPosition(GeolocationPosition* position) +{ + positionChanged(createGeoposition(position)); +} + +void Geolocation::setError(GeolocationError* error) +{ + RefPtr<PositionError> positionError = createPositionError(error); + handleError(positionError.get()); +} + +#else + +void Geolocation::geolocationServicePositionChanged(GeolocationService* service) +{ + ASSERT_UNUSED(service, service == m_service); + ASSERT(m_service->lastPosition()); + + positionChanged(m_service->lastPosition()); } void Geolocation::geolocationServiceErrorOccurred(GeolocationService* service) { ASSERT(service->lastError()); - + // Note that we do not stop timers here. For one-shots, the request is // cleared in handleError. For watchers, the spec requires that the timer is // not cleared. handleError(service->lastError()); } +#endif + +bool Geolocation::startUpdating(PositionOptions* options) +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + // FIXME: Pass options to client. + UNUSED_PARAM(options); + + if (!m_frame) + return false; + + Page* page = m_frame->page(); + if (!page) + return false; + + page->geolocationController()->addObserver(this); + return true; +#else + return m_service->startUpdating(options); +#endif +} + +void Geolocation::stopUpdating() +{ +#if ENABLE(CLIENT_BASED_GEOLOCATION) + if (!m_frame) + return; + + Page* page = m_frame->page(); + if (!page) + return; + + page->geolocationController()->removeObserver(this); +#else + m_service->stopUpdating(); +#endif + +} + bool Geolocation::operator==(const EventListener& listener) { if (listener.type() != GeolocationEventListenerType) diff --git a/WebCore/page/Geolocation.h b/WebCore/page/Geolocation.h index fd9d560..5b5feb5 100644 --- a/WebCore/page/Geolocation.h +++ b/WebCore/page/Geolocation.h @@ -48,8 +48,16 @@ namespace WebCore { class Frame; class CachedPositionManager; - -class Geolocation : public GeolocationServiceClient, public EventListener { +#if ENABLE(CLIENT_BASED_GEOLOCATION) +class GeolocationPosition; +class GeolocationError; +#endif + +class Geolocation : public EventListener +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + , public GeolocationServiceClient +#endif +{ public: static PassRefPtr<Geolocation> create(Frame* frame) { return adoptRef(new Geolocation(frame)); } @@ -57,7 +65,7 @@ public: void disconnectFrame(); - Geoposition* lastPosition() const { return m_service->lastPosition(); } + Geoposition* lastPosition(); void getCurrentPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); int watchPosition(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -73,6 +81,11 @@ public: void setShouldClearCache(bool shouldClearCache) { m_shouldClearCache = shouldClearCache; } bool shouldClearCache() const { return m_shouldClearCache; } +#if ENABLE(CLIENT_BASED_GEOLOCATION) + void setPostion(GeolocationPosition*); + void setError(GeolocationError*); +#endif + static void setDatabasePath(String); private: @@ -126,14 +139,20 @@ private: void stopTimersForWatchers(); void stopTimers(); + void positionChanged(PassRefPtr<Geoposition>); void makeSuccessCallbacks(); void handleError(PositionError*); void requestPermission(); + bool startUpdating(PositionOptions*); + void stopUpdating(); + +#if !ENABLE(CLIENT_BASED_GEOLOCATION) // GeolocationServiceClient virtual void geolocationServicePositionChanged(GeolocationService*); virtual void geolocationServiceErrorOccurred(GeolocationService*); +#endif PassRefPtr<GeoNotifier> startRequest(PassRefPtr<PositionCallback>, PassRefPtr<PositionErrorCallback>, PassRefPtr<PositionOptions>); @@ -151,7 +170,11 @@ private: GeoNotifierSet m_oneShots; Watchers m_watchers; Frame* m_frame; +#if !ENABLE(CLIENT_BASED_GEOLOCATION) OwnPtr<GeolocationService> m_service; +#endif + RefPtr<Geoposition> m_lastPosition; + RefPtr<Geoposition> m_currentPosition; enum { Unknown, diff --git a/WebCore/page/GeolocationController.cpp b/WebCore/page/GeolocationController.cpp new file mode 100644 index 0000000..44eba6e --- /dev/null +++ b/WebCore/page/GeolocationController.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2009 Apple 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. + */ + +#include "config.h" +#include "GeolocationController.h" + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "GeolocationControllerClient.h" + +namespace WebCore { + +GeolocationController::GeolocationController(Page* page, GeolocationControllerClient* client) + : m_page(page) + , m_client(client) +{ +} + +GeolocationController::~GeolocationController() +{ +} + +void GeolocationController::addObserver(Geolocation* observer) +{ + ASSERT(!m_observers.contains(observer)); + + bool wasEmpty = m_observers.isEmpty(); + m_observers.add(observer); + if (wasEmpty) + m_client->startUpdating(); +} + +void GeolocationController::removeObserver(Geolocation* observer) +{ + ASSERT(m_observers.contains(observer)); + + m_observers.remove(observer); + if (m_observers.isEmpty()) + m_client->stopUpdating(); +} + +void GeolocationController::positionChanged(GeolocationPosition* position) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setPosition(position); +} + +void GeolocationController::errorOccurred(GeolocationError* error) +{ + HashSet<RefPtr<Geolocation> >::const_iterator end = m_observers.end(); + for (HashSet<RefPtr<Geolocation> >::const_iterator it = m_observers.begin(); it != end; ++it) + (*it)->setError(error); +} + +GeolocationPosition* GeolocationController::lastPosition() +{ + return m_client->lastPosition(); +} + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) diff --git a/WebCore/page/GeolocationController.h b/WebCore/page/GeolocationController.h new file mode 100644 index 0000000..80f9ca8 --- /dev/null +++ b/WebCore/page/GeolocationController.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2009 Apple 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. + */ + +#ifndef GeolocationController_h +#define GeolocationController_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "Geolocation.h" +#include <wtf/HashSet.h> +#include <wtf/Noncopyable.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationControllerClient; +class GeolocationError; +class GeolocationPosition; +class Page; + +class GeolocationController : public Noncopyable { +public: + GeolocationController(Page*, GeolocationControllerClient*); + ~GeolocationController(); + + void addObserver(Geolocation*); + void removeObserver(Geolocation*); + + void positionChanged(GeolocationPosition*); + void errorOccurred(GeolocationError*); + + GeolocationPosition* lastPosition(); + +private: + Page* m_page; + GeolocationControllerClient* m_client; + + HashSet<RefPtr<Geolocation> > m_observers; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationController_h diff --git a/WebCore/page/GeolocationControllerClient.h b/WebCore/page/GeolocationControllerClient.h new file mode 100644 index 0000000..830c64b --- /dev/null +++ b/WebCore/page/GeolocationControllerClient.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2009 Apple 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. + */ + +#ifndef GeolocationControllerClient_h +#define GeolocationControllerClient_h + +namespace WebCore { + +class GeolocationPosition; + +class GeolocationControllerClient { +public: + virtual void startUpdating() = 0; + virtual void stopUpdating() = 0; + virtual GeolocationPosition* lastPosition() = 0; + +protected: + virtual ~GeolocationControllerClient() { } +}; + +} // namespace WebCore + +#endif // GeolocationControllerClient_h diff --git a/WebCore/page/GeolocationError.h b/WebCore/page/GeolocationError.h new file mode 100644 index 0000000..9761ca6 --- /dev/null +++ b/WebCore/page/GeolocationError.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2009 Apple 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. + */ + +#ifndef GeolocationError_h +#define GeolocationError_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include "PlatformString.h" +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationError : public RefCounted<GeolocationError> { +public: + enum ErrorCode { + PermissionDenied, + PositionUnavailable + }; + + static PassRefPtr<GeolocationError> create(ErrorCode code, const String& message) { return adoptRef(new GeolocationError(code, message)); } + + ErrorCode code() const { return m_code; } + const String& message() const { return m_message; } + +private: + GeolocationError(ErrorCode code, const String& message); + + ErrorCode m_code; + String m_message; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationError_h diff --git a/WebCore/page/GeolocationPosition.h b/WebCore/page/GeolocationPosition.h new file mode 100644 index 0000000..c31e9c4 --- /dev/null +++ b/WebCore/page/GeolocationPosition.h @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2009 Apple 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. + */ + +#ifndef GeolocationPosition_h +#define GeolocationPosition_h + +#if ENABLE(CLIENT_BASED_GEOLOCATION) + +#include <wtf/PassRefPtr.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +class GeolocationPosition : public RefCounted<GeolocationPosition> { +public: + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy)); } + + static PassRefPtr<GeolocationPosition> create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) { return adoptRef(new GeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed)); } + + double timestamp() const { return m_timestamp; } + + double latitude() const { return m_latitude; } + double longitude() const { return m_longitude; } + double accuracy() const { return m_accuracy; } + double altitude() const { return m_altitude; } + double altitudeAccuracy() const { return m_altitudeAccuracy; } + double heading() const { return m_heading; } + double speed() const { return m_speed; } + + bool canProvideAltitude() const { return m_canProvideAltitude; } + bool canProvideAltitudeAccuracy() const { return m_canProvideAltitudeAccuracy; } + bool canProvideHeading() const { return m_canProvideHeading; } + bool canProvideSpeed() const { return m_canProvideSpeed; } + +private: + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(0) + , m_altitudeAccuracy(0) + , m_heading(0) + , m_speed(0) + , m_canProvideAltitude(false) + , m_canProvideAltitudeAccuracy(false) + , m_canProvideHeading(false) + , m_canProvideSpeed(false) + { + } + + GeolocationPosition(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed) + : m_timestamp(timestamp) + , m_latitude(latitude) + , m_longitude(longitude) + , m_accuracy(accuracy) + , m_altitude(altitude) + , m_altitudeAccuracy(altitudeAccuracy) + , m_heading(heading) + , m_speed(speed) + , m_canProvideAltitude(providesAltitude) + , m_canProvideAltitudeAccuracy(providesAltitudeAccuracy) + , m_canProvideHeading(providesHeading) + , m_canProvideSpeed(providesSpeed) + { + } + + double m_timestamp; + + double m_latitude; + double m_longitude; + double m_accuracy; + double m_altitude; + double m_altitudeAccuracy; + double m_heading; + double m_speed; + + bool m_canProvideAltitude; + bool m_canProvideAltitudeAccuracy; + bool m_canProvideHeading; + bool m_canProvideSpeed; +}; + +} // namespace WebCore + +#endif // ENABLE(CLIENT_BASED_GEOLOCATION) + +#endif // GeolocationPosition_h diff --git a/WebCore/page/Geoposition.h b/WebCore/page/Geoposition.h index f3c703b..8b215b1 100644 --- a/WebCore/page/Geoposition.h +++ b/WebCore/page/Geoposition.h @@ -37,8 +37,11 @@ typedef int ExceptionCode; class Geoposition : public RefCounted<Geoposition> { public: - static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) { return adoptRef(new Geoposition(coordinates, timestamp)); } - + static PassRefPtr<Geoposition> create(PassRefPtr<Coordinates> coordinates, DOMTimeStamp timestamp) + { + return adoptRef(new Geoposition(coordinates, timestamp)); + } + DOMTimeStamp timestamp() const { return m_timestamp; } Coordinates* coords() const { return m_coordinates.get(); } diff --git a/WebCore/page/Page.cpp b/WebCore/page/Page.cpp index c4f33d6..1a035a5 100644 --- a/WebCore/page/Page.cpp +++ b/WebCore/page/Page.cpp @@ -77,6 +77,10 @@ #include "WMLPageState.h" #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) +#include "GeolocationController.h" +#endif + namespace WebCore { static HashSet<Page*>* allPages; @@ -101,7 +105,7 @@ static void networkStateChanged() frames[i]->document()->dispatchWindowEvent(Event::create(eventName, false, false)); } -Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient) +Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, EditorClient* editorClient, DragClient* dragClient, InspectorClient* inspectorClient, PluginHalterClient* pluginHalterClient, GeolocationControllerClient* geolocationControllerClient) : m_chrome(new Chrome(this, chromeClient)) , m_dragCaretController(new SelectionController(0, true)) #if ENABLE(DRAG_SUPPORT) @@ -114,6 +118,9 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if ENABLE(INSPECTOR) , m_inspectorController(new InspectorController(this, inspectorClient)) #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + , m_geolocationController(new GeolocationController(this, geolocationControllerClient)) +#endif , m_settings(new Settings(this)) , m_progress(new ProgressTracker) , m_backForwardList(BackForwardList::create(this)) @@ -148,6 +155,10 @@ Page::Page(ChromeClient* chromeClient, ContextMenuClient* contextMenuClient, Edi #if !ENABLE(INSPECTOR) UNUSED_PARAM(inspectorClient); #endif +#if !ENABLE(CLIENT_BASED_GEOLOCATION) + UNUSED_PARAM(geolocationControllerClient); +#endif + if (!allPages) { allPages = new HashSet<Page*>; diff --git a/WebCore/page/Page.h b/WebCore/page/Page.h index 4886464..40d96a7 100644 --- a/WebCore/page/Page.h +++ b/WebCore/page/Page.h @@ -54,6 +54,8 @@ namespace WebCore { class EditorClient; class FocusController; class Frame; + class GeolocationController; + class GeolocationControllerClient; class HaltablePlugin; class InspectorClient; class InspectorController; @@ -85,7 +87,7 @@ namespace WebCore { public: static void setNeedsReapplyStyles(); - Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*); + Page(ChromeClient*, ContextMenuClient*, EditorClient*, DragClient*, InspectorClient*, PluginHalterClient*, GeolocationControllerClient*); ~Page(); RenderTheme* theme() const { return m_theme.get(); }; @@ -144,6 +146,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) InspectorController* inspectorController() const { return m_inspectorController.get(); } #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + GeolocationController* geolocationController() const { return m_geolocationController.get(); } +#endif Settings* settings() const { return m_settings.get(); } ProgressTracker* progress() const { return m_progress.get(); } @@ -250,6 +255,9 @@ namespace WebCore { #if ENABLE(INSPECTOR) OwnPtr<InspectorController> m_inspectorController; #endif +#if ENABLE(CLIENT_BASED_GEOLOCATION) + OwnPtr<GeolocationController> m_geolocationController; +#endif OwnPtr<Settings> m_settings; OwnPtr<ProgressTracker> m_progress; diff --git a/WebCore/svg/graphics/SVGImage.cpp b/WebCore/svg/graphics/SVGImage.cpp index c4be11e..5f050a4 100644 --- a/WebCore/svg/graphics/SVGImage.cpp +++ b/WebCore/svg/graphics/SVGImage.cpp @@ -245,7 +245,7 @@ bool SVGImage::dataChanged(bool allDataReceived) // FIXME: If this SVG ends up loading itself, we might leak the world. // The comment said that the Cache code does not know about CachedImages // holding Frames and won't know to break the cycle. But - m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0)); + m_page.set(new Page(m_chromeClient.get(), dummyContextMenuClient, dummyEditorClient, dummyDragClient, dummyInspectorClient, 0, 0)); m_page->settings()->setJavaScriptEnabled(false); m_page->settings()->setPluginsEnabled(false); |