From 0628634a717eba507b3e19040d2043954be02bde Mon Sep 17 00:00:00 2001 From: "beng%bengoodger.com" Date: Fri, 28 Apr 2006 18:40:36 +0000 Subject: [PATCH] 333751 - more feed tweaking... safe exception handling around preferences. NOT PART OF BUILD! --- browser/components/feeds/content/subscribe.js | 25 ++++++----- .../components/feeds/content/subscribe.xhtml | 2 +- browser/components/feeds/src/FeedConverter.js | 42 +++++++++++++++---- 3 files changed, 49 insertions(+), 20 deletions(-) diff --git a/browser/components/feeds/content/subscribe.js b/browser/components/feeds/content/subscribe.js index 68ac3eae1cd..cbcad6e51c1 100644 --- a/browser/components/feeds/content/subscribe.js +++ b/browser/components/feeds/content/subscribe.js @@ -59,7 +59,12 @@ var SubscribeHandler = { }, _getPropertyAsString: function FH__getPropertyAsString(container, property) { - return container.fields.getPropertyAsAString(property); + try { + return container.fields.getPropertyAsAString(property); + } + catch (e) { + } + return ""; }, _setContentText: function SH__setContentText(id, text) { @@ -84,7 +89,7 @@ var SubscribeHandler = { return this._bundle.GetStringFromName(key); }, - init: function FH_init() { + init: function SH_init() { LOG("window.location.href = " + window.location.href); var feedService = @@ -106,12 +111,6 @@ var SubscribeHandler = { LOG("feed result is bozo?!"); } - var container = result.doc; - this._setContentText("feedTitleText", container.title); - this._setContentText("feedSubtitleText", - this._getPropertyAsString(container, "description")); - document.title = container.title; - // Set up the displayed handler this._initSelectedHandler(); var prefs = @@ -120,8 +119,12 @@ var SubscribeHandler = { prefs.addObserver(PREF_SELECTED_HANDLER, this, false); prefs.addObserver(PREF_SELECTED_APP, this, false); - // ... - + var container = result.doc; + this._setContentText("feedTitleText", container.title); + this._setContentText("feedSubtitleText", + this._getPropertyAsString(container, "description")); + document.title = container.title; + try { var parts = this._getPropertyAsBag(container, "image"); @@ -242,7 +245,7 @@ var SubscribeHandler = { "url(\"" + iconURI + "\")", ""); } catch (e) { - LOG("E2: " + e); + LOG("EEEE: " + e); // No selected handlers yet! Make the user choose... chosen.setAttribute("hidden", "true"); unchosen.removeAttribute("hidden"); diff --git a/browser/components/feeds/content/subscribe.xhtml b/browser/components/feeds/content/subscribe.xhtml index 212992e8982..5113c82945b 100644 --- a/browser/components/feeds/content/subscribe.xhtml +++ b/browser/components/feeds/content/subscribe.xhtml @@ -36,7 +36,7 @@ &feedSubscribeNow; &feedSubscribeUsing; - Live Bookmarks + &feedSubscribeChangeSubscribeOptions; diff --git a/browser/components/feeds/src/FeedConverter.js b/browser/components/feeds/src/FeedConverter.js index 1853cbb7a82..2a8726c4f4c 100644 --- a/browser/components/feeds/src/FeedConverter.js +++ b/browser/components/feeds/src/FeedConverter.js @@ -68,6 +68,30 @@ const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice"; const PREF_SELECTED_HANDLER = "browser.feeds.handler"; const PREF_SKIP_PREVIEW_PAGE = "browser.feeds.skip_preview_page"; +function safeGetBoolPref(pref, defaultValue) { + var prefs = + Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefBranch); + try { + return prefs.getBoolPref(pref); + } + catch (e) { + } + return defaultValue; +} + +function safeGetCharPref(pref, defaultValue) { + var prefs = + Cc["@mozilla.org/preferences-service;1"]. + getService(Ci.nsIPrefBranch); + try { + return prefs.getCharPref(pref); + } + catch (e) { + } + return defaultValue; +} + function FeedConverter() { } FeedConverter.prototype = { @@ -149,12 +173,9 @@ FeedConverter.prototype = { Cc["@mozilla.org/browser/feeds/result-service;1"]. getService(Ci.nsIFeedResultService); if (!this._forcePreviewPage) { - var prefs = - Cc["@mozilla.org/preferences-service;1"]. - getService(Ci.nsIPrefBranch); - var skipPreview = prefs.getBoolPref(PREF_SKIP_PREVIEW_PAGE); + var skipPreview = safeGetBoolPref(PREF_SKIP_PREVIEW_PAGE, false); if (skipPreview) { - var handler = prefs.getCharPref(PREF_SELECTED_HANDLER); + var handler = safeGetCharPref(PREF_SELECTED_HANDLER, "bookmarks"); if (handler == "web") { var wccr = Cc["@mozilla.org/web-content-handler-registrar;1"]. @@ -284,11 +305,16 @@ var FeedResultService = { var prefs = Cc["@mozilla.org/preferences-service;1"]. getService(Ci.nsIPrefBranch); - var handler = prefs.getCharPref(PREF_SELECTED_HANDLER); + var handler = safeGetCharPref(PREF_SELECTED_HANDLER, "bookmarks"); switch (handler) { case "client": - var clientApp = - prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile); + try { + var clientApp = + prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile); + } + catch (e) { + return; + } var process = Cc["@mozilla.org/process/util;1"]. createInstance(Ci.nsIProcess);