333751 - more feed tweaking... safe exception handling around preferences. NOT PART OF BUILD!

This commit is contained in:
beng%bengoodger.com 2006-04-28 18:40:36 +00:00
Родитель 2b6239d4e7
Коммит 0628634a71
3 изменённых файлов: 49 добавлений и 20 удалений

Просмотреть файл

@ -59,7 +59,12 @@ var SubscribeHandler = {
}, },
_getPropertyAsString: function FH__getPropertyAsString(container, property) { _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) { _setContentText: function SH__setContentText(id, text) {
@ -84,7 +89,7 @@ var SubscribeHandler = {
return this._bundle.GetStringFromName(key); return this._bundle.GetStringFromName(key);
}, },
init: function FH_init() { init: function SH_init() {
LOG("window.location.href = " + window.location.href); LOG("window.location.href = " + window.location.href);
var feedService = var feedService =
@ -106,12 +111,6 @@ var SubscribeHandler = {
LOG("feed result is bozo?!"); 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 // Set up the displayed handler
this._initSelectedHandler(); this._initSelectedHandler();
var prefs = var prefs =
@ -120,8 +119,12 @@ var SubscribeHandler = {
prefs.addObserver(PREF_SELECTED_HANDLER, this, false); prefs.addObserver(PREF_SELECTED_HANDLER, this, false);
prefs.addObserver(PREF_SELECTED_APP, 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 { try {
var parts = this._getPropertyAsBag(container, "image"); var parts = this._getPropertyAsBag(container, "image");
@ -242,7 +245,7 @@ var SubscribeHandler = {
"url(\"" + iconURI + "\")", ""); "url(\"" + iconURI + "\")", "");
} }
catch (e) { catch (e) {
LOG("E2: " + e); LOG("EEEE: " + e);
// No selected handlers yet! Make the user choose... // No selected handlers yet! Make the user choose...
chosen.setAttribute("hidden", "true"); chosen.setAttribute("hidden", "true");
unchosen.removeAttribute("hidden"); unchosen.removeAttribute("hidden");

Просмотреть файл

@ -36,7 +36,7 @@
&feedSubscribeNow;</a> &feedSubscribeNow;</a>
&feedSubscribeUsing; &feedSubscribeUsing;
<span id="feedSubscribeHandler"> <span id="feedSubscribeHandler">
<a id="feedSubscribeHandleText">Live Bookmarks</a> <a id="feedSubscribeHandleText"></a>
</span> </span>
<a id="feedChangeSubscribeOptions" href="javascript:SubscribeHandler.changeOptions();"> <a id="feedChangeSubscribeOptions" href="javascript:SubscribeHandler.changeOptions();">
&feedSubscribeChangeSubscribeOptions;</a> &feedSubscribeChangeSubscribeOptions;</a>

Просмотреть файл

@ -68,6 +68,30 @@ const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
const PREF_SELECTED_HANDLER = "browser.feeds.handler"; const PREF_SELECTED_HANDLER = "browser.feeds.handler";
const PREF_SKIP_PREVIEW_PAGE = "browser.feeds.skip_preview_page"; 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() { function FeedConverter() {
} }
FeedConverter.prototype = { FeedConverter.prototype = {
@ -149,12 +173,9 @@ FeedConverter.prototype = {
Cc["@mozilla.org/browser/feeds/result-service;1"]. Cc["@mozilla.org/browser/feeds/result-service;1"].
getService(Ci.nsIFeedResultService); getService(Ci.nsIFeedResultService);
if (!this._forcePreviewPage) { if (!this._forcePreviewPage) {
var prefs = var skipPreview = safeGetBoolPref(PREF_SKIP_PREVIEW_PAGE, false);
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var skipPreview = prefs.getBoolPref(PREF_SKIP_PREVIEW_PAGE);
if (skipPreview) { if (skipPreview) {
var handler = prefs.getCharPref(PREF_SELECTED_HANDLER); var handler = safeGetCharPref(PREF_SELECTED_HANDLER, "bookmarks");
if (handler == "web") { if (handler == "web") {
var wccr = var wccr =
Cc["@mozilla.org/web-content-handler-registrar;1"]. Cc["@mozilla.org/web-content-handler-registrar;1"].
@ -284,11 +305,16 @@ var FeedResultService = {
var prefs = var prefs =
Cc["@mozilla.org/preferences-service;1"]. Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch); getService(Ci.nsIPrefBranch);
var handler = prefs.getCharPref(PREF_SELECTED_HANDLER); var handler = safeGetCharPref(PREF_SELECTED_HANDLER, "bookmarks");
switch (handler) { switch (handler) {
case "client": case "client":
var clientApp = try {
prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile); var clientApp =
prefs.getComplexValue(PREF_SELECTED_APP, Ci.nsILocalFile);
}
catch (e) {
return;
}
var process = var process =
Cc["@mozilla.org/process/util;1"]. Cc["@mozilla.org/process/util;1"].
createInstance(Ci.nsIProcess); createInstance(Ci.nsIProcess);