Bug 1532761 - Add regionOverrides engine to jarNames. r=daleharvey a=lizzard
authorMichael Kaply <mozilla@kaply.com>
Wed, 13 Mar 2019 16:22:05 +0100
changeset 516368 2c906ef692e7556a04a924a302bf7a7fb464b0f0
parent 516367 586f46c17c458f3e95f65806eedf44e024f0c245
child 516369 791061efa6367a23945f207aa16a663e9c982faa
push id1963
push userarchaeopteryx@coole-files.de
push dateWed, 13 Mar 2019 15:32:59 +0000
treeherdermozilla-release@791061efa636 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaleharvey, lizzard
bugs1532761
milestone66.0
Bug 1532761 - Add regionOverrides engine to jarNames. r=daleharvey a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D22182
toolkit/components/search/nsSearchService.js
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -3506,16 +3506,18 @@ SearchService.prototype = {
     try {
       json = JSON.parse(list);
     } catch (e) {
       Cu.reportError("parseListJSON: Failed to parse list.json: " + e);
       dump("parseListJSON: Failed to parse list.json: " + e + "\n");
       return;
     }
 
+    let searchRegion = Services.prefs.getCharPref("browser.search.region", null);
+
     let searchSettings;
     let locale = Services.locale.appLocaleAsBCP47;
     if ("locales" in json &&
         locale in json.locales) {
       searchSettings = json.locales[locale];
     } else {
       // No locales were found, so use the JSON as is.
       // It should have a default section.
@@ -3538,16 +3540,22 @@ SearchService.prototype = {
         // Artifact builds use the full list.json which parses
         // slightly differently
         if (!("visibleDefaultEngines" in searchSettings[region])) {
           continue;
         }
         for (let engine of searchSettings[region].visibleDefaultEngines) {
           jarNames.add(engine);
         }
+        if ("regionOverrides" in json &&
+            searchRegion in json.regionOverrides) {
+          for (let engine in json.regionOverrides[searchRegion]) {
+            jarNames.add(json.regionOverrides[searchRegion][engine]);
+          }
+        }
       }
 
       engineNames = visibleDefaultEngines.split(",");
       // absearch can't be modified to use the new engine names.
       // Convert them here.
       engineNames = convertGoogleEngines(engineNames);
 
       for (let engineName of engineNames) {
@@ -3561,21 +3569,16 @@ SearchService.prototype = {
           LOG("_parseListJSON: ignoring visibleDefaultEngines value because " +
               engineName + " is not in the jar engines we have found");
           engineNames = null;
           break;
         }
       }
     }
 
-    let searchRegion;
-    if (Services.prefs.prefHasUserValue("browser.search.region")) {
-      searchRegion = Services.prefs.getCharPref("browser.search.region");
-    }
-
     // Fallback to building a list based on the regions in the JSON
     if (!engineNames || !engineNames.length) {
       if (searchRegion && searchRegion in searchSettings &&
           "visibleDefaultEngines" in searchSettings[searchRegion]) {
         engineNames = searchSettings[searchRegion].visibleDefaultEngines;
       } else {
         engineNames = searchSettings.default.visibleDefaultEngines;
       }