Bug 463312 - Remove geolocation fuzzing implementation. r/sr=jst r=mconnor
authorDoug Turner <dougt@meer.net>
Wed, 12 Nov 2008 08:04:18 -0800
changeset 21625 8a26a5d1a9bda2cf3f1728d02dea5547ed175665
parent 21624 1fe78d659cbe4f3f411f5c49e2393199d4064a1b
child 21626 4500efb0e922717a62bbddcb5f4d13055a2ce962
push id3624
push userdougt@mozilla.com
push dateThu, 13 Nov 2008 19:59:44 +0000
treeherdermozilla-central@a1364547a182 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconnor
bugs463312
milestone1.9.1b2pre
Bug 463312 - Remove geolocation fuzzing implementation. r/sr=jst r=mconnor
browser/components/nsBrowserGlue.js
browser/locales/en-US/chrome/browser/browser.properties
dom/public/idl/geolocation/nsIGeolocationProvider.idl
dom/src/geolocation/MaemoLocationProvider.cpp
dom/src/geolocation/nsGeolocation.cpp
dom/src/geolocation/nsGeolocation.h
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -918,21 +918,16 @@ GeolocationPrompt.prototype = {
       var browserBundle = bundleService.createBundle("chrome://browser/locale/browser.properties");
 
       var buttons = [{
         label: browserBundle.GetStringFromName("geolocation.exactLocation"),
         accessKey: browserBundle.GetStringFromName("geolocation.exactLocationKey"),
         callback: function() request.allow() ,
         },
         {
-        label: browserBundle.GetStringFromName("geolocation.neighborhoodLocation"),
-        accessKey: browserBundle.GetStringFromName("geolocation.neighborhoodLocationKey"),
-        callback: function() request.allowButFuzz() ,
-        },
-        {
         label: browserBundle.GetStringFromName("geolocation.nothingLocation"),
         accessKey: browserBundle.GetStringFromName("geolocation.nothingLocationKey"),
         callback: function() request.cancel() ,
         }];
       
       var message = browserBundle.formatStringFromName("geolocation.requestMessage",
                                                        [request.requestingURI.spec], 1);      
       notificationBox.appendNotification(message,
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -138,18 +138,16 @@ editBookmarkPanel.editBookmarkTitle=Edit
 # Geolocation UI
 # LOCALIZATION NOTE (exactLocation, neighborhoodLocation): These do not have to be
 # exact value, instead approximations would be fine.
 # examples: Neighborhood (within 2 km)
 #           Exact Location (within 3 m)
 #
 geolocation.exactLocation=Exact Location (within 10 feet)
 geolocation.exactLocationKey=E
-geolocation.neighborhoodLocation=Neighborhood (within 1 mile)
-geolocation.neighborhoodLocationKey=N
 geolocation.nothingLocation=Nothing
 geolocation.nothingLocationKey=o
 geolocation.requestMessage=%S wants to know where you are.  Tell them:
 
 # Phishing/Malware Notification Bar.
 # LOCALIZATION NOTE (notAForgery, notAnAttack)
 # The two button strings will never be shown at the same time, so
 # it's okay for them to have the same access key
--- a/dom/public/idl/geolocation/nsIGeolocationProvider.idl
+++ b/dom/public/idl/geolocation/nsIGeolocationProvider.idl
@@ -43,25 +43,24 @@ interface nsIDOMWindow;
 interface nsIDOMGeoPosition;
 interface nsIGeolocationPrompt;
 
 /**
  * Interface allows access to a geolocation and is passed to
  * the nsIGeolocationPrompt so that the application can approve
  * or deny the request.
  */
-[scriptable, function, uuid(D681C322-C075-4C6E-9765-C22711A4A60E)]
+[scriptable, function, uuid(F2AEFDE1-8E38-48B3-BBB8-BD6C4AE1AC8A)]
 interface nsIGeolocationRequest : nsISupports {
 
   readonly attribute nsIURI requestingURI;
   readonly attribute nsIDOMWindow requestingWindow;
 
   void cancel();
   void allow();
-  void allowButFuzz();
 };
 
 /**
  * Interface provides a way for the application to handle
  * the UI prompts associated with geo position.
  */
 [scriptable, function, uuid(2300C895-1BEE-4297-912C-A57082F3E936)]
 interface nsIGeolocationPrompt : nsISupports {
--- a/dom/src/geolocation/MaemoLocationProvider.cpp
+++ b/dom/src/geolocation/MaemoLocationProvider.cpp
@@ -34,16 +34,105 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 
 
 #include "MaemoLocationProvider.h"
 #include "nsGeolocation.h"
 
+
+////////////////////////////////////////////////////
+// nsGeoPosition
+////////////////////////////////////////////////////
+
+/**
+ * Simple object that holds a single point in space.
+ */ 
+class nsGeoPosition : public nsIDOMGeoPosition
+{
+public:
+  NS_DECL_ISUPPORTS
+  NS_DECL_NSIDOMGEOPOSITION
+
+    nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed, long long aTimestamp)
+    : mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mSpeed(aSpeed), mTimestamp(aTimestamp){};
+
+private:
+  ~nsGeoPosition(){}
+  double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
+  long long mTimestamp;
+};
+
+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(nsGeoPosition)
+NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition)
+
+NS_IMETHODIMP
+nsGeoPosition::GetLatitude(double *aLatitude)
+{
+  *aLatitude = mLat;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetLongitude(double *aLongitude)
+{
+  *aLongitude = mLong;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetAltitude(double *aAltitude)
+{
+  *aAltitude = mAlt;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetAccuracy(double *aAccuracy)
+{
+  *aAccuracy = mHError;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy)
+{
+  *aAltitudeAccuracy = mVError;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetHeading(double *aHeading)
+{
+  *aHeading = mHeading;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetSpeed(double *aSpeed)
+{
+  *aSpeed = mSpeed;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
+{
+  *aTimestamp = mTimestamp;
+  return NS_OK;
+}
+
+
 NS_IMPL_ISUPPORTS1(MaemoLocationProvider, nsIGeolocationProvider)
 
 MaemoLocationProvider::MaemoLocationProvider()
 : mGPSDevice(nsnull), mLocationCallbackHandle(0), mHasSeenLocation(PR_FALSE)
 {
 }
 
 MaemoLocationProvider::~MaemoLocationProvider()
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -134,17 +134,16 @@ nsDOMGeoPositionError::NotifyCallback(ns
 ////////////////////////////////////////////////////
 
 nsGeolocationRequest::nsGeolocationRequest(nsGeolocation* aLocator,
                                            nsIDOMGeoPositionCallback* aCallback,
                                            nsIDOMGeoPositionErrorCallback* aErrorCallback,
                                            nsIDOMGeoPositionOptions* aOptions)
   : mAllowed(PR_FALSE),
     mCleared(PR_FALSE),
-    mFuzzLocation(PR_FALSE),
     mHasSentData(PR_FALSE),
     mCallback(aCallback),
     mErrorCallback(aErrorCallback),
     mOptions(aOptions),
     mLocator(aLocator)
 {
 }
 
@@ -252,23 +251,16 @@ nsGeolocationRequest::Allow()
       mTimeoutTimer = do_CreateInstance("@mozilla.org/timer;1");
       mTimeoutTimer->InitWithCallback(this, timeout, nsITimer::TYPE_ONE_SHOT);
   }
 
   mAllowed = PR_TRUE;
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsGeolocationRequest::AllowButFuzz()
-{
-  mFuzzLocation = PR_TRUE;
-  return Allow();
-}
-
 void
 nsGeolocationRequest::MarkCleared()
 {
   mCleared = PR_TRUE;
 }
 
 void
 nsGeolocationRequest::SendLocation(nsIDOMGeoPosition* aPosition)
@@ -276,60 +268,17 @@ nsGeolocationRequest::SendLocation(nsIDO
   if (mCleared || !mAllowed)
     return;
 
   // Ensure that the proper context is on the stack (bug 452762)
   nsCOMPtr<nsIJSContextStack> stack(do_GetService("@mozilla.org/js/xpc/ContextStack;1"));
   if (!stack || NS_FAILED(stack->Push(nsnull)))
     return; // silently fail
   
-  //TODO mFuzzLocation.  Needs to be defined what we do here.
-  if (mFuzzLocation)
-  {
-    // need to make a copy because nsIDOMGeoPosition is
-    // readonly, and we are not sure of its implementation.
-
-    double lat, lon, alt, herror, verror, heading, speed;
-    DOMTimeStamp time;
-    aPosition->GetLatitude(&lat);
-    aPosition->GetLongitude(&lon);
-    aPosition->GetAltitude(&alt);
-    aPosition->GetAccuracy(&herror);
-    aPosition->GetAltitudeAccuracy(&verror);
-    aPosition->GetHeading(&heading);
-    aPosition->GetSpeed(&speed);
-    aPosition->GetTimestamp(&time); 
-
-    // Truncate ?
-    // lat = floor(lat*10+.5)/10;
-    // lon = floor(lon*10+.5)/10;
-    // herror = 1600; /* about 1 mile */
-
-    lat = 0;
-    lon = 0;
-    herror = 0;
-    heading = 0; 
-    speed = 0;
-    alt = 0;
-    verror = 0;
-
-    nsRefPtr<nsGeoPosition> somewhere = new nsGeoPosition(lat,
-                                                          lon,
-                                                          alt,
-                                                          herror,
-                                                          verror,
-                                                          heading,
-                                                          speed,
-                                                          time);
-    mCallback->HandleEvent(somewhere);
-  }
-  else
-  {
-    mCallback->HandleEvent(aPosition);
-  }
+  mCallback->HandleEvent(aPosition);
 
   // remove the stack
   JSContext* cx;
   stack->Pop(&cx);
 
   mHasSentData = PR_TRUE;
 }
 
@@ -337,84 +286,16 @@ void
 nsGeolocationRequest::Shutdown()
 {
   mCleared = PR_TRUE;
   mCallback = nsnull;
   mErrorCallback = nsnull;
 }
 
 ////////////////////////////////////////////////////
-// nsGeoPosition
-////////////////////////////////////////////////////
-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(nsGeoPosition)
-NS_IMPL_THREADSAFE_RELEASE(nsGeoPosition)
-
-NS_IMETHODIMP
-nsGeoPosition::GetLatitude(double *aLatitude)
-{
-  *aLatitude = mLat;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetLongitude(double *aLongitude)
-{
-  *aLongitude = mLong;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetAltitude(double *aAltitude)
-{
-  *aAltitude = mAlt;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetAccuracy(double *aAccuracy)
-{
-  *aAccuracy = mHError;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetAltitudeAccuracy(double *aAltitudeAccuracy)
-{
-  *aAltitudeAccuracy = mVError;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetHeading(double *aHeading)
-{
-  *aHeading = mHeading;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetSpeed(double *aSpeed)
-{
-  *aSpeed = mSpeed;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsGeoPosition::GetTimestamp(DOMTimeStamp* aTimestamp)
-{
-  *aTimestamp = mTimestamp;
-  return NS_OK;
-}
-
-////////////////////////////////////////////////////
 // nsGeolocationService
 ////////////////////////////////////////////////////
 NS_INTERFACE_MAP_BEGIN(nsGeolocationService)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIGeolocationUpdate)
   NS_INTERFACE_MAP_ENTRY(nsIGeolocationUpdate)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END
 
--- a/dom/src/geolocation/nsGeolocation.h
+++ b/dom/src/geolocation/nsGeolocation.h
@@ -83,46 +83,27 @@ class nsGeolocationRequest : public nsIG
 
   ~nsGeolocationRequest();
 
  private:
 
   void NotifyError(PRInt16 errorCode);
   PRPackedBool mAllowed;
   PRPackedBool mCleared;
-  PRPackedBool mFuzzLocation;
   PRPackedBool mHasSentData;
 
   nsCOMPtr<nsITimer> mTimeoutTimer;
   nsCOMPtr<nsIDOMGeoPositionCallback> mCallback;
   nsCOMPtr<nsIDOMGeoPositionErrorCallback> mErrorCallback;
   nsCOMPtr<nsIDOMGeoPositionOptions> mOptions;
 
   nsGeolocation* mLocator; // The locator exists longer than this object.
 };
 
 /**
- * Simple object that holds a single point in space.
- */ 
-class nsGeoPosition : public nsIDOMGeoPosition
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMGEOPOSITION
-
-    nsGeoPosition(double aLat, double aLong, double aAlt, double aHError, double aVError, double aHeading, double aSpeed, long long aTimestamp)
-    : mLat(aLat), mLong(aLong), mAlt(aAlt), mHError(aHError), mVError(aVError), mHeading(aHeading), mSpeed(aSpeed), mTimestamp(aTimestamp){};
-
-private:
-  ~nsGeoPosition(){}
-  double mLat, mLong, mAlt, mHError, mVError, mHeading, mSpeed;
-  long long mTimestamp;
-};
-
-/**
  * Singleton that manages the geolocation provider
  */
 class nsGeolocationService : public nsIGeolocationUpdate, public nsIObserver
 {
 public:
 
   static nsGeolocationService* GetGeolocationService();
   static nsGeolocationService* GetInstance();  // Non-Addref'ing