Bug 883071 - Don't send opted-out SSIDs when querying Google Location Service. r=dougt
authorChris Peterson <cpeterson@mozilla.com>
Thu, 13 Jun 2013 20:20:15 -0700
changeset 146992 1d2a43c84bd322d46130a52fda221c3308c50cad
parent 146991 43516c3e17fbfb985eb4683961ca0b9da806ad0b
child 146993 a45f1dcd603c37577185dc875abee26ba12a1e25
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs883071
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 883071 - Don't send opted-out SSIDs when querying Google Location Service. r=dougt
dom/system/NetworkGeolocationProvider.js
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -208,29 +208,37 @@ WifiGeoPositionProvider.prototype = {
       providerUrl = providerUrlBase + "&";
     providerUrl = providerUrl + "browser=firefox&sensor=true";
     
 
     let accessToken = this.getAccessTokenForURL(providerUrlBase);
     if (accessToken !== "")
       providerUrl = providerUrl + "&access_token="+accessToken;
 
-    function sort(a, b) {
+    function bySignal(a, b) {
       return b.signal - a.signal;
     };
 
+    function noOptOut(ap) {
+      let optOut = (ap.ssid === "" || ap.ssid.endsWith("_nomap"));
+      return !optOut;
+    };
+
     function encode(ap) {
       // make sure that the ssid doesn't contain any | chars.
       ap.ssid = ap.ssid.replace("|", "\\|");
       // gls service parses the | as fields
       return "&wifi=mac:"+ap.mac+"|ssid:"+ap.ssid+"|ss:"+ap.signal;
     };
 
     if (accessPoints) {
-        providerUrl = providerUrl + accessPoints.sort(sort).map(encode).join("");
+        providerUrl += accessPoints.filter(noOptOut)
+                                   .sort(bySignal)
+                                   .map(encode)
+                                   .join("");
     }
 
     providerUrl = encodeURI(providerUrl);
 
     // max length is 2k.  make sure we are under that
     let x = providerUrl.length - 2000;
     if (x >= 0) {
 	// we need to trim