Bug 696159 - Remove some deprecated Places code.

r=dietrich sr=rstrong
This commit is contained in:
Marco Bonardo 2011-10-27 11:11:43 +02:00
parent d5bdd788f6
commit 7279ff22e3
15 changed files with 117 additions and 346 deletions

View File

@ -131,7 +131,16 @@ let RemoteTabViewer = {
let item = this._tabsList.selectedItems[0]; let item = this._tabsList.selectedItems[0];
let uri = Weave.Utils.makeURI(item.getAttribute("url")); let uri = Weave.Utils.makeURI(item.getAttribute("url"));
let title = item.getAttribute("title"); let title = item.getAttribute("title");
PlacesUIUtils.showMinimalAddBookmarkUI(uri, title); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "bookmark"
, uri: uri
, title: title
, hiddenRows: [ "description"
, "location"
, "folderPicker"
, "loadInSidebar"
, "keyword" ]
});
}, },
bookmarkSelectedTabs: function() { bookmarkSelectedTabs: function() {
@ -146,8 +155,13 @@ let RemoteTabViewer = {
URIs.push(uri); URIs.push(uri);
} }
} }
if (URIs.length) if (URIs.length) {
PlacesUIUtils.showMinimalAddMultiBookmarkUI(URIs); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "folder"
, URIList: URIs
, hiddenRows: [ "description" ]
});
}
}, },
_generateTabList: function() { _generateTabList: function() {

View File

@ -378,11 +378,23 @@ var PlacesCommandHook = {
bookmarkLink: function PCH_bookmarkLink(aParent, aURL, aTitle) { bookmarkLink: function PCH_bookmarkLink(aParent, aURL, aTitle) {
var linkURI = makeURI(aURL); var linkURI = makeURI(aURL);
var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI); var itemId = PlacesUtils.getMostRecentBookmarkForURI(linkURI);
if (itemId == -1) if (itemId == -1) {
PlacesUIUtils.showMinimalAddBookmarkUI(linkURI, aTitle); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "bookmark"
, uri: linkURI
, title: aTitle
, hiddenRows: [ "description"
, "location"
, "loadInSidebar"
, "folderPicker"
, "keyword" ]
});
}
else { else {
PlacesUIUtils.showItemProperties(itemId, PlacesUIUtils.showBookmarkDialog({ action: "edit"
PlacesUtils.bookmarks.TYPE_BOOKMARK); , type: "bookmark"
, itemId: itemId
});
} }
}, },
@ -411,7 +423,11 @@ var PlacesCommandHook = {
bookmarkCurrentPages: function PCH_bookmarkCurrentPages() { bookmarkCurrentPages: function PCH_bookmarkCurrentPages() {
let pages = this.uniqueCurrentPages; let pages = this.uniqueCurrentPages;
if (pages.length > 1) { if (pages.length > 1) {
PlacesUIUtils.showMinimalAddMultiBookmarkUI(pages); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "folder"
, URIList: pages
, hiddenRows: [ "description" ]
});
} }
}, },
@ -451,10 +467,18 @@ var PlacesCommandHook = {
else else
description = PlacesUIUtils.getDescriptionFromDocument(doc); description = PlacesUIUtils.getDescriptionFromDocument(doc);
var toolbarIP = var toolbarIP = new InsertionPoint(PlacesUtils.toolbarFolderId, -1);
new InsertionPoint(PlacesUtils.bookmarks.toolbarFolder, -1); PlacesUIUtils.showBookmarkDialog({ action: "add"
PlacesUIUtils.showMinimalAddLivemarkUI(feedURI, gBrowser.currentURI, , type: "livemark"
title, description, toolbarIP, true); , feedURI: feedURI
, siteURI: gBrowser.currentURI
, title: title
, description: description
, defaultInsertionPoint: toolbarIP
, hiddenRows: [ "feedLocation"
, "siteLocation"
, "description" ]
});
}, },
/** /**

View File

@ -3122,7 +3122,16 @@ var bookmarksButtonObserver = {
let name = { }; let name = { };
let url = browserDragAndDrop.drop(aEvent, name); let url = browserDragAndDrop.drop(aEvent, name);
try { try {
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), name); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "bookmark"
, uri: makeURI(url)
, title: name
, hiddenRows: [ "description"
, "location"
, "loadInSidebar"
, "folderPicker"
, "keyword" ]
});
} catch(ex) { } } catch(ex) { }
}, },
@ -5588,9 +5597,16 @@ function contentAreaClick(event, isPanelClick)
// This is the Opera convention for a special link that, when clicked, // This is the Opera convention for a special link that, when clicked,
// allows to add a sidebar panel. The link's title attribute contains // allows to add a sidebar panel. The link's title attribute contains
// the title that should be used for the sidebar panel. // the title that should be used for the sidebar panel.
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(href), PlacesUIUtils.showBookmarkDialog({ action: "add"
linkNode.getAttribute("title"), , type: "bookmark"
null, null, true, true); , uri: makeURI(href)
, title: linkNode.getAttribute("title")
, loadBookmarkInSidebar: true
, hiddenRows: [ "description"
, "location"
, "folderPicker"
, "keyword" ]
});
event.preventDefault(); event.preventDefault();
return true; return true;
} }
@ -6626,8 +6642,18 @@ function AddKeywordForSearchField() {
else else
spec += "?" + formData.join("&"); spec += "?" + formData.join("&");
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(spec), title, description, null, PlacesUIUtils.showBookmarkDialog({ action: "add"
null, null, "", postData, charset); , type: "bookmark"
, uri: makeURI(spec)
, title: title
, description: description
, keyword: ""
, postData: postData
, charSet: charset
, hiddenRows: [ "location"
, "loadInSidebar"
, "folderPicker" ]
});
} }
function SwitchDocumentDirection(aWindow) { function SwitchDocumentDirection(aWindow) {

View File

@ -1397,11 +1397,24 @@ nsContextMenu.prototype = {
if (itemId == -1) { if (itemId == -1) {
var title = doc.title; var title = doc.title;
var description = PlacesUIUtils.getDescriptionFromDocument(doc); var description = PlacesUIUtils.getDescriptionFromDocument(doc);
PlacesUIUtils.showMinimalAddBookmarkUI(uri, title, description); PlacesUIUtils.showBookmarkDialog({ action: "add"
, type: "bookmark"
, uri: uri
, title: title
, description: description
, hiddenRows: [ "description"
, "location"
, "loadInSidebar"
, "folderPicker"
, "keyword" ]
});
}
else {
PlacesUIUtils.showBookmarkDialog({ action: "edit"
, type: "bookmark"
, itemId: itemId
});
} }
else
PlacesUIUtils.showItemProperties(itemId,
PlacesUtils.bookmarks.TYPE_BOOKMARK);
}, },
savePageAs: function CM_savePageAs() { savePageAs: function CM_savePageAs() {

View File

@ -586,9 +586,6 @@ PlacesViewBase.prototype = {
nodeKeywordChanged: function() { }, nodeKeywordChanged: function() { },
sortingChanged: function() { }, sortingChanged: function() { },
batching: function() { }, batching: function() { },
// Replaced by containerStateChanged.
containerOpened: function() { },
containerClosed: function() { },
nodeInserted: nodeInserted:
function PVB_nodeInserted(aParentPlacesNode, aPlacesNode, aIndex) { function PVB_nodeInserted(aParentPlacesNode, aPlacesNode, aIndex) {

View File

@ -137,7 +137,6 @@ PlacesController.prototype = {
}, },
supportsCommand: function PC_supportsCommand(aCommand) { supportsCommand: function PC_supportsCommand(aCommand) {
//LOG("supportsCommand: " + command);
// Non-Places specific commands that we also support // Non-Places specific commands that we also support
switch (aCommand) { switch (aCommand) {
case "cmd_undo": case "cmd_undo":
@ -778,17 +777,6 @@ PlacesController.prototype = {
} }
}, },
/**
* Create a new Bookmark folder somewhere. Prompts the user for the name
* of the folder.
*/
newFolder: function PC_newFolder() {
Cu.reportError("PlacesController.newFolder is deprecated and will be \
removed in a future release. Use newItem instead.");
this.newItem("folder");
},
/** /**
* Create a new Bookmark separator somewhere. * Create a new Bookmark separator somewhere.
*/ */

View File

@ -90,7 +90,8 @@ PlacesTreeView.prototype = {
selection.selectEventsSuppressed = true; selection.selectEventsSuppressed = true;
if (!this._rootNode.containerOpen) { if (!this._rootNode.containerOpen) {
// This triggers containerOpened which then builds the visible section. // This triggers containerStateChanged which then builds the visible
// section.
this._rootNode.containerOpen = true; this._rootNode.containerOpen = true;
} }
else else
@ -858,16 +859,10 @@ PlacesTreeView.prototype = {
this._invalidateCellValue(aNode, this.COLUMN_TYPE_LASTMODIFIED); this._invalidateCellValue(aNode, this.COLUMN_TYPE_LASTMODIFIED);
}, },
containerOpened: function PTV_containerOpened(aNode) {
this.invalidateContainer(aNode);
},
containerClosed: function PTV_containerClosed(aNode) {
this.invalidateContainer(aNode);
},
containerStateChanged: containerStateChanged:
function PTV_containerStateChanged(aNode, aOldState, aNewState) {}, function PTV_containerStateChanged(aNode, aOldState, aNewState) {
this.invalidateContainer(aNode);
},
invalidateContainer: function PTV_invalidateContainer(aContainer) { invalidateContainer: function PTV_invalidateContainer(aContainer) {
NS_ASSERT(this._result, "Need to have a result to update"); NS_ASSERT(this._result, "Need to have a result to update");

View File

@ -332,238 +332,6 @@ var PlacesUIUtils = {
return null; return null;
}, },
_reportDeprecatedAddBookmarkMethod:
function PUIU__reportDeprecatedAddBookmarkMethod() {
// Removes "PUIU_".
let oldFuncName = arguments.callee.caller.name.slice(5);
Cu.reportError(oldFuncName + " is deprecated and will be removed in a " +
"future release. Use showBookmarkDialog instead.");
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showAddBookmarkUI: function PUIU_showAddBookmarkUI(
aURI, aTitle, aDescription, aDefaultInsertionPoint, aShowPicker,
aLoadInSidebar, aKeyword, aPostData, aCharSet) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "add",
type: "bookmark"
};
if (aURI)
info.uri = aURI;
// allow default empty title
if (typeof(aTitle) == "string")
info.title = aTitle;
if (aDescription)
info.description = aDescription;
if (aDefaultInsertionPoint) {
info.defaultInsertionPoint = aDefaultInsertionPoint;
if (!aShowPicker)
info.hiddenRows = ["folderPicker"];
}
if (aLoadInSidebar)
info.loadBookmarkInSidebar = true;
if (typeof(aKeyword) == "string") {
info.keyword = aKeyword;
if (typeof(aPostData) == "string")
info.postData = aPostData;
if (typeof(aCharSet) == "string")
info.charSet = aCharSet;
}
return this.showBookmarkDialog(info);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showMinimalAddBookmarkUI:
function PUIU_showMinimalAddBookmarkUI(
aURI, aTitle, aDescription, aDefaultInsertionPoint, aShowPicker,
aLoadInSidebar, aKeyword, aPostData, aCharSet) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "add",
type: "bookmark",
hiddenRows: ["description"]
};
if (aURI)
info.uri = aURI;
// allow default empty title
if (typeof(aTitle) == "string")
info.title = aTitle;
if (aDescription)
info.description = aDescription;
if (aDefaultInsertionPoint) {
info.defaultInsertionPoint = aDefaultInsertionPoint;
if (!aShowPicker)
info.hiddenRows.push("folderPicker");
}
if (aLoadInSidebar)
info.loadBookmarkInSidebar = true;
else
info.hiddenRows = info.hiddenRows.concat(["location", "loadInSidebar"]);
if (typeof(aKeyword) == "string") {
info.keyword = aKeyword;
// Hide the Tags field if we are adding a keyword.
info.hiddenRows.push("tags");
// Keyword related params.
if (typeof(aPostData) == "string")
info.postData = aPostData;
if (typeof(aCharSet) == "string")
info.charSet = aCharSet;
}
else
info.hiddenRows.push("keyword");
return this.showBookmarkDialog(info, undefined, true);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showAddLivemarkUI: function PUIU_showAddLivemarkURI(aFeedURI,
aSiteURI,
aTitle,
aDescription,
aDefaultInsertionPoint,
aShowPicker) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "add",
type: "livemark"
};
if (aFeedURI)
info.feedURI = aFeedURI;
if (aSiteURI)
info.siteURI = aSiteURI;
// allow default empty title
if (typeof(aTitle) == "string")
info.title = aTitle;
if (aDescription)
info.description = aDescription;
if (aDefaultInsertionPoint) {
info.defaultInsertionPoint = aDefaultInsertionPoint;
if (!aShowPicker)
info.hiddenRows = ["folderPicker"];
}
return this.showBookmarkDialog(info);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showMinimalAddLivemarkUI:
function PUIU_showMinimalAddLivemarkURI(
aFeedURI, aSiteURI, aTitle, aDescription, aDefaultInsertionPoint,
aShowPicker) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "add",
type: "livemark",
hiddenRows: ["feedLocation", "siteLocation", "description"]
};
if (aFeedURI)
info.feedURI = aFeedURI;
if (aSiteURI)
info.siteURI = aSiteURI;
// allow default empty title
if (typeof(aTitle) == "string")
info.title = aTitle;
if (aDescription)
info.description = aDescription;
if (aDefaultInsertionPoint) {
info.defaultInsertionPoint = aDefaultInsertionPoint;
if (!aShowPicker)
info.hiddenRows.push("folderPicker");
}
return this.showBookmarkDialog(info, undefined, true);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showMinimalAddMultiBookmarkUI: function PUIU_showAddMultiBookmarkUI(aURIList) {
this._reportDeprecatedAddBookmarkMethod();
if (aURIList.length == 0)
throw("showAddMultiBookmarkUI expects a list of nsIURI objects");
var info = {
action: "add",
type: "folder",
hiddenRows: ["description"],
URIList: aURIList
};
return this.showBookmarkDialog(info, undefined, true);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showItemProperties: function PUIU_showItemProperties(aItemId, aType, aReadOnly) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "edit",
type: aType,
itemId: aItemId,
readOnly: aReadOnly
};
return this.showBookmarkDialog(info);
},
/**
* This is here for compatibility reasons, use ShowBookmarkDialog instead.
*/
showAddFolderUI:
function PUIU_showAddFolderUI(aTitle, aDefaultInsertionPoint, aShowPicker) {
this._reportDeprecatedAddBookmarkMethod();
var info = {
action: "add",
type: "folder",
hiddenRows: []
};
// allow default empty title
if (typeof(aTitle) == "string")
info.title = aTitle;
if (aDefaultInsertionPoint) {
info.defaultInsertionPoint = aDefaultInsertionPoint;
if (!aShowPicker)
info.hiddenRows.push("folderPicker");
}
return this.showBookmarkDialog(info);
},
/** /**
* Shows the bookmark dialog corresponding to the specified info. * Shows the bookmark dialog corresponding to the specified info.
* *

View File

@ -229,6 +229,7 @@ greprefs/xpinstall.js
install.rdf install.rdf
modules/ISO8601DateUtils.jsm modules/ISO8601DateUtils.jsm
modules/JSON.jsm modules/JSON.jsm
modules/utils.js
mozilla-runtime@BIN_SUFFIX@ mozilla-runtime@BIN_SUFFIX@
old-homepage-default.properties old-homepage-default.properties
README.txt README.txt
@ -997,7 +998,6 @@ xpicleanup@BIN_SUFFIX@
modules/tabview/AllTabs.jsm modules/tabview/AllTabs.jsm
modules/tabview/groups.jsm modules/tabview/groups.jsm
modules/tabview/utils.jsm modules/tabview/utils.jsm
modules/utils.js
modules/WindowDraggingUtils.jsm modules/WindowDraggingUtils.jsm
#ifdef XP_WIN #ifdef XP_WIN
modules/WindowsJumpLists.jsm modules/WindowsJumpLists.jsm

View File

@ -118,7 +118,6 @@ endif
EXTRA_JS_MODULES = \ EXTRA_JS_MODULES = \
PlacesDBUtils.jsm \ PlacesDBUtils.jsm \
utils.js \
$(NULL) $(NULL)
EXTRA_PP_JS_MODULES = \ EXTRA_PP_JS_MODULES = \

View File

@ -461,7 +461,7 @@ interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
* according to history and bookmark system events. Register this observer on a * according to history and bookmark system events. Register this observer on a
* result using nsINavHistoryResult::addObserver. * result using nsINavHistoryResult::addObserver.
*/ */
[scriptable, uuid(9ea86387-6a30-4ee2-b70d-26fbb718902f)] [scriptable, uuid(547102c4-ab84-4058-b9d4-6f99f6c80893)]
interface nsINavHistoryResultObserver : nsISupports interface nsINavHistoryResultObserver : nsISupports
{ {
/** /**
@ -618,30 +618,6 @@ interface nsINavHistoryResultObserver : nsISupports
in nsINavHistoryResultNode aNewNode, in nsINavHistoryResultNode aNewNode,
in unsigned long aIndex); in unsigned long aIndex);
/**
* Called after a container node went from closed to opened.
*
* @note This method is DEPRECATED. In the future only containerStateChanged
* will notify when a container is opened.
*
* @param aContainerNode
* the container node which was opened
*/
void containerOpened(in nsINavHistoryContainerResultNode aContainerNode);
/**
* Called after a container node went from opened to closed. This will be
* called for the topmost container that is closing, and implies that any
* child containers have closed as well.
*
* @note This method is DEPRECATED. In the future only containerStateChanged
* will notify when a container is closed.
*
* @param aContainerNode
* the container node which was closed
*/
void containerClosed(in nsINavHistoryContainerResultNode aContainerNode);
/** /**
* Called after a container changes state. * Called after a container changes state.
* *

View File

@ -628,13 +628,6 @@ nsNavHistoryContainerResultNode::NotifyOnStateChange(PRUint16 aOldState)
// Notify via the new ContainerStateChanged observer method. // Notify via the new ContainerStateChanged observer method.
NOTIFY_RESULT_OBSERVERS(result, NOTIFY_RESULT_OBSERVERS(result,
ContainerStateChanged(this, aOldState, currState)); ContainerStateChanged(this, aOldState, currState));
// Notify via the deprecated observer methods.
if (currState == STATE_OPENED)
NOTIFY_RESULT_OBSERVERS(result, ContainerOpened(this));
else if (currState == STATE_CLOSED)
NOTIFY_RESULT_OBSERVERS(result, ContainerClosed(this));
return NS_OK; return NS_OK;
} }

View File

@ -242,8 +242,6 @@ Test.prototype = {
do_throw(err); do_throw(err);
} }
}, },
containerOpened: function (container) {},
containerClosed: function (container) {}
}; };
this.result.addObserver(this.observer, false); this.result.addObserver(this.observer, false);

View File

@ -94,14 +94,15 @@ var resultObserver = {
this.movedNode = node; this.movedNode = node;
}, },
openedContainer: null, openedContainer: null,
containerOpened: function(node) {
this.openedContainer = node;
},
closedContainer: null, closedContainer: null,
containerClosed: function(node) { containerStateChanged: function (aNode, aOldState, aNewState) {
this.closedContainer = node; if (aNewState == Ci.nsINavHistoryContainerResultNode.STATE_OPENED) {
this.openedContainer = aNode;
}
else if (aNewState == Ci.nsINavHistoryContainerResultNode.STATE_CLOSED) {
this.closedContainer = aNode;
}
}, },
containerStateChanged: function (node, oldState, newState) {},
invalidatedContainer: null, invalidatedContainer: null,
invalidateContainer: function(node) { invalidateContainer: function(node) {
this.invalidatedContainer = node; this.invalidatedContainer = node;

View File

@ -1,21 +0,0 @@
/*
* This is a mock file pointing to PlacesUtils.jsm for add-ons backwards
* compatibility.
*
* If you are importing this file, you should instead import PlacesUtils.jsm.
* If you need to support different versions of toolkit, then you can use the
* following code to import PlacesUtils in your scope.
*
* Try {
* Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
* } catch (ex) {
* Components.utils.import("resource://gre/modules/utils.js");
* }
*
*/
var EXPORTED_SYMBOLS = ["PlacesUtils"];
Components.utils.reportError('An add-on is importing utils.js module, this file is deprecated, PlacesUtils.jsm should be used instead. Please notify add-on author of this problem.');
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");