зеркало из https://github.com/mozilla/pjs.git
333751 - more feed tweaking... safe exception handling around preferences. NOT PART OF BUILD!
This commit is contained in:
Родитель
2b6239d4e7
Коммит
0628634a71
|
@ -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");
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
&feedSubscribeNow;</a>
|
||||
&feedSubscribeUsing;
|
||||
<span id="feedSubscribeHandler">
|
||||
<a id="feedSubscribeHandleText">Live Bookmarks</a>
|
||||
<a id="feedSubscribeHandleText"></a>
|
||||
</span>
|
||||
<a id="feedChangeSubscribeOptions" href="javascript:SubscribeHandler.changeOptions();">
|
||||
&feedSubscribeChangeSubscribeOptions;</a>
|
||||
|
|
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче