diff --git a/browser/components/bookmarks/content/microsummaryPicker.js b/browser/components/bookmarks/content/microsummaryPicker.js index e030221c40b7..7ac58499f59d 100644 --- a/browser/components/bookmarks/content/microsummaryPicker.js +++ b/browser/components/bookmarks/content/microsummaryPicker.js @@ -122,30 +122,29 @@ var MicrosummaryPicker = { * */ get enabled() { - if (this._mode == ADD_BOOKMARK_MODE) { + if (!("_enabled" in this)) { // If we're adding a bookmark, we only have to worry about livemarks - // and bookmarking multiple tabs. - if ("feedURL" in gArg || gArg.bBookmarkAllTabs) - return false; - } - else if (this._mode == EDIT_BOOKMARK_MODE) { + // and bookmarking multiple tabs; otherwise, the picker is enabled. + if (this._mode == ADD_BOOKMARK_MODE) + this._enabled = !("feedURL" in gArg || gArg.bBookmarkAllTabs); + // If we're modifying a bookmark, it could be a livemark, separator, // folder, or regular page. The picker is only enabled for regular pages. - var isLivemark = BookmarksUtils.resolveType(gResource) == "Livemark"; - var isSeparator = BookmarksUtils.resolveType(gResource) == "BookmarkSeparator"; - var isContainer = RDFCU.IsContainer(BMDS, gResource); - if (isLivemark || isSeparator || isContainer) - return false; - } - else { + else if (this._mode == EDIT_BOOKMARK_MODE) { + var bookmarkType = BookmarksUtils.resolveType(gResource); + this._enabled = !(bookmarkType == "Livemark" || + bookmarkType == "BookmarkSeparator" || + RDFCU.IsContainer(BMDS, gResource)); + } + // We should never get to this point, since we're only being used // in the Add Bookmark and Bookmark Properties dialogs, but if we're here // for some reason, be conservative and assume the picker is disabled. - return false; + else + this._enabled = false; } - // We haven't found a reason to disable the picker, so say it's enabled. - return true; + return this._enabled; }, init: function MSP_init() { @@ -153,7 +152,21 @@ var MicrosummaryPicker = { this._updateUserEnteredNameItem(); if (this._pageURI) { - this._microsummaries = this._mss.getMicrosummaries(this._pageURI, this._bookmarkID); + try { + this._microsummaries = this._mss.getMicrosummaries(this._pageURI, this._bookmarkID); + } + catch(ex) { + // There was a problem retrieving microsummaries; disable the picker. + // The microsummary service will throw an exception in at least + // two cases: + // 1. the bookmarked URI contains a scheme that the service won't + // download for security reasons (currently it only handles http, + // https, and file); + // 2. the page to which the URI refers isn't HTML or XML (the only two + // content types the service knows how to summarize). + this._enabled = false; + return; + } this._microsummaries.addObserver(this._observer); this.rebuild(); } diff --git a/browser/components/places/content/bookmarkProperties.js b/browser/components/places/content/bookmarkProperties.js index 5c264685da3a..f19569be46bd 100755 --- a/browser/components/places/content/bookmarkProperties.js +++ b/browser/components/places/content/bookmarkProperties.js @@ -173,15 +173,20 @@ var BookmarkPropertiesPanel = { * of the dialog. */ _isMicrosummaryVisible: function BPP__isMicrosummaryVisible() { - switch(this._variant) { - case this.EDIT_FOLDER_VARIANT: - case this.ADD_MULTIPLE_BOOKMARKS_VARIANT: - case this.ADD_LIVEMARK_VARIANT: - case this.EDIT_LIVEMARK_VARIANT: - return false; - default: - return true; + if (!("_microsummaryVisible" in this)) { + switch(this._variant) { + case this.EDIT_FOLDER_VARIANT: + case this.ADD_MULTIPLE_BOOKMARKS_VARIANT: + case this.ADD_LIVEMARK_VARIANT: + case this.EDIT_LIVEMARK_VARIANT: + this._microsummaryVisible = false; + break; + default: + this._microsummaryVisible = true; + break; + } } + return this._microsummaryVisible; }, /** @@ -406,6 +411,28 @@ var BookmarkPropertiesPanel = { this._folderTree.load([query], options); }, + _initMicrosummaryPicker: function BPP__initMicrosummaryPicker() { + try { + this._microsummaries = this._mss.getMicrosummaries(this._bookmarkURI, + this._bookmarkURI); + } + catch(ex) { + // There was a problem retrieving microsummaries; disable the picker. + // The microsummary service will throw an exception in at least + // two cases: + // 1. the bookmarked URI contains a scheme that the service won't + // download for security reasons (currently it only handles http, + // https, and file); + // 2. the page to which the URI refers isn't HTML or XML (the only two + // content types the service knows how to summarize). + this._microsummaryVisible = false; + this._hide("microsummaryRow"); + return; + } + this._microsummaries.addObserver(this._microsummaryObserver); + this._rebuildMicrosummaryPicker(); + }, + /** * This is a shorter form of getElementById for the dialog document. * Given a XUL element ID from the dialog, returns the corresponding @@ -495,15 +522,10 @@ var BookmarkPropertiesPanel = { } if (this._isMicrosummaryVisible()) { - this._microsummaries = this._mss.getMicrosummaries(this._bookmarkURI, - this._bookmarkURI); - this._microsummaries.addObserver(this._microsummaryObserver); - this._rebuildMicrosummaryPicker(); + this._initMicrosummaryPicker(); } else { - var microsummaryRow = - this._dialogWindow.document.getElementById("microsummaryRow"); - microsummaryRow.setAttribute("hidden", "true"); + this._hide("microsummaryRow"); } if (this._isFolderEditable()) {