Bug 999851 - remove topN support from search service, r=gavin
authorMike Connor <mconnor@mozilla.com>
Thu, 24 Apr 2014 16:24:36 -0400
changeset 181196 06449d964ed32177fa5473a5704d8615ab5f03c3
parent 181195 1fdff43f8f8c414f461b364efdb1d645bb25c546
child 181197 070ba75ffd6081708f8ba755e0f37fc9b88028bd
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersgavin
bugs999851
milestone32.0a1
Bug 999851 - remove topN support from search service, r=gavin
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -917,43 +917,17 @@ EngineURL.prototype = {
 
   // Note: This method requires that aObj has a unique name or the previous MozParams entry with
   // that name will be overwritten.
   _addMozParam: function SRCH_EURL__addMozParam(aObj) {
     aObj.mozparam = true;
     this.mozparams[aObj.name] = aObj;
   },
 
-  reevalMozParams: function(engine) {
-    for (let param of this.params) {
-      let mozparam = this.mozparams[param.name];
-      if (mozparam && mozparam.positionDependent) {
-        // the condition is a string in the form of "topN", extract N as int
-        let positionStr = mozparam.condition.slice("top".length);
-        let position = parseInt(positionStr, 10);
-        let engines;
-        try {
-          // This will throw if we're not initialized yet (which shouldn't happen), just 
-          // ignore and move on with the false Value (checking isInitialized also throws)
-          // XXX
-          engines = Services.search.getVisibleEngines({});
-        } catch (ex) {
-          LOG("reevalMozParams called before search service initialization!?");
-          break;
-        }
-        let index = engines.map((e) => e.wrappedJSObject).indexOf(engine.wrappedJSObject);
-        let isTopN = index > -1 && (index + 1) <= position;
-        param.value = isTopN ? mozparam.trueValue : mozparam.falseValue;
-      }
-    }
-  },
-
   getSubmission: function SRCH_EURL_getSubmission(aSearchTerms, aEngine, aPurpose) {
-    this.reevalMozParams(aEngine);
-
     var url = ParamSubstitution(this.template, aSearchTerms, aEngine);
     // Default to an empty string if the purpose is not provided so that default purpose params
     // (purpose="") work consistently rather than having to define "null" and "" purposes.
     var purpose = aPurpose || "";
 
     // Create an application/x-www-form-urlencoded representation of our params
     // (name=value&name=value&name=value)
     var dataString = "";
@@ -1845,25 +1819,19 @@ Engine.prototype = {
               value = getMozParamPref(param.getAttribute("pref"), value);
               url.addParam(param.getAttribute("name"), value);
               url._addMozParam({"pref": param.getAttribute("pref"),
                                 "name": param.getAttribute("name"),
                                 "condition": "pref"});
             } catch (e) { }
             break;
           default:
-            if (condition && condition.startsWith("top")) {
-              url.addParam(param.getAttribute("name"), param.getAttribute("falseValue"));
-              let mozparam = {"name": param.getAttribute("name"),
-                              "falseValue": param.getAttribute("falseValue"),
-                              "trueValue": param.getAttribute("trueValue"),
-                              "condition": condition,
-                              "positionDependent": true};
-              url._addMozParam(mozparam);
-            }
+            let engineLoc = this._location;
+            let paramName = param.getAttribute("name");
+            LOG("_parseURL: MozParam (" + paramName + ") has an unknown condition: " + condition + ". Found parsing engine: " + engineLoc);
           break;
         }
       }
     }
 
     this._urls.push(url);
   },