Bug 969408 - Remove old Deprecated methods from PlacesUtils. r=mano

This commit is contained in:
Marco Bonardo 2014-03-03 17:51:44 +01:00
parent fbb61eabea
commit 512c65a96b
2 changed files with 1 additions and 262 deletions

View File

@ -76,12 +76,6 @@ function QI_node(aNode, aIID) {
}
return result;
}
function asVisit(aNode) {
Deprecated.warning(
"asVisit is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=561450");
return aNode;
};
function asContainer(aNode) QI_node(aNode, Ci.nsINavHistoryContainerResultNode);
function asQuery(aNode) QI_node(aNode, Ci.nsINavHistoryQueryResultNode);
@ -119,7 +113,6 @@ this.PlacesUtils = {
TOPIC_BOOKMARKS_RESTORE_SUCCESS: "bookmarks-restore-success",
TOPIC_BOOKMARKS_RESTORE_FAILED: "bookmarks-restore-failed",
asVisit: function(aNode) asVisit(aNode),
asContainer: function(aNode) asContainer(aNode),
asQuery: function(aNode) asQuery(aNode),
@ -188,34 +181,12 @@ this.PlacesUtils = {
return aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR;
},
/**
* Determines whether or not a ResultNode is a visit item.
* @param aNode
* A result node
* @returns true if the node is a visit item, false otherwise
*/
nodeIsVisit: function PU_nodeIsVisit(aNode) {
Deprecated.warning(
"nodeIsVisit is deprecated ans will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=561450");
return this.nodeIsURI(aNode) && aNode.parent &&
this.nodeIsQuery(aNode.parent) &&
asQuery(aNode.parent).queryOptions.resultType ==
Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT;
},
/**
* Determines whether or not a ResultNode is a URL item.
* @param aNode
* A result node
* @returns true if the node is a URL item, false otherwise
*/
get uriTypes() {
Deprecated.warning(
"uriTypes is deprecated ans will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=561450");
return [Ci.nsINavHistoryResultNode.RESULT_TYPE_URI];
},
nodeIsURI: function PU_nodeIsURI(aNode) {
return aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_URI;
},
@ -1128,155 +1099,6 @@ this.PlacesUtils = {
return urls;
},
/**
* Takes a JSON-serialized node and inserts it into the db.
*
* @param aData
* The unwrapped data blob of dropped or pasted data.
* @param aContainer
* The container the data was dropped or pasted into
* @param aIndex
* The index within the container the item was dropped or pasted at
* @returns an array containing of maps of old folder ids to new folder ids,
* and an array of saved search ids that need to be fixed up.
* eg: [[[oldFolder1, newFolder1]], [search1]]
*/
importJSONNode: function PU_importJSONNode(aData, aContainer, aIndex, aGrandParentId) {
Deprecated.warning(
"importJSONNode is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=855842");
var folderIdMap = [];
var searchIds = [];
var id = -1;
switch (aData.type) {
case this.TYPE_X_MOZ_PLACE_CONTAINER:
if (aContainer == PlacesUtils.tagsFolderId) {
// node is a tag
if (aData.children) {
aData.children.forEach(function(aChild) {
try {
this.tagging.tagURI(this._uri(aChild.uri), [aData.title]);
} catch (ex) {
// invalid tag child, skip it
}
}, this);
return [folderIdMap, searchIds];
}
}
else if (aData.livemark && aData.annos) {
// node is a livemark
var feedURI = null;
var siteURI = null;
aData.annos = aData.annos.filter(function(aAnno) {
switch (aAnno.name) {
case this.LMANNO_FEEDURI:
feedURI = this._uri(aAnno.value);
return false;
case this.LMANNO_SITEURI:
siteURI = this._uri(aAnno.value);
return false;
default:
return true;
}
}, this);
if (feedURI) {
this.livemarks.addLivemark(
{ title: aData.title
, feedURI: feedURI
, parentId: aContainer
, index: aIndex
, lastModified: aData.lastModified
, siteURI: siteURI
},
(function(aStatus, aLivemark) {
if (Components.isSuccessCode(aStatus)) {
let id = aLivemark.id;
if (aData.dateAdded)
this.bookmarks.setItemDateAdded(id, aData.dateAdded);
if (aData.annos && aData.annos.length)
this.setAnnotationsForItem(id, aData.annos);
}
}).bind(this)
);
}
}
else {
id = this.bookmarks.createFolder(aContainer, aData.title, aIndex);
folderIdMap[aData.id] = id;
// process children
if (aData.children) {
aData.children.forEach(function(aChild, aIndex) {
var [folders, searches] = this.importJSONNode(aChild, id, aIndex, aContainer);
for (var i = 0; i < folders.length; i++) {
if (folders[i])
folderIdMap[i] = folders[i];
}
searchIds = searchIds.concat(searches);
}, this);
}
}
break;
case this.TYPE_X_MOZ_PLACE:
id = this.bookmarks.insertBookmark(aContainer, this._uri(aData.uri),
aIndex, aData.title);
if (aData.keyword)
this.bookmarks.setKeywordForBookmark(id, aData.keyword);
if (aData.tags) {
var tags = aData.tags.split(", ");
if (tags.length)
this.tagging.tagURI(this._uri(aData.uri), tags);
}
if (aData.charset) {
this.setCharsetForURI(this._uri(aData.uri), aData.charset);
}
if (aData.uri.substr(0, 6) == "place:")
searchIds.push(id);
if (aData.icon) {
try {
// Create a fake faviconURI to use (FIXME: bug 523932)
let faviconURI = this._uri("fake-favicon-uri:" + aData.uri);
this.favicons.replaceFaviconDataFromDataURL(faviconURI, aData.icon, 0);
this.favicons.setAndFetchFaviconForPage(this._uri(aData.uri), faviconURI, false,
this.favicons.FAVICON_LOAD_NON_PRIVATE);
} catch (ex) {
Components.utils.reportError("Failed to import favicon data:" + ex);
}
}
if (aData.iconUri) {
try {
this.favicons.setAndFetchFaviconForPage(this._uri(aData.uri),
this._uri(aData.iconUri),
false,
this.favicons.FAVICON_LOAD_NON_PRIVATE);
} catch (ex) {
Components.utils.reportError("Failed to import favicon URI:" + ex);
}
}
break;
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
id = this.bookmarks.insertSeparator(aContainer, aIndex);
break;
default:
// Unknown node type
}
// set generic properties, valid for all nodes
if (id != -1 &&
aContainer != PlacesUtils.tagsFolderId &&
aGrandParentId != PlacesUtils.tagsFolderId) {
if (aData.dateAdded)
this.bookmarks.setItemDateAdded(id, aData.dateAdded);
if (aData.lastModified)
this.bookmarks.setItemLastModified(id, aData.lastModified);
if (aData.annos && aData.annos.length)
this.setAnnotationsForItem(id, aData.annos);
}
return [folderIdMap, searchIds];
},
/**
* Serializes the given node (and all its descendents) as JSON
* and writes the serialization to the given output stream.
@ -1491,89 +1313,6 @@ this.PlacesUtils = {
}
},
/**
* Serializes the given node (and all its descendents) as JSON
* and writes the serialization to the given output stream.
*
* @param aNode
* An nsINavHistoryResultNode
* @param aStream
* An nsIOutputStream. NOTE: it only uses the write(str, len)
* method of nsIOutputStream. The caller is responsible for
* closing the stream.
* @param aIsUICommand
* Boolean - If true, modifies serialization so that each node self-contained.
* For Example, tags are serialized inline with each bookmark.
* @param aResolveShortcuts
* Converts folder shortcuts into actual folders.
* @param aExcludeItems
* An array of item ids that should not be written to the backup.
*/
serializeNodeAsJSONToOutputStream:
function PU_serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
aResolveShortcuts,
aExcludeItems) {
Deprecated.warning(
"serializeNodeAsJSONToOutputStream is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=854761");
this._serializeNodeAsJSONToOutputStream(aNode, aStream, aIsUICommand,
aResolveShortcuts, aExcludeItems);
},
/**
* Restores bookmarks and tags from a JSON file.
* WARNING: This method *removes* any bookmarks in the collection before
* restoring from the file.
*
* @param aFile
* nsIFile of bookmarks in JSON format to be restored.
*/
restoreBookmarksFromJSONFile:
function PU_restoreBookmarksFromJSONFile(aFile) {
Deprecated.warning(
"restoreBookmarksFromJSONFile is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=854388");
BookmarkJSONUtils.importFromFile(aFile, true);
},
/**
* Serializes bookmarks using JSON, and writes to the supplied file.
*
* @see backups.saveBookmarksToJSONFile(aFile)
*/
backupBookmarksToFile: function PU_backupBookmarksToFile(aFile) {
Deprecated.warning(
"backupBookmarksToFile is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=852041");
return PlacesBackups.saveBookmarksToJSONFile(aFile);
},
/**
* Creates a dated backup in <profile>/bookmarkbackups.
* Stores the bookmarks using JSON.
*
* @see backups.create(aMaxBackups, aForceBackup)
*/
archiveBookmarksFile:
function PU_archiveBookmarksFile(aMaxBackups, aForceBackup) {
Deprecated.warning(
"archiveBookmarksFile is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=857429");
return PlacesBackups.create(aMaxBackups, aForceBackup);
},
/**
* Helper to create and manage backups.
*/
get backups() {
Deprecated.warning(
"PlacesUtils.backups is deprecated and will be removed in a future version",
"https://bugzilla.mozilla.org/show_bug.cgi?id=857429");
return PlacesBackups;
},
/**
* Given a uri returns list of itemIds associated to it.
*

View File

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* Check for correct functionality of PlacesUtils.archiveBookmarksFile
* Check for correct functionality of bookmarks backups
*/
const PREFIX = "bookmarks-";