Bug 1629430 - Make use of optional defaultvalue in get*Pref in feeds. r=frg DONTBUILD
authorIan Neal <iann_cvs@blueyonder.co.uk>
Sat, 11 Apr 2020 16:57:42 +0100
changeset 38980 92fecd6fc1c250ec6814be216785d18229878f88
parent 38979 61ae2dafd0a56785753f57cdebe4cd7bf77feeda
child 38981 362312fa34e819f73940c1ffa706bab813838d38
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersfrg
bugs1629430
Bug 1629430 - Make use of optional defaultvalue in get*Pref in feeds. r=frg DONTBUILD
suite/components/feeds/FeedConverter.js
suite/components/feeds/FeedWriter.js
--- a/suite/components/feeds/FeedConverter.js
+++ b/suite/components/feeds/FeedConverter.js
@@ -76,31 +76,18 @@ function getPrefReaderForType(t) {
       return PREF_AUDIO_SELECTED_READER;
 
     default:
       return PREF_SELECTED_READER;
   }
 }
 
 function LOG(str) {
-  try {
-    if (Services.prefs.getBoolPref("feeds.log"))
-      dump("*** Feeds: " + str + "\n");
-  }
-  catch (ex) {
-  }
-}
-
-function safeGetCharPref(pref, defaultValue) {
-  try {
-    return Services.prefs.getCharPref(pref);
-  }
-  catch (e) {
-  }
-  return defaultValue;
+  if (Services.prefs.getBoolPref("feeds.log", false))
+    dump("*** Feeds: " + str + "\n");
 }
 
 function FeedConverter() {
 }
 
 FeedConverter.prototype = {
   /**
    * This is the downloaded text data for the feed.
@@ -192,21 +179,21 @@ FeedConverter.prototype = {
     //
     // If this is just a feed, not some kind of specialized application, then
     // auto-handlers can be set and we should obey them.
     try {
       var feedService = Cc["@mozilla.org/browser/feeds/result-service;1"]
                           .getService(Ci.nsIFeedResultService);
       if (!this._forcePreviewPage && result.doc) {
         var feed = result.doc.QueryInterface(Ci.nsIFeed);
-        var handler = safeGetCharPref(getPrefActionForType(feed.type), "ask");
+        var handler = Services.prefs.getCharPref(getPrefActionForType(feed.type), "ask");
 
         if (handler != "ask") {
           if (handler == "reader")
-            handler = safeGetCharPref(getPrefReaderForType(feed.type), "messenger");
+            handler = Services.prefs.getCharPref(getPrefReaderForType(feed.type), "messenger");
           switch (handler) {
             case "web":
               var wccr = Cc["@mozilla.org/embeddor.implemented/web-content-handler-registrar;1"]
                            .getService(Ci.nsIWebContentConverterService);
               if ((feed.type == Ci.nsIFeed.TYPE_FEED &&
                    wccr.getAutoHandler(TYPE_MAYBE_FEED)) ||
                   (feed.type == Ci.nsIFeed.TYPE_VIDEO &&
                    wccr.getAutoHandler(TYPE_MAYBE_VIDEO_FEED)) ||
@@ -348,19 +335,19 @@ FeedResultService.prototype = {
    * See nsIFeedResultService.idl
    */
   forcePreviewPage: false,
 
   /**
    * See nsIFeedResultService.idl
    */
   addToClientReader: function addToClientReader(spec, title, subtitle, feedType) {
-    var handler = safeGetCharPref(getPrefActionForType(feedType), "reader");
+    var handler = Services.prefs.getCharPref(getPrefActionForType(feedType), "reader");
     if (handler == "ask" || handler == "reader")
-      handler = safeGetCharPref(getPrefReaderForType(feedType), "messenger");
+      handler = Services.prefs.getCharPref(getPrefReaderForType(feedType), "messenger");
 
     switch (handler) {
     case "client":
       var clientApp = Services.prefs.getComplexValue(getPrefAppForType(feedType),
                                                      Ci.nsIFile);
 
       // For the benefit of applications that might know how to deal with more
       // URLs than just feeds, send feed: URLs in the following format:
--- a/suite/components/feeds/FeedWriter.js
+++ b/suite/components/feeds/FeedWriter.js
@@ -89,31 +89,18 @@ function getPrefReaderForType(t) {
       return PREF_AUDIO_SELECTED_READER;
 
     default:
       return PREF_SELECTED_READER;
   }
 }
 
 function LOG(str) {
-  try {
-    if (Services.prefs.getBoolPref("feeds.log"))
-      dump("*** Feeds: " + str + "\n");
-  }
-  catch (ex) {
-  }
-}
-
-function safeGetCharPref(pref, defaultValue) {
-  try {
-    return Services.prefs.getCharPref(pref);
-  }
-  catch (e) {
-  }
-  return defaultValue;
+  if (Services.prefs.getBoolPref("feeds.log", false))
+    dump("*** Feeds: " + str + "\n");
 }
 
 /**
  * Wrapper function for nsIIOService::newURI.
  * @param aURLSpec
  *        The URL string from which to create an nsIURI.
  * @returns an nsIURI object, or null if the creation of the URI failed.
  */
@@ -671,17 +658,17 @@ FeedWriter.prototype = {
       fp.appendFilters(Ci.nsIFilePicker.filterApps);
       fp.open(fpCallback);
     } catch(ex) {}
   },
 
   _setAlwaysUseCheckedState: function setAlwaysUseCheckedState(feedType) {
     var checkbox = this._getUIElement("alwaysUse");
     if (checkbox) {
-      var alwaysUse = (safeGetCharPref(getPrefActionForType(feedType), "ask") != "ask");
+      var alwaysUse = (Services.prefs.getCharPref(getPrefActionForType(feedType), "ask") != "ask");
       this._setCheckboxCheckedState(checkbox, alwaysUse);
     }
   },
 
   _setSubscribeUsingLabel: function setSubscribeUsingLabel() {
     var stringLabel = "subscribeFeedUsing";
     switch (this._getFeedType()) {
       case Ci.nsIFeed.TYPE_VIDEO:
@@ -758,17 +745,17 @@ FeedWriter.prototype = {
           break;
         default:
           this._setAlwaysUseLabel();
       }
     }
   },
 
   _setSelectedHandler: function setSelectedHandler(feedType) {
-    var handler = safeGetCharPref(getPrefReaderForType(feedType), "messenger");
+    var handler = Services.prefs.getCharPref(getPrefReaderForType(feedType), "messenger");
 
     switch (handler) {
       case "web":
         if (this._handlersMenuList) {
           var url = Services.prefs.getStringPref(getPrefWebForType(feedType));
           var handlers = this._handlersMenuList.getElementsByAttribute("webhandlerurl", url);
           if (handlers.length == 0) {
             LOG("FeedWriter._setSelectedHandler: selected web handler isn't in the menulist");