diff --git a/dom/public/idl/geolocation/Makefile.in b/dom/public/idl/geolocation/Makefile.in index 4cd3fd3121f3..c7c649da8fbd 100644 --- a/dom/public/idl/geolocation/Makefile.in +++ b/dom/public/idl/geolocation/Makefile.in @@ -46,12 +46,15 @@ MODULE = dom XPIDL_MODULE = dom_geolocation GRE_MODULE = 1 -XPIDLSRCS = \ - nsIDOMGeolocation.idl \ - nsIDOMGeolocationCallback.idl \ - nsIDOMGeolocator.idl \ - nsIDOMNavigatorGeolocator.idl \ - nsIGeolocationProvider.idl \ +XPIDLSRCS = \ + nsIDOMGeoGeolocation.idl \ + nsIDOMGeoPosition.idl \ + nsIDOMGeoPositionCallback.idl \ + nsIDOMGeoPositionError.idl \ + nsIDOMGeoPositionErrorCallback.idl \ + nsIDOMGeoPositionOptions.idl \ + nsIDOMNavigatorGeolocation.idl \ + nsIGeolocationProvider.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/public/idl/geolocation/nsIDOMGeoGeolocation.idl b/dom/public/idl/geolocation/nsIDOMGeoGeolocation.idl new file mode 100644 index 000000000000..e224f1e450cf --- /dev/null +++ b/dom/public/idl/geolocation/nsIDOMGeoGeolocation.idl @@ -0,0 +1,58 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Geolocation. + * + * The Initial Developer of the Original Code is Mozilla Corporation + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Doug Turner (Original Author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "domstubs.idl" + +interface nsIDOMGeoPosition; +interface nsIDOMGeoPositionOptions; +interface nsIDOMGeoPositionCallback; +interface nsIDOMGeoPositionErrorCallback; + +[scriptable, function, uuid(CE495440-C8B9-42DE-B67C-60E6928C0F40)] +interface nsIDOMGeoGeolocation : nsISupports +{ + readonly attribute nsIDOMGeoPosition lastPosition; + + void getCurrentPosition(in nsIDOMGeoPositionCallback successCallback, + in nsIDOMGeoPositionErrorCallback errorCallback, + in nsIDOMGeoPositionOptions options); + + unsigned short watchPosition(in nsIDOMGeoPositionCallback successCallback, + in nsIDOMGeoPositionErrorCallback errorCallback, + in nsIDOMGeoPositionOptions options); + + void clearWatch(in unsigned short watchId); +}; diff --git a/dom/public/idl/geolocation/nsIDOMGeolocation.idl b/dom/public/idl/geolocation/nsIDOMGeoPosition.idl similarity index 88% rename from dom/public/idl/geolocation/nsIDOMGeolocation.idl rename to dom/public/idl/geolocation/nsIDOMGeoPosition.idl index 5dda53a098eb..790f4fa1d15d 100644 --- a/dom/public/idl/geolocation/nsIDOMGeolocation.idl +++ b/dom/public/idl/geolocation/nsIDOMGeoPosition.idl @@ -37,15 +37,15 @@ #include "domstubs.idl" -[scriptable, uuid(CEEBF85D-F5E2-4E27-981A-0BF8705ABF0A)] -interface nsIDOMGeolocation : nsISupports +[scriptable, uuid(F9C6A2C0-9D9B-48A2-B84B-12CC95283CD0)] +interface nsIDOMGeoPosition : nsISupports { readonly attribute double latitude; readonly attribute double longitude; readonly attribute double altitude; - - readonly attribute double horizontalAccuracy; - readonly attribute double verticalAccuracy; - + readonly attribute double accuracy; + readonly attribute double altitudeAccuracy; + readonly attribute double heading; + readonly attribute double velocity; readonly attribute DOMTimeStamp timestamp; }; diff --git a/dom/public/idl/geolocation/nsIDOMGeolocationCallback.idl b/dom/public/idl/geolocation/nsIDOMGeoPositionCallback.idl similarity index 89% rename from dom/public/idl/geolocation/nsIDOMGeolocationCallback.idl rename to dom/public/idl/geolocation/nsIDOMGeoPositionCallback.idl index aafdbffd9afd..ac4763e792b0 100644 --- a/dom/public/idl/geolocation/nsIDOMGeolocationCallback.idl +++ b/dom/public/idl/geolocation/nsIDOMGeoPositionCallback.idl @@ -37,9 +37,9 @@ #include "domstubs.idl" -interface nsIDOMGeolocation; +interface nsIDOMGeoPosition; -[scriptable, function, uuid(679C8833-5D8C-430D-A7A3-FF13FE082098)] -interface nsIDOMGeolocationCallback : nsISupports { - void onRequest(in nsIDOMGeolocation position); +[scriptable, function, uuid(527E8B53-6F29-4B6A-8D04-5C1666A4C4C1)] +interface nsIDOMGeoPositionCallback : nsISupports { + void handleEvent(in nsIDOMGeoPosition position); }; diff --git a/dom/public/idl/geolocation/nsIDOMGeolocator.idl b/dom/public/idl/geolocation/nsIDOMGeoPositionError.idl similarity index 81% rename from dom/public/idl/geolocation/nsIDOMGeolocator.idl rename to dom/public/idl/geolocation/nsIDOMGeoPositionError.idl index 1f6177bb1d89..f2421018ec3a 100644 --- a/dom/public/idl/geolocation/nsIDOMGeolocator.idl +++ b/dom/public/idl/geolocation/nsIDOMGeoPositionError.idl @@ -35,20 +35,11 @@ * ***** END LICENSE BLOCK ***** */ - #include "domstubs.idl" -interface nsIDOMGeolocation; -interface nsIDOMGeolocationCallback; - -[scriptable, uuid(3C3B69FF-3AFA-4D4C-BA3A-F03940E74E14)] -interface nsIDOMGeolocator : nsISupports +[scriptable, uuid(39928BF8-4466-4A64-BF5F-97114A5CD171)] +interface nsIDOMGeoPositionError : nsISupports { - readonly attribute nsIDOMGeolocation lastPosition; - - void getCurrentPosition(in nsIDOMGeolocationCallback callback); - - unsigned short watchPosition(in nsIDOMGeolocationCallback callback); - - void clearWatch(in unsigned short watchId); + readonly attribute short code; + readonly attribute DOMString message; }; diff --git a/dom/public/idl/geolocation/nsIDOMGeoPositionErrorCallback.idl b/dom/public/idl/geolocation/nsIDOMGeoPositionErrorCallback.idl new file mode 100644 index 000000000000..3fa03e376d69 --- /dev/null +++ b/dom/public/idl/geolocation/nsIDOMGeoPositionErrorCallback.idl @@ -0,0 +1,45 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Geolocation. + * + * The Initial Developer of the Original Code is Mozilla Corporation + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Doug Turner (Original Author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#include "domstubs.idl" + +interface nsIDOMGeoPositionError; + +[scriptable, function, uuid(7D9B09D9-4843-43EB-A7A7-67F7DDA6B3C4)] +interface nsIDOMGeoPositionErrorCallback : nsISupports { + void handleEvent(in nsIDOMGeoPositionError position); +}; diff --git a/dom/public/idl/geolocation/nsIDOMGeoPositionOptions.idl b/dom/public/idl/geolocation/nsIDOMGeoPositionOptions.idl new file mode 100644 index 000000000000..6d8532df2a8f --- /dev/null +++ b/dom/public/idl/geolocation/nsIDOMGeoPositionOptions.idl @@ -0,0 +1,44 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Geolocation. + * + * The Initial Developer of the Original Code is Mozilla Corporation + * Portions created by the Initial Developer are Copyright (C) 2008 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Doug Turner (Original Author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#include "domstubs.idl" + +[scriptable, uuid(03723BAE-E1EC-4F35-965F-0A9FDF573D86)] +interface nsIDOMGeoPositionOptions : nsISupports +{ + attribute boolean enableHiqhAccuracy; +}; diff --git a/dom/public/idl/geolocation/nsIDOMNavigatorGeolocator.idl b/dom/public/idl/geolocation/nsIDOMNavigatorGeolocation.idl similarity index 90% rename from dom/public/idl/geolocation/nsIDOMNavigatorGeolocator.idl rename to dom/public/idl/geolocation/nsIDOMNavigatorGeolocation.idl index 7983e1eea600..b10a5bb0da63 100644 --- a/dom/public/idl/geolocation/nsIDOMNavigatorGeolocator.idl +++ b/dom/public/idl/geolocation/nsIDOMNavigatorGeolocation.idl @@ -37,14 +37,14 @@ #include "domstubs.idl" -interface nsIDOMGeolocator; +interface nsIDOMGeoGeolocation; /** * Property that extends the navigator object. */ -[scriptable, uuid(1470B9BC-F17C-4419-85A4-E6C1742977A3)] -interface nsIDOMNavigatorGeolocator : nsISupports +[scriptable, uuid(9F218D6A-42EC-4B8A-AEE9-E29CA96A4EAE)] +interface nsIDOMNavigatorGeolocation : nsISupports { - readonly attribute nsIDOMGeolocator geolocator; + readonly attribute nsIDOMGeoGeolocation geolocation; }; diff --git a/dom/public/idl/geolocation/nsIGeolocationProvider.idl b/dom/public/idl/geolocation/nsIGeolocationProvider.idl index b3afc918b6d3..432603ece872 100644 --- a/dom/public/idl/geolocation/nsIGeolocationProvider.idl +++ b/dom/public/idl/geolocation/nsIGeolocationProvider.idl @@ -40,7 +40,7 @@ interface nsIURI; interface nsIDOMWindow; -interface nsIDOMGeolocation; +interface nsIDOMGeoPosition; interface nsIGeolocationPrompt; /** @@ -69,7 +69,7 @@ interface nsIGeolocationRequest : nsISupports { /** * Interface provides a way for the application to handle - * the UI prompts associated with geolocation. + * the UI prompts associated with geo position. */ [scriptable, function, uuid(2300C895-1BEE-4297-912C-A57082F3E936)] interface nsIGeolocationPrompt : nsISupports { @@ -91,7 +91,7 @@ interface nsIGeolocationUpdate : nsISupports { * has been discovered. * This must be called on the main thread */ - void update(in nsIDOMGeolocation location); + void update(in nsIDOMGeoPosition position); }; @@ -126,7 +126,7 @@ interface nsIGeolocationProvider : nsISupports { * currentLocation return the current location as seen by * the provider. may be null. */ - readonly attribute nsIDOMGeolocation currentLocation; + readonly attribute nsIDOMGeoPosition currentPosition; /** * shutdown diff --git a/dom/public/nsDOMClassInfoID.h b/dom/public/nsDOMClassInfoID.h index 5721a5638a7f..adbeac782d1d 100644 --- a/dom/public/nsDOMClassInfoID.h +++ b/dom/public/nsDOMClassInfoID.h @@ -426,8 +426,9 @@ enum nsDOMClassInfoID { eDOMClassInfo_MessageEvent_id, // Geolocation - eDOMClassInfo_Geolocation_id, - eDOMClassInfo_Geolocator_id, + eDOMClassInfo_GeoGeolocation_id, + eDOMClassInfo_GeoPosition_id, + eDOMClassInfo_GeoPositionError_id, // @font-face in CSS eDOMClassInfo_CSSFontFaceRule_id, diff --git a/dom/src/base/nsDOMClassInfo.cpp b/dom/src/base/nsDOMClassInfo.cpp index c6ef180432e5..e6e83b04b6fa 100644 --- a/dom/src/base/nsDOMClassInfo.cpp +++ b/dom/src/base/nsDOMClassInfo.cpp @@ -457,8 +457,9 @@ #include "nsIDOMLoadStatusEvent.h" // Geolocation -#include "nsIDOMGeolocation.h" -#include "nsIDOMGeolocator.h" +#include "nsIDOMGeoGeolocation.h" +#include "nsIDOMGeoPosition.h" +#include "nsIDOMGeoPositionError.h" #include "nsIDOMFileList.h" #include "nsIDOMFile.h" @@ -1251,12 +1252,15 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(MessageEvent, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(Geolocation, nsDOMGenericSH, + NS_DEFINE_CLASSINFO_DATA(GeoGeolocation, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - - NS_DEFINE_CLASSINFO_DATA(Geolocator, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) - + + NS_DEFINE_CLASSINFO_DATA(GeoPosition, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + + NS_DEFINE_CLASSINFO_DATA(GeoPositionError, nsDOMGenericSH, + DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(CSSFontFaceRule, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(CSSFontFaceStyleDecl, nsCSSStyleDeclSH, @@ -1954,7 +1958,7 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator) DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigator) DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSNavigator) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocator) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMNavigatorGeolocation) DOM_CLASSINFO_MAP_ENTRY(nsIDOMClientInformation) DOM_CLASSINFO_MAP_END @@ -3453,12 +3457,16 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_EVENT_MAP_ENTRIES DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(Geolocation, nsIDOMGeolocation) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeolocation) + DOM_CLASSINFO_MAP_BEGIN(GeoGeolocation, nsIDOMGeoGeolocation) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoGeolocation) DOM_CLASSINFO_MAP_END - DOM_CLASSINFO_MAP_BEGIN(Geolocator, nsIDOMGeolocator) - DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeolocator) + DOM_CLASSINFO_MAP_BEGIN(GeoPosition, nsIDOMGeoPosition) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPosition) + DOM_CLASSINFO_MAP_END + + DOM_CLASSINFO_MAP_BEGIN(GeoPositionError, nsIDOMGeoPositionError) + DOM_CLASSINFO_MAP_ENTRY(nsIDOMGeoPositionError) DOM_CLASSINFO_MAP_END DOM_CLASSINFO_MAP_BEGIN(CSSFontFaceRule, nsIDOMCSSFontFaceRule) @@ -3814,7 +3822,7 @@ nsDOMClassInfo::PostCreate(nsIXPConnectWrappedNative *wrapper, // above) in order to make sure that prototype delegation works correctly. // Consider if a site sets HTMLElement.prototype.foopy = function () { ... } // Now, calling document.body.foopy() needs to ensure that looking up foopy - // on document.body's prototype will find the right function. This + // on document.body's prototype will find the right function. Thisb // LookupProperty accomplishes that. // XXX This shouldn't need to go through the JS engine. Instead, we should // be calling nsWindowSH::GlobalResolve directly. diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index 07d013afb86a..fc5432fb9000 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -112,7 +112,7 @@ #include "nsIDOMPopupBlockedEvent.h" #include "nsIDOMPkcs11.h" #include "nsIDOMOfflineResourceList.h" -#include "nsIDOMGeolocation.h" +#include "nsIDOMGeoGeolocation.h" #include "nsDOMString.h" #include "nsIEmbeddingSiteWindow2.h" #include "nsThreadUtils.h" @@ -9040,7 +9040,7 @@ NS_INTERFACE_MAP_BEGIN(nsNavigator) NS_INTERFACE_MAP_ENTRY(nsIDOMNavigator) NS_INTERFACE_MAP_ENTRY(nsIDOMJSNavigator) NS_INTERFACE_MAP_ENTRY(nsIDOMClientInformation) - NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocator) + NS_INTERFACE_MAP_ENTRY(nsIDOMNavigatorGeolocation) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Navigator) NS_INTERFACE_MAP_END @@ -9057,10 +9057,10 @@ nsNavigator::SetDocShell(nsIDocShell *aDocShell) mPlugins->SetDocShell(aDocShell); // if there is a page transition, make sure delete the geolocation object - if (mGeolocator) + if (mGeolocation) { - mGeolocator->Shutdown(); - mGeolocator = nsnull; + mGeolocation->Shutdown(); + mGeolocation = nsnull; } } @@ -9583,10 +9583,10 @@ nsNavigator::LoadingNewDocument() mMimeTypes = nsnull; mPlugins = nsnull; - if (mGeolocator) + if (mGeolocation) { - mGeolocator->Shutdown(); - mGeolocator = nsnull; + mGeolocation->Shutdown(); + mGeolocation = nsnull; } } @@ -9709,19 +9709,19 @@ nsNavigator::MozIsLocallyAvailable(const nsAString &aURI, } //***************************************************************************** -// nsNavigator::nsIDOMNavigatorGeolocator +// nsNavigator::nsIDOMNavigatorGeolocation //***************************************************************************** -NS_IMETHODIMP nsNavigator::GetGeolocator(nsIDOMGeolocator **_retval) +NS_IMETHODIMP nsNavigator::GetGeolocation(nsIDOMGeoGeolocation **_retval) { NS_ENSURE_ARG_POINTER(_retval); - if (!mGeolocator) { + if (!mGeolocation) { nsCOMPtr contentDOMWindow(do_GetInterface(mDocShell)); - mGeolocator = new nsGeolocator(contentDOMWindow); + mGeolocation = new nsGeolocation(contentDOMWindow); } - NS_IF_ADDREF(*_retval = mGeolocator); + NS_IF_ADDREF(*_retval = mGeolocation); return NS_OK; } diff --git a/dom/src/base/nsGlobalWindow.h b/dom/src/base/nsGlobalWindow.h index 10a09e1a5847..556eb32b4648 100644 --- a/dom/src/base/nsGlobalWindow.h +++ b/dom/src/base/nsGlobalWindow.h @@ -65,7 +65,7 @@ #include "nsIDOM3EventTarget.h" #include "nsIDOMNSEventTarget.h" #include "nsIDOMNavigator.h" -#include "nsIDOMNavigatorGeolocator.h" +#include "nsIDOMNavigatorGeolocation.h" #include "nsIDOMNSLocation.h" #include "nsIDOMWindowInternal.h" #include "nsIInterfaceRequestor.h" @@ -125,7 +125,7 @@ class PostMessageEvent; class nsDOMOfflineResourceList; class nsDOMOfflineLoadStatusList; -class nsGeolocator; +class nsGeolocation; // permissible values for CheckOpenAllow enum OpenAllowValue { @@ -809,7 +809,7 @@ protected: class nsNavigator : public nsIDOMNavigator, public nsIDOMJSNavigator, public nsIDOMClientInformation, - public nsIDOMNavigatorGeolocator + public nsIDOMNavigatorGeolocation { public: nsNavigator(nsIDocShell *aDocShell); @@ -819,7 +819,7 @@ public: NS_DECL_NSIDOMNAVIGATOR NS_DECL_NSIDOMJSNAVIGATOR NS_DECL_NSIDOMCLIENTINFORMATION - NS_DECL_NSIDOMNAVIGATORGEOLOCATOR + NS_DECL_NSIDOMNAVIGATORGEOLOCATION void SetDocShell(nsIDocShell *aDocShell); nsIDocShell *GetDocShell() @@ -833,7 +833,7 @@ public: protected: nsRefPtr mMimeTypes; nsRefPtr mPlugins; - nsRefPtr mGeolocator; + nsRefPtr mGeolocation; nsIDocShell* mDocShell; // weak reference static jsval sPrefInternal_id; diff --git a/dom/src/geolocation/MaemoLocationProvider.cpp b/dom/src/geolocation/MaemoLocationProvider.cpp index 7b029ff4a5af..14770cdb2e2a 100644 --- a/dom/src/geolocation/MaemoLocationProvider.cpp +++ b/dom/src/geolocation/MaemoLocationProvider.cpp @@ -53,12 +53,13 @@ MaemoLocationProvider::~MaemoLocationProvider() void location_changed (LocationGPSDevice *device, gpointer userdata) { MaemoLocationProvider* provider = (MaemoLocationProvider*) userdata; - nsRefPtr somewhere = new nsGeolocation(device->fix->latitude, + nsRefPtr somewhere = new nsGeoPosition(device->fix->latitude, device->fix->longitude, device->fix->altitude, device->fix->eph, device->fix->epv, - device->fix->time); + 0,0, + device->fix->time); provider->Update(somewhere); } @@ -90,10 +91,10 @@ NS_IMETHODIMP MaemoLocationProvider::Watch(nsIGeolocationUpdate *callback) return NS_OK; } -/* readonly attribute nsIDOMGeolocation currentLocation; */ -NS_IMETHODIMP MaemoLocationProvider::GetCurrentLocation(nsIDOMGeolocation * *aCurrentLocation) +/* readonly attribute nsIDOMGeoPosition currentPosition; */ +NS_IMETHODIMP MaemoLocationProvider::GetCurrentPosition(nsIDOMGeoPosition * *aCurrentPosition) { - NS_IF_ADDREF(*aCurrentLocation = mLastLocation); + NS_IF_ADDREF(*aCurrentPosition = mLastPosition); return NS_OK; } @@ -110,10 +111,10 @@ NS_IMETHODIMP MaemoLocationProvider::Shutdown() return NS_OK; } -void MaemoLocationProvider::Update(nsIDOMGeolocation* aLocation) +void MaemoLocationProvider::Update(nsIDOMGeoPosition* aPosition) { mHasSeenLocation = PR_TRUE; - mLastLocation = aLocation; + mLastPosition = aPosition; if (mCallback) - mCallback->Update(aLocation); + mCallback->Update(aPosition); } diff --git a/dom/src/geolocation/MaemoLocationProvider.h b/dom/src/geolocation/MaemoLocationProvider.h index e41b5632ff64..70ac3d4410b3 100644 --- a/dom/src/geolocation/MaemoLocationProvider.h +++ b/dom/src/geolocation/MaemoLocationProvider.h @@ -35,7 +35,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsIGeolocationProvider.h" -#include "nsIDOMGeolocation.h" +#include "nsIDOMGeoPosition.h" #include "nsCOMPtr.h" #include @@ -58,12 +58,12 @@ public: MaemoLocationProvider(); - void Update(nsIDOMGeolocation* aLocation); + void Update(nsIDOMGeoPosition* aPosition); private: ~MaemoLocationProvider(); - nsCOMPtr mLastLocation; + nsCOMPtr mLastPosition; nsIGeolocationUpdate* mCallback; // weak reference by contract. diff --git a/dom/src/geolocation/nsGeolocation.cpp b/dom/src/geolocation/nsGeolocation.cpp index da3244e1529f..003b1fa9b5ef 100644 --- a/dom/src/geolocation/nsGeolocation.cpp +++ b/dom/src/geolocation/nsGeolocation.cpp @@ -47,6 +47,9 @@ #include "nsIObserverService.h" #include "nsIPrefService.h" #include "nsIPrefBranch2.h" +#include "nsIProxyObjectManager.h" + +#include #ifdef NS_OSSO #include "MaemoLocationProvider.h" @@ -54,12 +57,64 @@ #include "nsIDOMDocument.h" #include "nsIDocument.h" + +//////////////////////////////////////////////////// +// nsDOMGeoPositionError +//////////////////////////////////////////////////// + +class nsDOMGeoPositionError : public nsIDOMGeoPositionError +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIDOMGEOPOSITIONERROR + + nsDOMGeoPositionError(PRInt16 aCode, const nsAString& aMessage); + +private: + ~nsDOMGeoPositionError(); + PRInt16 mCode; + nsString mMessage; + +}; + +NS_INTERFACE_MAP_BEGIN(nsDOMGeoPositionError) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPositionError) + NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPositionError) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPositionError) +NS_INTERFACE_MAP_END + +NS_IMPL_THREADSAFE_ADDREF(nsDOMGeoPositionError) +NS_IMPL_THREADSAFE_RELEASE(nsDOMGeoPositionError) + +nsDOMGeoPositionError::nsDOMGeoPositionError(PRInt16 aCode, const nsAString& aMessage) + : mCode(aCode), mMessage(aMessage) +{ +} + +nsDOMGeoPositionError::~nsDOMGeoPositionError(){} + + +NS_IMETHODIMP +nsDOMGeoPositionError::GetCode(PRInt16 *aCode) +{ + NS_ENSURE_ARG_POINTER(aCode); + *aCode = mCode; + return NS_OK; +} + +NS_IMETHODIMP +nsDOMGeoPositionError::GetMessage(nsAString & aMessage) +{ + aMessage = mMessage; + return NS_OK; +} + //////////////////////////////////////////////////// // nsGeolocationRequest //////////////////////////////////////////////////// -nsGeolocationRequest::nsGeolocationRequest(nsGeolocator* locator, nsIDOMGeolocationCallback* callback) - : mAllowed(PR_FALSE), mCleared(PR_FALSE), mFuzzLocation(PR_FALSE), mCallback(callback), mLocator(locator) +nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* locator, nsIDOMGeoPositionCallback* callback, nsIDOMGeoPositionErrorCallback* errorCallback) + : mAllowed(PR_FALSE), mCleared(PR_FALSE), mFuzzLocation(PR_FALSE), mCallback(callback), mErrorCallback(errorCallback), mLocator(locator) { } @@ -96,9 +151,6 @@ nsGeolocationRequest::GetRequestingWindow(nsIDOMWindow * *aRequestingWindow) NS_IMETHODIMP nsGeolocationRequest::Cancel() { - // pass a null back. - mCallback->OnRequest(nsnull); - // remove ourselves from the locators callback lists. mLocator->RemoveRequest(this); return NS_OK; @@ -108,8 +160,29 @@ NS_IMETHODIMP nsGeolocationRequest::Allow() { // Kick off the geo device, if it isn't already running - nsRefPtr geoService = nsGeolocatorService::GetInstance(); - geoService->StartDevice(); + nsRefPtr geoService = nsGeolocationService::GetInstance(); + nsresult rv = geoService->StartDevice(); + + if (NS_FAILED(rv)) { + + if (!mErrorCallback) + return NS_OK; // If no one is listening for errors, fail silently. + + // TODO what are the real error values here!! + nsRefPtr positionError = new nsDOMGeoPositionError(1, NS_LITERAL_STRING("")); + + nsCOMPtr callbackProxy; + + nsCOMPtr proxyObjMgr = do_GetService("@mozilla.org/xpcomproxy;1"); + proxyObjMgr->GetProxyForObject(NS_PROXY_TO_MAIN_THREAD, + NS_GET_IID(nsIDOMGeoPositionErrorCallback), + mErrorCallback, + NS_PROXY_ASYNC | NS_PROXY_ALWAYS, + getter_AddRefs(callbackProxy)); + + callbackProxy->HandleEvent(positionError); + return rv; + } mAllowed = PR_TRUE; return NS_OK; @@ -129,7 +202,7 @@ nsGeolocationRequest::MarkCleared() } void -nsGeolocationRequest::SendLocation(nsIDOMGeolocation* location) +nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* position) { if (mCleared || !mAllowed) return; @@ -137,34 +210,46 @@ nsGeolocationRequest::SendLocation(nsIDOMGeolocation* location) //TODO mFuzzLocation. Needs to be defined what we do here. if (mFuzzLocation) { - // need to make a copy because nsIDOMGeolocation is + // need to make a copy because nsIDOMGeoPosition is // readonly, and we are not sure of its implementation. - double lat, lon, alt, herror, verror; + double lat, lon, alt, herror, verror, heading, velocity; DOMTimeStamp time; - location->GetLatitude(&lat); - location->GetLongitude(&lon); - location->GetAltitude(&alt); - location->GetHorizontalAccuracy(&herror); - location->GetVerticalAccuracy(&verror); - location->GetTimestamp(&time); + position->GetLatitude(&lat); + position->GetLongitude(&lon); + position->GetAltitude(&alt); + position->GetAccuracy(&herror); + position->GetAltitudeAccuracy(&verror); + position->GetHeading(&heading); + position->GetVelocity(&velocity); + position->GetTimestamp(&time); - // do something to the numbers... TODO. - - // mask out any location until we figure out how to fuzz locations; - lat = 0; lon = 0; alt = 0; herror = 100000; verror = 100000; + // Truncate ? + // lat = floor(lat*10+.5)/10; + // lon = floor(lon*10+.5)/10; + // herror = 1600; /* about 1 mile */ - nsRefPtr somewhere = new nsGeolocation(lat, + lat = 0; + lon = 0; + herror = 0; + heading = 0; + velocity = 0; + alt = 0; + verror = 0; + + nsRefPtr somewhere = new nsGeoPosition(lat, lon, alt, herror, verror, + heading, + velocity, time); - mCallback->OnRequest(somewhere); + mCallback->HandleEvent(somewhere); return; } - mCallback->OnRequest(location); + mCallback->HandleEvent(position); } void @@ -172,76 +257,91 @@ nsGeolocationRequest::Shutdown() { mCleared = PR_TRUE; mCallback = nsnull; + mErrorCallback = nsnull; } //////////////////////////////////////////////////// -// nsGeolocation +// nsGeoPosition //////////////////////////////////////////////////// -NS_INTERFACE_MAP_BEGIN(nsGeolocation) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeolocation) - NS_INTERFACE_MAP_ENTRY(nsIDOMGeolocation) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Geolocation) +NS_INTERFACE_MAP_BEGIN(nsGeoPosition) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoPosition) + NS_INTERFACE_MAP_ENTRY(nsIDOMGeoPosition) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoPosition) NS_INTERFACE_MAP_END -NS_IMPL_THREADSAFE_ADDREF(nsGeolocation) -NS_IMPL_THREADSAFE_RELEASE(nsGeolocation) +NS_IMPL_THREADSAFE_ADDREF(nsGeoPosition) +NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition) NS_IMETHODIMP -nsGeolocation::GetLatitude(double *aLatitude) +nsGeoPosition::GetLatitude(double *aLatitude) { *aLatitude = mLat; return NS_OK; } NS_IMETHODIMP -nsGeolocation::GetLongitude(double *aLongitude) +nsGeoPosition::GetLongitude(double *aLongitude) { *aLongitude = mLong; return NS_OK; } NS_IMETHODIMP -nsGeolocation::GetAltitude(double *aAltitude) +nsGeoPosition::GetAltitude(double *aAltitude) { *aAltitude = mAlt; return NS_OK; } NS_IMETHODIMP -nsGeolocation::GetHorizontalAccuracy(double *aHorizontalAccuracy) +nsGeoPosition::GetAccuracy(double *aAccuracy) { - *aHorizontalAccuracy = mHError; + *aAccuracy = mHError; return NS_OK; } NS_IMETHODIMP -nsGeolocation::GetVerticalAccuracy(double *aVerticalAccuracy) +nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy) { - *aVerticalAccuracy = mVError; + *aAltitudeAccuracy = mVError; return NS_OK; } NS_IMETHODIMP -nsGeolocation::GetTimestamp(DOMTimeStamp* aTimestamp) +nsGeoPosition::GetHeading(double *aHeading) +{ + *aHeading = mHeading; + return NS_OK; +} + +NS_IMETHODIMP +nsGeoPosition::GetVelocity(double *aVelocity) +{ + *aVelocity = mVelocity; + return NS_OK; +} + +NS_IMETHODIMP +nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp) { *aTimestamp = mTimestamp; return NS_OK; } //////////////////////////////////////////////////// -// nsGeolocatorService +// nsGeolocationService //////////////////////////////////////////////////// -NS_INTERFACE_MAP_BEGIN(nsGeolocatorService) +NS_INTERFACE_MAP_BEGIN(nsGeolocationService) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIGeolocationUpdate) NS_INTERFACE_MAP_ENTRY(nsIGeolocationUpdate) NS_INTERFACE_MAP_ENTRY(nsIGeolocationService) NS_INTERFACE_MAP_ENTRY(nsIObserver) NS_INTERFACE_MAP_END -NS_IMPL_THREADSAFE_ADDREF(nsGeolocatorService) -NS_IMPL_THREADSAFE_RELEASE(nsGeolocatorService) +NS_IMPL_THREADSAFE_ADDREF(nsGeolocationService) +NS_IMPL_THREADSAFE_RELEASE(nsGeolocationService) -nsGeolocatorService::nsGeolocatorService() +nsGeolocationService::nsGeolocationService() { nsCOMPtr obs = do_GetService("@mozilla.org/observer-service;1"); if (obs) { @@ -251,12 +351,12 @@ nsGeolocatorService::nsGeolocatorService() mTimeout = nsContentUtils::GetIntPref("geo.timeout", 6000); } -nsGeolocatorService::~nsGeolocatorService() +nsGeolocationService::~nsGeolocationService() { } NS_IMETHODIMP -nsGeolocatorService::Observe(nsISupports* aSubject, const char* aTopic, +nsGeolocationService::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData) { if (!strcmp("quit-application", aTopic)) @@ -296,7 +396,7 @@ nsGeolocatorService::Observe(nsISupports* aSubject, const char* aTopic, } NS_IMETHODIMP -nsGeolocatorService::GetPrompt(nsIGeolocationPrompt * *aPrompt) +nsGeolocationService::GetPrompt(nsIGeolocationPrompt * *aPrompt) { NS_ENSURE_ARG_POINTER(aPrompt); *aPrompt = mPrompt; @@ -305,32 +405,32 @@ nsGeolocatorService::GetPrompt(nsIGeolocationPrompt * *aPrompt) } NS_IMETHODIMP -nsGeolocatorService::SetPrompt(nsIGeolocationPrompt * aPrompt) +nsGeolocationService::SetPrompt(nsIGeolocationPrompt * aPrompt) { mPrompt = aPrompt; return NS_OK; } NS_IMETHODIMP -nsGeolocatorService::Update(nsIDOMGeolocation *somewhere) +nsGeolocationService::Update(nsIDOMGeoPosition *somewhere) { for (PRUint32 i = 0; i< mGeolocators.Length(); i++) mGeolocators[i]->Update(somewhere); return NS_OK; } -already_AddRefed -nsGeolocatorService::GetLastKnownPosition() +already_AddRefed +nsGeolocationService::GetLastKnownPosition() { - nsIDOMGeolocation* location = nsnull; + nsIDOMGeoPosition* p = nsnull; if (mProvider) - mProvider->GetCurrentLocation(&location); + mProvider->GetCurrentPosition(&p); - return location; + return p; } PRBool -nsGeolocatorService::IsDeviceReady() +nsGeolocationService::IsDeviceReady() { PRBool ready = PR_FALSE; if (mProvider) @@ -340,7 +440,7 @@ nsGeolocatorService::IsDeviceReady() } nsresult -nsGeolocatorService::StartDevice() +nsGeolocationService::StartDevice() { if (!mProvider) { @@ -362,8 +462,8 @@ nsGeolocatorService::StartDevice() // if we have one, start it up. nsresult rv = mProvider->Startup(); if (NS_FAILED(rv)) - return NS_ERROR_NOT_AVAILABLE;; - + return NS_ERROR_NOT_AVAILABLE; + // lets monitor it for any changes. mProvider->Watch(this); @@ -377,7 +477,7 @@ nsGeolocatorService::StartDevice() } void -nsGeolocatorService::SetDisconnectTimer() +nsGeolocationService::SetDisconnectTimer() { if (!mDisconnectTimer) mDisconnectTimer = do_CreateInstance("@mozilla.org/timer;1"); @@ -390,7 +490,7 @@ nsGeolocatorService::SetDisconnectTimer() } void -nsGeolocatorService::StopDevice() +nsGeolocationService::StopDevice() { if (mProvider) { mProvider->Shutdown(); @@ -403,51 +503,51 @@ nsGeolocatorService::StopDevice() } } -nsGeolocatorService* nsGeolocatorService::gService = nsnull; +nsGeolocationService* nsGeolocationService::gService = nsnull; -nsGeolocatorService* -nsGeolocatorService::GetInstance() +nsGeolocationService* +nsGeolocationService::GetInstance() { - if (!nsGeolocatorService::gService) { - nsGeolocatorService::gService = new nsGeolocatorService(); + if (!nsGeolocationService::gService) { + nsGeolocationService::gService = new nsGeolocationService(); } - return nsGeolocatorService::gService; + return nsGeolocationService::gService; } -nsGeolocatorService* -nsGeolocatorService::GetGeolocationService() +nsGeolocationService* +nsGeolocationService::GetGeolocationService() { - nsGeolocatorService* inst = nsGeolocatorService::GetInstance(); + nsGeolocationService* inst = nsGeolocationService::GetInstance(); NS_ADDREF(inst); return inst; } void -nsGeolocatorService::AddLocator(nsGeolocator* locator) +nsGeolocationService::AddLocator(nsGeolocation* locator) { mGeolocators.AppendElement(locator); } void -nsGeolocatorService::RemoveLocator(nsGeolocator* locator) +nsGeolocationService::RemoveLocator(nsGeolocation* locator) { mGeolocators.RemoveElement(locator); } //////////////////////////////////////////////////// -// nsGeolocator +// nsGeolocation //////////////////////////////////////////////////// -NS_INTERFACE_MAP_BEGIN(nsGeolocator) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeolocator) - NS_INTERFACE_MAP_ENTRY(nsIDOMGeolocator) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Geolocator) +NS_INTERFACE_MAP_BEGIN(nsGeolocation) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMGeoGeolocation) + NS_INTERFACE_MAP_ENTRY(nsIDOMGeoGeolocation) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(GeoGeolocation) NS_INTERFACE_MAP_END -NS_IMPL_ADDREF(nsGeolocator) -NS_IMPL_RELEASE(nsGeolocator) +NS_IMPL_ADDREF(nsGeolocation) +NS_IMPL_RELEASE(nsGeolocation) -nsGeolocator::nsGeolocator(nsIDOMWindow* contentDom) +nsGeolocation::nsGeolocation(nsIDOMWindow* contentDom) : mUpdateInProgress(PR_FALSE) { // Remember the window @@ -462,17 +562,17 @@ nsGeolocator::nsGeolocator(nsIDOMWindow* contentDom) if (doc) doc->NodePrincipal()->GetURI(getter_AddRefs(mURI)); - mService = nsGeolocatorService::GetInstance(); + mService = nsGeolocationService::GetInstance(); if (mService) mService->AddLocator(this); } -nsGeolocator::~nsGeolocator() +nsGeolocation::~nsGeolocation() { } void -nsGeolocator::Shutdown() +nsGeolocation::Shutdown() { // Shutdown and release all callbacks for (PRInt32 i = 0; i< mPendingCallbacks.Count(); i++) @@ -492,13 +592,13 @@ nsGeolocator::Shutdown() } PRBool -nsGeolocator::HasActiveCallbacks() +nsGeolocation::HasActiveCallbacks() { return (PRBool) mWatchingCallbacks.Count(); } void -nsGeolocator::RemoveRequest(nsGeolocationRequest* request) +nsGeolocation::RemoveRequest(nsGeolocationRequest* request) { mPendingCallbacks.RemoveObject(request); @@ -512,7 +612,7 @@ nsGeolocator::RemoveRequest(nsGeolocationRequest* request) } void -nsGeolocator::Update(nsIDOMGeolocation *somewhere) +nsGeolocation::Update(nsIDOMGeoPosition *somewhere) { // This method calls out to objects which may spin and // event loop which may add new location objects into @@ -543,7 +643,7 @@ nsGeolocator::Update(nsIDOMGeolocation *somewhere) } NS_IMETHODIMP -nsGeolocator::GetLastPosition(nsIDOMGeolocation * *aLastPosition) +nsGeolocation::GetLastPosition(nsIDOMGeoPosition * *aLastPosition) { // we are advocating that this method be removed. NS_ENSURE_ARG_POINTER(aLastPosition); @@ -552,13 +652,15 @@ nsGeolocator::GetLastPosition(nsIDOMGeolocation * *aLastPosition) } NS_IMETHODIMP -nsGeolocator::GetCurrentPosition(nsIDOMGeolocationCallback *callback) +nsGeolocation::GetCurrentPosition(nsIDOMGeoPositionCallback *callback, + nsIDOMGeoPositionErrorCallback *errorCallback, + nsIDOMGeoPositionOptions *options) { nsIGeolocationPrompt* prompt = mService->GetPrompt(); if (prompt == nsnull) return NS_ERROR_NOT_AVAILABLE; - nsRefPtr request = new nsGeolocationRequest(this, callback); + nsRefPtr request = new nsGeolocationRequest(this, callback, errorCallback); prompt->Prompt(request); // What if you have a location provider that only sends a location once, then stops.? fix. @@ -567,13 +669,16 @@ nsGeolocator::GetCurrentPosition(nsIDOMGeolocationCallback *callback) } NS_IMETHODIMP -nsGeolocator::WatchPosition(nsIDOMGeolocationCallback *callback, PRUint16 *_retval NS_OUTPARAM) +nsGeolocation::WatchPosition(nsIDOMGeoPositionCallback *callback, + nsIDOMGeoPositionErrorCallback *errorCallback, + nsIDOMGeoPositionOptions *options, + PRUint16 *_retval NS_OUTPARAM) { nsIGeolocationPrompt* prompt = mService->GetPrompt(); if (prompt == nsnull) return NS_ERROR_NOT_AVAILABLE; - nsRefPtr request = new nsGeolocationRequest(this, callback); + nsRefPtr request = new nsGeolocationRequest(this, callback, errorCallback); prompt->Prompt(request); // need to hand back an index/reference. @@ -583,14 +688,14 @@ nsGeolocator::WatchPosition(nsIDOMGeolocationCallback *callback, PRUint16 *_retv } NS_IMETHODIMP -nsGeolocator::ClearWatch(PRUint16 watchId) +nsGeolocation::ClearWatch(PRUint16 watchId) { mWatchingCallbacks[watchId]->MarkCleared(); return NS_OK; } PRBool -nsGeolocator::OwnerStillExists() +nsGeolocation::OwnerStillExists() { if (!mOwner) return PR_FALSE; diff --git a/dom/src/geolocation/nsGeolocation.h b/dom/src/geolocation/nsGeolocation.h index 2c01211898bb..f12334a215ab 100644 --- a/dom/src/geolocation/nsGeolocation.h +++ b/dom/src/geolocation/nsGeolocation.h @@ -43,19 +43,20 @@ #include "nsIObserver.h" #include "nsIURI.h" -#include "nsIDOMGeolocation.h" -#include "nsIDOMGeolocation.h" -#include "nsIDOMGeolocationCallback.h" -#include "nsIDOMGeolocator.h" -#include "nsIDOMNavigatorGeolocator.h" +#include "nsIDOMGeoGeolocation.h" +#include "nsIDOMGeoPosition.h" +#include "nsIDOMGeoPositionError.h" +#include "nsIDOMGeoPositionCallback.h" +#include "nsIDOMGeoPositionErrorCallback.h" +#include "nsIDOMGeoPositionOptions.h" +#include "nsIDOMNavigatorGeolocation.h" #include "nsPIDOMWindow.h" #include "nsIGeolocationProvider.h" -class nsGeolocator; -class nsGeolocatorService; - +class nsGeolocationService; +class nsGeolocation; class nsGeolocationRequest : public nsIGeolocationRequest { @@ -63,10 +64,12 @@ class nsGeolocationRequest : public nsIGeolocationRequest NS_DECL_ISUPPORTS NS_DECL_NSIGEOLOCATIONREQUEST - nsGeolocationRequest(nsGeolocator* locator, nsIDOMGeolocationCallback* callback); + nsGeolocationRequest(nsGeolocation* locator, + nsIDOMGeoPositionCallback* callback, + nsIDOMGeoPositionErrorCallback* errorCallback); void Shutdown(); - void SendLocation(nsIDOMGeolocation* location); + void SendLocation(nsIDOMGeoPosition* location); void MarkCleared(); PRBool Allowed() {return mAllowed;} @@ -77,53 +80,54 @@ class nsGeolocationRequest : public nsIGeolocationRequest PRBool mCleared; PRBool mFuzzLocation; - nsCOMPtr mCallback; + nsCOMPtr mCallback; + nsCOMPtr mErrorCallback; - nsGeolocator* mLocator; // The locator exists alonger than this object. + nsGeolocation* mLocator; // The locator exists alonger than this object. }; /** * Simple object that holds a single point in space. */ -class nsGeolocation : public nsIDOMGeolocation +class nsGeoPosition : public nsIDOMGeoPosition { public: NS_DECL_ISUPPORTS - NS_DECL_NSIDOMGEOLOCATION + NS_DECL_NSIDOMGEOPOSITION - nsGeolocation(double aLat, double aLong, double aAlt, double aHError, double aVError, long long aTimestamp) - : mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mTimestamp(aTimestamp){}; + nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aVelocity, long long aTimestamp) + : mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mVelocity(aVelocity), mTimestamp(aTimestamp){}; private: - ~nsGeolocation(){} - double mLat, mLong, mAlt, mHError, mVError; + ~nsGeoPosition(){} + double mLat, mLong, mAlt, mHError, mVError, mHeading, mVelocity; long long mTimestamp; }; /** * Singleton that manages the geolocation provider */ -class nsGeolocatorService : public nsIGeolocationService, public nsIGeolocationUpdate, public nsIObserver +class nsGeolocationService : public nsIGeolocationService, public nsIGeolocationUpdate, public nsIObserver { public: - static nsGeolocatorService* GetGeolocationService(); - static nsGeolocatorService* GetInstance(); // Non-Addref'ing - static nsGeolocatorService* gService; + static nsGeolocationService* GetGeolocationService(); + static nsGeolocationService* GetInstance(); // Non-Addref'ing + static nsGeolocationService* gService; NS_DECL_ISUPPORTS NS_DECL_NSIGEOLOCATIONUPDATE NS_DECL_NSIOBSERVER NS_DECL_NSIGEOLOCATIONSERVICE - nsGeolocatorService(); + nsGeolocationService(); - // Management of the nsGeolocator objects - void AddLocator(nsGeolocator* locator); - void RemoveLocator(nsGeolocator* locator); + // Management of the nsGeolocation objects + void AddLocator(nsGeolocation* locator); + void RemoveLocator(nsGeolocation* locator); // Returns the last geolocation we have seen since calling StartDevice() - already_AddRefed GetLastKnownPosition(); + already_AddRefed GetLastKnownPosition(); // Returns the application defined UI prompt nsIGeolocationPrompt* GetPrompt() { return mPrompt; } // does not addref. @@ -143,7 +147,7 @@ public: private: - ~nsGeolocatorService(); + ~nsGeolocationService(); // Disconnect timer. When this timer expires, it clears all pending callbacks // and closes down the provider, unless we are watching a point, and in that @@ -159,7 +163,7 @@ private: // mGeolocators are not owned here. Their constructor // addes them to this list, and their destructor removes // them from this list. - nsTArray mGeolocators; + nsTArray mGeolocators; // prompt callback, if any nsCOMPtr mPrompt; @@ -169,17 +173,17 @@ private: /** * Can return a geolocation info */ -class nsGeolocator : public nsIDOMGeolocator +class nsGeolocation : public nsIDOMGeoGeolocation { public: NS_DECL_ISUPPORTS - NS_DECL_NSIDOMGEOLOCATOR + NS_DECL_NSIDOMGEOGEOLOCATION - nsGeolocator(nsIDOMWindow* contentDom); + nsGeolocation(nsIDOMWindow* contentDom); // Called by the geolocation device to notify that a location has changed. - void Update(nsIDOMGeolocation* aLocation); + void Update(nsIDOMGeoPosition* aPosition); // Returns true if any of the callbacks are repeating PRBool HasActiveCallbacks(); @@ -190,10 +194,10 @@ public: // Shutting down. void Shutdown(); - // Setter and Getter of the URI that this nsGeolocator was loaded from + // Setter and Getter of the URI that this nsGeolocation was loaded from nsIURI* GetURI() { return mURI; } - // Setter and Getter of the window that this nsGeolocator is owned by + // Setter and Getter of the window that this nsGeolocation is owned by nsIDOMWindow* GetOwner() { return mOwner; } // Check to see if the widnow still exists @@ -201,7 +205,7 @@ public: private: - ~nsGeolocator(); + ~nsGeolocation(); // Two callback arrays. The first |mPendingCallbacks| holds objects for only // one callback and then they are released/removed from the array. The second @@ -220,5 +224,5 @@ private: nsCOMPtr mURI; // owning back pointer. - nsRefPtr mService; + nsRefPtr mService; }; diff --git a/dom/tests/mochitest/geolocation/Makefile.in b/dom/tests/mochitest/geolocation/Makefile.in index 3694bef6f14a..41ec24fefffd 100644 --- a/dom/tests/mochitest/geolocation/Makefile.in +++ b/dom/tests/mochitest/geolocation/Makefile.in @@ -49,7 +49,7 @@ _TEST_FILES = \ test_manyWindows.html \ prompt_common.js \ geolocation_common.js \ - geolocator.html \ + geolocation.html \ $(NULL) diff --git a/dom/tests/mochitest/geolocation/geolocation.html b/dom/tests/mochitest/geolocation/geolocation.html new file mode 100644 index 000000000000..e5daf9802832 --- /dev/null +++ b/dom/tests/mochitest/geolocation/geolocation.html @@ -0,0 +1,12 @@ + +Simple access of geolocation + + + +

+ + diff --git a/dom/tests/mochitest/geolocation/geolocation_common.js b/dom/tests/mochitest/geolocation/geolocation_common.js index c57dd5813317..cb254cb9624f 100644 --- a/dom/tests/mochitest/geolocation/geolocation_common.js +++ b/dom/tests/mochitest/geolocation/geolocation_common.js @@ -5,8 +5,12 @@ function check_geolocation(location) { ok(location.latitude, "Check to see if there is a latitude"); ok(location.longitude, "Check to see if there is a longitude"); ok(location.altitude, "Check to see if there is a altitude"); - ok(location.horizontalAccuracy, "Check to see if there is a horizontalAccuracy"); - ok(location.verticalAccuracy, "Check to see if there is a verticalAccuracy"); + ok(location.accuracy, "Check to see if there is a accuracy"); + ok(location.altitudeAccuracy, "Check to see if there is a alt accuracy"); + + ok(location.heading, "Check to see if there is a heading"); + ok(location.velocity, "Check to see if there is a velocity"); + ok(location.timestamp, "Check to see if there is a timestamp"); } diff --git a/dom/tests/mochitest/geolocation/geolocator.html b/dom/tests/mochitest/geolocation/geolocator.html deleted file mode 100644 index 5c2bb2ef7118..000000000000 --- a/dom/tests/mochitest/geolocation/geolocator.html +++ /dev/null @@ -1,12 +0,0 @@ - -Simple access of geolocator - - - -

- - diff --git a/dom/tests/mochitest/geolocation/test_lastPosition.html b/dom/tests/mochitest/geolocation/test_lastPosition.html index ada99200b7ab..86cbc069c87e 100644 --- a/dom/tests/mochitest/geolocation/test_lastPosition.html +++ b/dom/tests/mochitest/geolocation/test_lastPosition.html @@ -43,7 +43,7 @@ function handleDialog(doc) { -ok(navigator.geolocator, "Ensure that the geolocation object is present"); +ok(navigator.geolocation, "Ensure that the geolocation object is present"); //first we want to prevent this proprerty from loading. /* @@ -54,7 +54,7 @@ dialog in FF. startCallbackTimer(); */ -last = navigator.geolocator.lastPosition; +last = navigator.geolocation.lastPosition; ok(last == null, "Check to ensure the lastPosition is null"); @@ -67,7 +67,7 @@ allow_dialog = 1; startCallbackTimer(); */ -last = navigator.geolocator.lastPosition; +last = navigator.geolocation.lastPosition; if (last != null) { check_geolocation(last); diff --git a/dom/tests/mochitest/geolocation/test_manyWindows.html b/dom/tests/mochitest/geolocation/test_manyWindows.html index 778ca608990d..5aa34fcf0c75 100644 --- a/dom/tests/mochitest/geolocation/test_manyWindows.html +++ b/dom/tests/mochitest/geolocation/test_manyWindows.html @@ -24,7 +24,7 @@ href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Crash in Multiple Windows