summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-04-20 11:17:30 +0200
committerGitHub <noreply@github.com>2019-04-20 11:17:30 +0200
commite0116ac2b78eb4e621a4d0769e01f8358a6d661c (patch)
treefe2898874f0be34a8425281ecba2cb8cb59fb210 /toolkit/components/places
parent32577bdb3d2471c0e5ce4cfd0501a820157230cb (diff)
parent21b4cb27cabecdb5580c01891801c9259689ec87 (diff)
downloadUXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.gz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.lz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.xz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.zip
Merge pull request #1041 from Ascrod/default-pref
Clean up try/catch blocks for preferences
Diffstat (limited to 'toolkit/components/places')
-rw-r--r--toolkit/components/places/PlacesCategoriesStarter.js7
-rw-r--r--toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm6
-rw-r--r--toolkit/components/places/UnifiedComplete.js5
-rw-r--r--toolkit/components/places/nsPlacesExpiration.js14
-rw-r--r--toolkit/components/places/tests/unit/test_000_frecency.js10
5 files changed, 10 insertions, 32 deletions
diff --git a/toolkit/components/places/PlacesCategoriesStarter.js b/toolkit/components/places/PlacesCategoriesStarter.js
index 560bd486a..bab14db52 100644
--- a/toolkit/components/places/PlacesCategoriesStarter.js
+++ b/toolkit/components/places/PlacesCategoriesStarter.js
@@ -77,11 +77,8 @@ PlacesCategoriesStarter.prototype = {
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.
- let lastMaintenance = 0;
- try {
- lastMaintenance =
- Services.prefs.getIntPref("places.database.lastMaintenance");
- } catch (ex) {}
+ let lastMaintenance =
+ Services.prefs.getIntPref("places.database.lastMaintenance", 0);
let nowSeconds = parseInt(Date.now() / 1000);
if (lastMaintenance < nowSeconds - MAINTENANCE_INTERVAL_SECONDS) {
PlacesDBUtils.maintenanceOnIdle();
diff --git a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
index d23d5bc6e..c3bc501eb 100644
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -95,11 +95,7 @@ function observe(subject, topic, data) {
case "nsPref:changed":
if (data == PREF_SHOW_REMOTE_ICONS) {
- try {
- showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS);
- } catch (_) {
- showRemoteIcons = true; // no such pref - default is to show the icons.
- }
+ showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS, true);
}
break;
diff --git a/toolkit/components/places/UnifiedComplete.js b/toolkit/components/places/UnifiedComplete.js
index ec5f91111..7b63e29bb 100644
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -437,10 +437,7 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
store.maxCharsForSearchSuggestions = prefs.get(...PREF_MAX_CHARS_FOR_SUGGEST);
- store.keywordEnabled = true;
- try {
- store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled");
- } catch (ex) {}
+ store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled", true);
// If history is not set, onlyTyped value should be ignored.
if (!store.suggestHistory) {
diff --git a/toolkit/components/places/nsPlacesExpiration.js b/toolkit/components/places/nsPlacesExpiration.js
index 499934362..767a4d345 100644
--- a/toolkit/components/places/nsPlacesExpiration.js
+++ b/toolkit/components/places/nsPlacesExpiration.js
@@ -812,11 +812,8 @@ nsPlacesExpiration.prototype = {
_loadPrefs: Task.async(function* () {
// Get the user's limit, if it was set.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS);
- } catch (ex) { /* User limit not set */ }
+ this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS,
+ PREF_MAX_URIS_NOTSET);
if (this._urisLimit < 0) {
// Some testing code expects a pref change to be synchronous, so
@@ -874,11 +871,8 @@ nsPlacesExpiration.prototype = {
this._urisLimit);
// Get the expiration interval value.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS);
- } catch (ex) { /* User interval not set */ }
+ this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS,
+ PREF_INTERVAL_SECONDS_NOTSET);
if (this._interval <= 0) {
this._interval = PREF_INTERVAL_SECONDS_NOTSET;
}
diff --git a/toolkit/components/places/tests/unit/test_000_frecency.js b/toolkit/components/places/tests/unit/test_000_frecency.js
index 0a7347a02..64ee86b59 100644
--- a/toolkit/components/places/tests/unit/test_000_frecency.js
+++ b/toolkit/components/places/tests/unit/test_000_frecency.js
@@ -56,14 +56,8 @@ var prefPrefix = "places.frecency.";
function* task_initializeBucket(bucket) {
let [cutoffName, weightName] = bucket;
// get pref values
- var weight = 0, cutoff = 0;
- try {
- weight = prefs.getIntPref(prefPrefix + weightName);
- } catch (ex) {}
- try {
- cutoff = prefs.getIntPref(prefPrefix + cutoffName);
- } catch (ex) {}
-
+ var weight = prefs.getIntPref(prefPrefix + weightName, 0);
+ var cutoff = prefs.getIntPref(prefPrefix + cutoffName, 0);
if (cutoff < 1)
return;