From 0e55ba696ec844c54061b7828abd4336947a4932 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Wed, 15 Jun 2011 01:54:31 +0200 Subject: [PATCH] Bug 663269 - Handle null livemarks siteURIs. r=dietrich --- .../places/content/browserPlacesViews.js | 4 ++-- .../places/content/editBookmarkOverlay.js | 8 ++++--- toolkit/components/places/PlacesUtils.jsm | 23 +++++++++++-------- .../components/places/nsILivemarkService.idl | 3 ++- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js index 9ed371203232..f6b68c4159a8 100644 --- a/browser/components/places/content/browserPlacesViews.js +++ b/browser/components/places/content/browserPlacesViews.js @@ -402,9 +402,9 @@ PlacesViewBase.prototype = { let as = PlacesUtils.annotations; let lmStatus = null; - if (as.itemHasAnnotation(itemId, "livemark/loadfailed")) + if (as.itemHasAnnotation(itemId, PlacesUtils.LMANNO_LOADFAILED)) lmStatus = "bookmarksLivemarkFailed"; - else if (as.itemHasAnnotation(itemId, "livemark/loading")) + else if (as.itemHasAnnotation(itemId, PlacesUtils.LMANNO_LOADING)) lmStatus = "bookmarksLivemarkLoading"; let lmStatusElt = aPopup._lmStatusMenuItem; diff --git a/browser/components/places/content/editBookmarkOverlay.js b/browser/components/places/content/editBookmarkOverlay.js index b8dc383a8c17..49ace75387fa 100644 --- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -618,10 +618,12 @@ var gEditItemOverlay = { catch(ex) { } var currentSiteURI = PlacesUtils.livemarks.getSiteURI(this._itemId); - if (!uri || !currentSiteURI.equals(uri)) { - var txn = PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, uri); - PlacesUIUtils.ptm.doTransaction(txn); + if ((!uri && !currentSiteURI) || + (uri && currentSiteURI && currentSiteURI.equals(uri))) { + return; } + var txn = PlacesUIUtils.ptm.editLivemarkSiteURI(this._itemId, uri); + PlacesUIUtils.ptm.doTransaction(txn); }, onLoadInSidebarCheckboxCommand: diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 538ae8127479..6d13fae0c471 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -596,8 +596,9 @@ var PlacesUtils = { case this.TYPE_X_MOZ_URL: { function gatherDataUrl(bNode) { if (PlacesUtils.nodeIsLivemarkContainer(bNode)) { - let siteURI = PlacesUtils.livemarks.getSiteURI(bNode.itemId).spec; - return siteURI + NEWLINE + bNode.title; + let uri = PlacesUtils.livemarks.getSiteURI(bNode.itemId) || + PlacesUtils.livemarks.getFeedURI(bNode.itemId); + return uri.spec + NEWLINE + bNode.title; } if (PlacesUtils.nodeIsURI(bNode)) return (aOverrideURI || bNode.uri) + NEWLINE + bNode.title; @@ -625,8 +626,9 @@ var PlacesUtils = { // escape out potential HTML in the title let escapedTitle = bNode.title ? htmlEscape(bNode.title) : ""; if (PlacesUtils.nodeIsLivemarkContainer(bNode)) { - let siteURI = PlacesUtils.livemarks.getSiteURI(bNode.itemId).spec; - return "" + escapedTitle + "" + NEWLINE; + let uri = PlacesUtils.livemarks.getSiteURI(bNode.itemId) || + PlacesUtils.livemarks.getFeedURI(bNode.itemId); + return "" + escapedTitle + "" + NEWLINE; } if (PlacesUtils.nodeIsContainer(bNode)) { asContainer(bNode); @@ -664,7 +666,8 @@ var PlacesUtils = { // Otherwise, we wrap as TYPE_UNICODE. function gatherDataText(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)) { asContainer(bNode); let wasOpen = bNode.containerOpen; @@ -2590,11 +2593,11 @@ function PlacesRemoveLivemarkTransaction(aFolderId) this._container = PlacesUtils.bookmarks.getFolderIdForItem(this._id); let annos = PlacesUtils.getAnnotationsForItem(this._id); // Exclude livemark service annotations, those will be recreated automatically - let annosToExclude = ["livemark/feedURI", - "livemark/siteURI", - "livemark/expiration", - "livemark/loadfailed", - "livemark/loading"]; + let annosToExclude = [PlacesUtils.LMANNO_FEEDURI, + PlacesUtils.LMANNO_SITEURI, + PlacesUtils.LMANNO_EXPIRATION, + PlacesUtils.LMANNO_LOADFAILED, + PlacesUtils.LMANNO_LOADING]; this._annotations = annos.filter(function(aValue, aIndex, aArray) { return annosToExclude.indexOf(aValue.name) == -1; }); diff --git a/toolkit/components/places/nsILivemarkService.idl b/toolkit/components/places/nsILivemarkService.idl index 2c4f453f1269..eab87ae30e51 100644 --- a/toolkit/components/places/nsILivemarkService.idl +++ b/toolkit/components/places/nsILivemarkService.idl @@ -64,7 +64,8 @@ interface nsILivemarkService : nsISupports * @param name The name to show when displaying the livemark * @param siteURI The URI of the site the livemark was created from * @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 */ long long createLivemark(in long long folder,