Bug 885246 - Remove usage of the sync history.getPageTitle API from BookmarkProperties.js. r?adw
MozReview-Commit-ID: KXhWKebkdvz
--- a/browser/components/places/content/bookmarkProperties.js
+++ b/browser/components/places/content/bookmarkProperties.js
@@ -145,17 +145,17 @@ var BookmarkPropertiesPanel = {
return this._strings.getFormattedString("dialogTitleEdit", [this._title]);
}
return "";
},
/**
* Determines the initial data for the item edited or added by this dialog
*/
- _determineItemInfo() {
+ async _determineItemInfo() {
let dialogInfo = window.arguments[0];
this._action = dialogInfo.action == "add" ? ACTION_ADD : ACTION_EDIT;
this._hiddenRows = dialogInfo.hiddenRows ? dialogInfo.hiddenRows : [];
if (this._action == ACTION_ADD) {
NS_ASSERT("type" in dialogInfo, "missing type property for add action");
if ("title" in dialogInfo)
this._title = dialogInfo.title;
@@ -173,17 +173,17 @@ var BookmarkPropertiesPanel = {
switch (dialogInfo.type) {
case "bookmark":
this._itemType = BOOKMARK_ITEM;
if ("uri" in dialogInfo) {
NS_ASSERT(dialogInfo.uri instanceof Ci.nsIURI,
"uri property should be a uri object");
this._uri = dialogInfo.uri;
if (typeof(this._title) != "string") {
- this._title = this._getURITitleFromHistory(this._uri) ||
+ this._title = await PlacesUtils.history.fetch(this._uri) ||
this._uri.spec;
}
} else {
this._uri = PlacesUtils._uri("about:blank");
this._title = this._strings.getString("newBookmarkDefault");
this._dummyItem = true;
}
@@ -216,17 +216,17 @@ var BookmarkPropertiesPanel = {
this._itemType = LIVEMARK_CONTAINER;
if ("feedURI" in dialogInfo)
this._feedURI = dialogInfo.feedURI;
if ("siteURI" in dialogInfo)
this._siteURI = dialogInfo.siteURI;
if (!this._title) {
if (this._feedURI) {
- this._title = this._getURITitleFromHistory(this._feedURI) ||
+ this._title = await PlacesUtils.history.fetch(this._feedURI) ||
this._feedURI.spec;
} else
this._title = this._strings.getString("newLivemarkDefault");
}
}
if ("description" in dialogInfo)
this._description = dialogInfo.description;
@@ -236,39 +236,21 @@ var BookmarkPropertiesPanel = {
if (PlacesUtils.nodeIsFolder(this._node))
this._itemType = BOOKMARK_FOLDER;
else if (PlacesUtils.nodeIsURI(this._node))
this._itemType = BOOKMARK_ITEM;
}
},
/**
- * This method returns the title string corresponding to a given URI.
- * If none is available from the bookmark service (probably because
- * the given URI doesn't appear in bookmarks or history), we synthesize
- * a title from the first 100 characters of the URI.
- *
- * @param aURI
- * nsIURI object for which we want the title
- *
- * @returns a title string
- */
- _getURITitleFromHistory: function BPP__getURITitleFromHistory(aURI) {
- NS_ASSERT(aURI instanceof Ci.nsIURI);
-
- // get the title from History
- return PlacesUtils.history.getPageTitle(aURI);
- },
-
- /**
* This method should be called by the onload of the Bookmark Properties
* dialog to initialize the state of the panel.
*/
- onDialogLoad() {
- this._determineItemInfo();
+ async onDialogLoad() {
+ await this._determineItemInfo();
document.title = this._getDialogTitle();
// Disable the buttons until we have all the information required.
let acceptButton = document.documentElement.getButton("accept");
acceptButton.disabled = true;
// Allow initialization to complete in a truely async manner so that we're