Bug 663269 - Handle null livemarks siteURIs.

r=dietrich
This commit is contained in:
Marco Bonardo 2011-06-15 01:54:31 +02:00
parent 96b9620223
commit 0e55ba696e
4 changed files with 22 additions and 16 deletions

View File

@ -402,9 +402,9 @@ PlacesViewBase.prototype = {
let as = PlacesUtils.annotations; let as = PlacesUtils.annotations;
let lmStatus = null; let lmStatus = null;
if (as.itemHasAnnotation(itemId, "livemark/loadfailed")) if (as.itemHasAnnotation(itemId, PlacesUtils.LMANNO_LOADFAILED))
lmStatus = "bookmarksLivemarkFailed"; lmStatus = "bookmarksLivemarkFailed";
else if (as.itemHasAnnotation(itemId, "livemark/loading")) else if (as.itemHasAnnotation(itemId, PlacesUtils.LMANNO_LOADING))
lmStatus = "bookmarksLivemarkLoading"; lmStatus = "bookmarksLivemarkLoading";
let lmStatusElt = aPopup._lmStatusMenuItem; let lmStatusElt = aPopup._lmStatusMenuItem;

View File

@ -618,10 +618,12 @@ var gEditItemOverlay = {
catch(ex) { } catch(ex) { }
var currentSiteURI = PlacesUtils.livemarks.getSiteURI(this._itemId); var currentSiteURI = PlacesUtils.livemarks.getSiteURI(this._itemId);
if (!uri || !currentSiteURI.equals(uri)) { if ((!uri && !currentSiteURI) ||
var txn = PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, uri); (uri && currentSiteURI && currentSiteURI.equals(uri))) {
PlacesUIUtils.ptm.doTransaction(txn); return;
} }
var txn = PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, uri);
PlacesUIUtils.ptm.doTransaction(txn);
}, },
onLoadInSidebarCheckboxCommand: onLoadInSidebarCheckboxCommand:

View File

@ -596,8 +596,9 @@ var PlacesUtils = {
case this.TYPE_X_MOZ_URL: { case this.TYPE_X_MOZ_URL: {
function gatherDataUrl(bNode) { function gatherDataUrl(bNode) {
if (PlacesUtils.nodeIsLivemarkContainer(bNode)) { if (PlacesUtils.nodeIsLivemarkContainer(bNode)) {
let siteURI = PlacesUtils.livemarks.getSiteURI(bNode.itemId).spec; let uri = PlacesUtils.livemarks.getSiteURI(bNode.itemId) ||
return siteURI + NEWLINE + bNode.title; PlacesUtils.livemarks.getFeedURI(bNode.itemId);
return uri.spec + NEWLINE + bNode.title;
} }
if (PlacesUtils.nodeIsURI(bNode)) if (PlacesUtils.nodeIsURI(bNode))
return (aOverrideURI || bNode.uri) + NEWLINE + bNode.title; return (aOverrideURI || bNode.uri) + NEWLINE + bNode.title;
@ -625,8 +626,9 @@ var PlacesUtils = {
// escape out potential HTML in the title // escape out potential HTML in the title
let escapedTitle = bNode.title ? htmlEscape(bNode.title) : ""; let escapedTitle = bNode.title ? htmlEscape(bNode.title) : "";
if (PlacesUtils.nodeIsLivemarkContainer(bNode)) { if (PlacesUtils.nodeIsLivemarkContainer(bNode)) {
let siteURI = PlacesUtils.livemarks.getSiteURI(bNode.itemId).spec; let uri = PlacesUtils.livemarks.getSiteURI(bNode.itemId) ||
return "<A HREF=\"" + siteURI + "\">" + escapedTitle + "</A>" + NEWLINE; PlacesUtils.livemarks.getFeedURI(bNode.itemId);
return "<A HREF=\"" + uri.spec + "\">" + escapedTitle + "</A>" + NEWLINE;
} }
if (PlacesUtils.nodeIsContainer(bNode)) { if (PlacesUtils.nodeIsContainer(bNode)) {
asContainer(bNode); asContainer(bNode);
@ -664,7 +666,8 @@ var PlacesUtils = {
// Otherwise, we wrap as TYPE_UNICODE. // Otherwise, we wrap as TYPE_UNICODE.
function gatherDataText(bNode) { function gatherDataText(bNode) {
if (PlacesUtils.nodeIsLivemarkContainer(bNode)) if (PlacesUtils.nodeIsLivemarkContainer(bNode))
return PlacesUtils.livemarks.getSiteURI(bNode.itemId).spec; return PlacesUtils.livemarks.getSiteURI(bNode.itemId) ||
PlacesUtils.livemarks.getFeedURI(bNode.itemId);
if (PlacesUtils.nodeIsContainer(bNode)) { if (PlacesUtils.nodeIsContainer(bNode)) {
asContainer(bNode); asContainer(bNode);
let wasOpen = bNode.containerOpen; let wasOpen = bNode.containerOpen;
@ -2590,11 +2593,11 @@ function PlacesRemoveLivemarkTransaction(aFolderId)
this._container = PlacesUtils.bookmarks.getFolderIdForItem(this._id); this._container = PlacesUtils.bookmarks.getFolderIdForItem(this._id);
let annos = PlacesUtils.getAnnotationsForItem(this._id); let annos = PlacesUtils.getAnnotationsForItem(this._id);
// Exclude livemark service annotations, those will be recreated automatically // Exclude livemark service annotations, those will be recreated automatically
let annosToExclude = ["livemark/feedURI", let annosToExclude = [PlacesUtils.LMANNO_FEEDURI,
"livemark/siteURI", PlacesUtils.LMANNO_SITEURI,
"livemark/expiration", PlacesUtils.LMANNO_EXPIRATION,
"livemark/loadfailed", PlacesUtils.LMANNO_LOADFAILED,
"livemark/loading"]; PlacesUtils.LMANNO_LOADING];
this._annotations = annos.filter(function(aValue, aIndex, aArray) { this._annotations = annos.filter(function(aValue, aIndex, aArray) {
return annosToExclude.indexOf(aValue.name) == -1; return annosToExclude.indexOf(aValue.name) == -1;
}); });

View File

@ -64,7 +64,8 @@ interface nsILivemarkService : nsISupports
* @param name The name to show when displaying the livemark * @param name The name to show when displaying the livemark
* @param siteURI The URI of the site the livemark was created from * @param siteURI The URI of the site the livemark was created from
* @param feedURI The URI of the actual RSS feed * @param feedURI The URI of the actual RSS feed
* @param index The index to insert at, or -1 to append * @param index The index to insert at, or
* nsINavBookmarksService.DEFAULT_INDEX to append.
* @returns the ID of the folder for the livemark * @returns the ID of the folder for the livemark
*/ */
long long createLivemark(in long long folder, long long createLivemark(in long long folder,