From 714e9c9074d9eb2f4063962d07bae6b4f02a1e7a Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Sat, 13 Apr 2019 10:53:58 -0400 Subject: Issue #991 Part 7: Toolkit Components --- .../components/search/orginal/nsSearchService.js | 38 ++++++---------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'toolkit/components/search/orginal/nsSearchService.js') diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js index 5b5ce7a57..c4481df5f 100644 --- a/toolkit/components/search/orginal/nsSearchService.js +++ b/toolkit/components/search/orginal/nsSearchService.js @@ -418,12 +418,7 @@ function isPartnerBuild() { // Method to determine if we should be using geo-specific defaults function geoSpecificDefaultsEnabled() { - let geoSpecificDefaults = false; - try { - geoSpecificDefaults = Services.prefs.getBoolPref("browser.search.geoSpecificDefaults"); - } catch(e) {} - - return geoSpecificDefaults; + return Services.prefs.getBoolPref("browser.search.geoSpecificDefaults", false); } // Some notes on countryCode and region prefs: @@ -528,11 +523,7 @@ function isUSTimezone() { // If it fails we don't touch that pref so isUS() does its normal thing. var ensureKnownCountryCode = Task.async(function* () { // If we have a country-code already stored in our prefs we trust it. - let countryCode; - try { - countryCode = Services.prefs.getCharPref("browser.search.countryCode"); - } catch(e) {} - + let countryCode = Services.prefs.getCharPref("browser.search.countryCode", ""); if (!countryCode) { // We don't have it cached, so fetch it. fetchCountryCode() will call // storeCountryCode if it gets a result (even if that happens after the @@ -732,10 +723,7 @@ var fetchRegionDefault = () => new Promise(resolve => { // Append the optional cohort value. const cohortPref = "browser.search.cohort"; - let cohort; - try { - cohort = Services.prefs.getCharPref(cohortPref); - } catch(e) {} + let cohort = Services.prefs.getCharPref(cohortPref, ""); if (cohort) endpoint += "/" + cohort; @@ -1034,19 +1022,13 @@ function QueryParameter(aName, aValue, aPurpose) { function ParamSubstitution(aParamValue, aSearchTerms, aEngine) { var value = aParamValue; - var distributionID = MOZ_DISTRIBUTION_ID; - try { - distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID"); - } - catch (ex) { } - var official = MOZ_OFFICIAL; - try { - if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official")) - official = "official"; - else - official = "unofficial"; - } - catch (ex) { } + var distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID", + MOZ_DISTRIBUTION_ID || ""); + var official; + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official", MOZ_OFFICIAL)) + official = "official"; + else + official = "unofficial"; // Custom search parameters. These are only available to default search // engines. -- cgit v1.2.3 From 40fc72376411587e7bf9985fb9545eca1c9aaa8e Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Sat, 13 Apr 2019 17:27:59 -0400 Subject: Pref try/catch block fixup. Tag #991. --- toolkit/components/search/orginal/nsSearchService.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'toolkit/components/search/orginal/nsSearchService.js') diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js index c4481df5f..1cec5f966 100644 --- a/toolkit/components/search/orginal/nsSearchService.js +++ b/toolkit/components/search/orginal/nsSearchService.js @@ -1024,11 +1024,14 @@ function ParamSubstitution(aParamValue, aSearchTerms, aEngine) { var distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID", MOZ_DISTRIBUTION_ID || ""); - var official; - if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official", MOZ_OFFICIAL)) - official = "official"; - else - official = "unofficial"; + var official = MOZ_OFFICIAL; + try { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official")) + official = "official"; + else + official = "unofficial"; + } + catch (ex) { } // Custom search parameters. These are only available to default search // engines. -- cgit v1.2.3