зеркало из https://github.com/mozilla/gecko-dev.git
Bug 556739 - Part4: PlacesUIUtils should be a module instead. r=dietrich
--HG-- rename : browser/components/places/content/utils.js => browser/components/places/src/PlacesUIUtils.jsm rename : browser/components/places/tests/chrome/test_bug510634.xul => browser/components/places/tests/chrome/test_0_bug510634.xul rename : browser/components/places/tests/chrome/test_multiple_left_pane.xul => browser/components/places/tests/chrome/test_0_multiple_left_pane.xul
This commit is contained in:
Родитель
db0525f091
Коммит
96b1a35cc4
|
@ -75,10 +75,12 @@
|
|||
#ifdef CRH_DIALOG_TREE_VIEW
|
||||
<script type="application/javascript"
|
||||
src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/places/utils.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/places/treeView.js"/>
|
||||
<script type="application/javascript"><![CDATA[
|
||||
Components.utils.import("resource://gre/modules/utils.js");
|
||||
Components.utils.import("resource://gre/modules/PlacesUIUtils.jsm");
|
||||
]]></script>
|
||||
#endif
|
||||
|
||||
<script type="application/javascript"
|
||||
|
|
|
@ -279,7 +279,7 @@ var BookmarkPropertiesPanel = {
|
|||
// Load In Sidebar
|
||||
this._loadInSidebar = PlacesUtils.annotations
|
||||
.itemHasAnnotation(this._itemId,
|
||||
LOAD_IN_SIDEBAR_ANNO);
|
||||
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
|
||||
break;
|
||||
|
||||
case "folder":
|
||||
|
@ -295,10 +295,10 @@ var BookmarkPropertiesPanel = {
|
|||
|
||||
// Description
|
||||
if (PlacesUtils.annotations
|
||||
.itemHasAnnotation(this._itemId, DESCRIPTION_ANNO)) {
|
||||
.itemHasAnnotation(this._itemId, PlacesUIUtils.DESCRIPTION_ANNO)) {
|
||||
this._description = PlacesUtils.annotations
|
||||
.getItemAnnotation(this._itemId,
|
||||
DESCRIPTION_ANNO);
|
||||
PlacesUIUtils.DESCRIPTION_ANNO);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -114,6 +114,9 @@ InsertionPoint.prototype = {
|
|||
|
||||
function PlacesController(aView) {
|
||||
this._view = aView;
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "clipboard",
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
"nsIClipboard");
|
||||
}
|
||||
|
||||
PlacesController.prototype = {
|
||||
|
@ -389,7 +392,7 @@ PlacesController.prototype = {
|
|||
// pasteable, with no need to unwrap all the nodes.
|
||||
|
||||
var flavors = PlacesControllerDragHelper.placesFlavors;
|
||||
var clipboard = PlacesUIUtils.clipboard;
|
||||
var clipboard = this.clipboard;
|
||||
var hasPlacesData =
|
||||
clipboard.hasDataMatchingFlavors(flavors, flavors.length,
|
||||
Ci.nsIClipboard.kGlobalClipboard);
|
||||
|
@ -1216,7 +1219,7 @@ PlacesController.prototype = {
|
|||
addData(PlacesUtils.TYPE_HTML, htmlString);
|
||||
|
||||
if (placeString || unicodeString || htmlString || mozURLString) {
|
||||
PlacesUIUtils.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
this.clipboard.setData(xferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -1260,7 +1263,7 @@ PlacesController.prototype = {
|
|||
return xferable;
|
||||
}
|
||||
|
||||
var clipboard = PlacesUIUtils.clipboard;
|
||||
var clipboard = this.clipboard;
|
||||
|
||||
var ip = this._view.insertionPoint;
|
||||
if (!ip)
|
||||
|
|
|
@ -174,7 +174,7 @@ var gEditItemOverlay = {
|
|||
// Load In Sidebar checkbox
|
||||
this._element("loadInSidebarCheckbox").checked =
|
||||
PlacesUtils.annotations.itemHasAnnotation(this._itemId,
|
||||
LOAD_IN_SIDEBAR_ANNO);
|
||||
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
|
||||
}
|
||||
else {
|
||||
if (!this._readOnly) // If readOnly wasn't forced through aInfo
|
||||
|
@ -458,6 +458,7 @@ var gEditItemOverlay = {
|
|||
// content types the service knows how to summarize).
|
||||
this._microsummaries = null;
|
||||
}
|
||||
|
||||
if (this._microsummaries) {
|
||||
var enumerator = this._microsummaries.Enumerate();
|
||||
|
||||
|
@ -1122,14 +1123,14 @@ var gEditItemOverlay = {
|
|||
PlacesUtils.bookmarks
|
||||
.getKeywordForBookmark(this._itemId));
|
||||
break;
|
||||
case DESCRIPTION_ANNO:
|
||||
case PlacesUIUtils.DESCRIPTION_ANNO:
|
||||
this._initTextField("descriptionField",
|
||||
PlacesUIUtils.getItemDescription(this._itemId));
|
||||
break;
|
||||
case LOAD_IN_SIDEBAR_ANNO:
|
||||
case PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO:
|
||||
this._element("loadInSidebarCheckbox").checked =
|
||||
PlacesUtils.annotations.itemHasAnnotation(this._itemId,
|
||||
LOAD_IN_SIDEBAR_ANNO);
|
||||
PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
|
||||
break;
|
||||
case PlacesUtils.LMANNO_FEEDURI:
|
||||
var feedURISpec = PlacesUtils.livemarks.getFeedURI(this._itemId).spec;
|
||||
|
|
|
@ -1324,7 +1324,7 @@ var ViewMenu = {
|
|||
lastModified: { key: "LASTMODIFIED", dir: "descending" },
|
||||
description: { key: "ANNOTATION",
|
||||
dir: "ascending",
|
||||
anno: DESCRIPTION_ANNO }
|
||||
anno: PlacesUIUtils.DESCRIPTION_ANNO }
|
||||
};
|
||||
|
||||
// Make sure we have a valid column.
|
||||
|
|
|
@ -51,8 +51,16 @@
|
|||
src="chrome://global/content/globalOverlay.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/utilityOverlay.js"/>
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/places/utils.js"/>
|
||||
<script type="application/javascript"><![CDATA[
|
||||
// TODO: Bug 406371.
|
||||
// A bunch of browser code depends on us defining these, sad but true :(
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cr = Components.results;
|
||||
|
||||
Components.utils.import("resource://gre/modules/utils.js");
|
||||
Components.utils.import("resource://gre/modules/PlacesUIUtils.jsm");
|
||||
]]></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://browser/content/places/controller.js"/>
|
||||
<script type="application/javascript"
|
||||
|
|
|
@ -570,11 +570,11 @@ PlacesTreeView.prototype = {
|
|||
case Ci.nsINavHistoryQueryOptions.SORT_BY_KEYWORD_DESCENDING:
|
||||
return [this.COLUMN_TYPE_KEYWORD, true];
|
||||
case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_ASCENDING:
|
||||
if (this._result.sortingAnnotation == DESCRIPTION_ANNO)
|
||||
if (this._result.sortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
|
||||
return [this.COLUMN_TYPE_DESCRIPTION, false];
|
||||
break;
|
||||
case Ci.nsINavHistoryQueryOptions.SORT_BY_ANNOTATION_DESCENDING:
|
||||
if (this._result.sortingAnnotation == DESCRIPTION_ANNO)
|
||||
if (this._result.sortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
|
||||
return [this.COLUMN_TYPE_DESCRIPTION, true];
|
||||
case Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_ASCENDING:
|
||||
return [this.COLUMN_TYPE_DATEADDED, false];
|
||||
|
@ -827,7 +827,7 @@ PlacesTreeView.prototype = {
|
|||
},
|
||||
|
||||
nodeAnnotationChanged: function PTV_nodeAnnotationChanged(aNode, aAnno) {
|
||||
if (aAnno == DESCRIPTION_ANNO)
|
||||
if (aAnno == PlacesUIUtils.DESCRIPTION_ANNO)
|
||||
this._invalidateCellValue(aNode, this.COLUMN_TYPE_DESCRIPTION);
|
||||
},
|
||||
|
||||
|
@ -1338,7 +1338,7 @@ PlacesTreeView.prototype = {
|
|||
if (node.itemId != -1) {
|
||||
try {
|
||||
return PlacesUtils.annotations.
|
||||
getItemAnnotation(node.itemId, DESCRIPTION_ANNO);
|
||||
getItemAnnotation(node.itemId, PlacesUIUtils.DESCRIPTION_ANNO);
|
||||
}
|
||||
catch (ex) { /* has no description */ }
|
||||
}
|
||||
|
@ -1472,17 +1472,17 @@ PlacesTreeView.prototype = {
|
|||
break;
|
||||
case this.COLUMN_TYPE_DESCRIPTION:
|
||||
if (oldSort == NHQO.SORT_BY_ANNOTATION_ASCENDING &&
|
||||
oldSortingAnnotation == DESCRIPTION_ANNO) {
|
||||
oldSortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO) {
|
||||
newSort = NHQO.SORT_BY_ANNOTATION_DESCENDING;
|
||||
newSortingAnnotation = DESCRIPTION_ANNO;
|
||||
newSortingAnnotation = PlacesUIUtils.DESCRIPTION_ANNO;
|
||||
}
|
||||
else if (allowTriState &&
|
||||
oldSort == NHQO.SORT_BY_ANNOTATION_DESCENDING &&
|
||||
oldSortingAnnotation == DESCRIPTION_ANNO)
|
||||
oldSortingAnnotation == PlacesUIUtils.DESCRIPTION_ANNO)
|
||||
newSort = NHQO.SORT_BY_NONE;
|
||||
else {
|
||||
newSort = NHQO.SORT_BY_ANNOTATION_ASCENDING;
|
||||
newSortingAnnotation = DESCRIPTION_ANNO;
|
||||
newSortingAnnotation = PlacesUIUtils.DESCRIPTION_ANNO;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,6 @@ browser.jar:
|
|||
* content/browser/places/toolbar.xml (content/toolbar.xml)
|
||||
* content/browser/places/menu.xml (content/menu.xml)
|
||||
* content/browser/places/tree.xml (content/tree.xml)
|
||||
* content/browser/places/utils.js (content/utils.js)
|
||||
* content/browser/places/controller.js (content/controller.js)
|
||||
* content/browser/places/treeView.js (content/treeView.js)
|
||||
# keep the Places version of the history sidebar at history/history-panel.xul
|
||||
|
|
|
@ -49,6 +49,10 @@ EXTRA_COMPONENTS = \
|
|||
PlacesProtocolHandler.js \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_JS_MODULES = \
|
||||
PlacesUIUtils.jsm \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
XPIDL_FLAGS += -I$(topsrcdir)/browser/components
|
||||
|
|
|
@ -40,27 +40,24 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
function LOG(str) {
|
||||
dump("*** " + str + "\n");
|
||||
}
|
||||
var EXPORTED_SYMBOLS = ["PlacesUIUtils"];
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
|
||||
__defineGetter__("PlacesUtils", function() {
|
||||
delete this.PlacesUtils
|
||||
var tmpScope = {};
|
||||
Components.utils.import("resource://gre/modules/utils.js", tmpScope);
|
||||
return this.PlacesUtils = tmpScope.PlacesUtils;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "Services", function() {
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
return Services;
|
||||
});
|
||||
|
||||
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
|
||||
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
||||
|
||||
const ORGANIZER_FOLDER_ANNO = "PlacesOrganizer/OrganizerFolder";
|
||||
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
|
||||
const ORGANIZER_LEFTPANE_VERSION = 6;
|
||||
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
|
||||
Cu.import("resource://gre/modules/utils.js");
|
||||
return PlacesUtils;
|
||||
});
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
// On Mac OSX, the transferable system converts "\r\n" to "\n\n", where we
|
||||
|
@ -72,48 +69,12 @@ const NEWLINE = "\r\n";
|
|||
#endif
|
||||
|
||||
var PlacesUIUtils = {
|
||||
get RDF() {
|
||||
delete this.RDF;
|
||||
return this.RDF = Cc["@mozilla.org/rdf/rdf-service;1"].
|
||||
getService(Ci.nsIRDFService);
|
||||
},
|
||||
ORGANIZER_LEFTPANE_VERSION: 6,
|
||||
ORGANIZER_FOLDER_ANNO: "PlacesOrganizer/OrganizerFolder",
|
||||
ORGANIZER_QUERY_ANNO: "PlacesOrganizer/OrganizerQuery",
|
||||
|
||||
get localStore() {
|
||||
delete this.localStore;
|
||||
return this.localStore = this.RDF.GetDataSource("rdf:local-store");
|
||||
},
|
||||
|
||||
get ptm() {
|
||||
delete this.ptm;
|
||||
return this.ptm = Cc["@mozilla.org/browser/placesTransactionsService;1"].
|
||||
getService(Ci.nsIPlacesTransactionsService);
|
||||
},
|
||||
|
||||
get clipboard() {
|
||||
delete this.clipboard;
|
||||
return this.clipboard = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
},
|
||||
|
||||
get URIFixup() {
|
||||
delete this.URIFixup;
|
||||
return this.URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].
|
||||
getService(Ci.nsIURIFixup);
|
||||
},
|
||||
|
||||
get ellipsis() {
|
||||
delete this.ellipsis;
|
||||
var pref = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
return this.ellipsis = pref.getComplexValue("intl.ellipsis",
|
||||
Ci.nsIPrefLocalizedString).data;
|
||||
},
|
||||
|
||||
get privateBrowsing() {
|
||||
delete this.privateBrowsing;
|
||||
return this.privateBrowsing = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
},
|
||||
LOAD_IN_SIDEBAR_ANNO: "bookmarkProperties/loadInSidebar",
|
||||
DESCRIPTION_ANNO: "bookmarkProperties/description",
|
||||
|
||||
/**
|
||||
* Makes a URI from a spec, and do fixup
|
||||
|
@ -121,7 +82,7 @@ var PlacesUIUtils = {
|
|||
* The string spec of the URI
|
||||
* @returns A URI object for the spec.
|
||||
*/
|
||||
createFixedURI: function PU_createFixedURI(aSpec) {
|
||||
createFixedURI: function PUIU_createFixedURI(aSpec) {
|
||||
return this.URIFixup.createFixupURI(aSpec, 0);
|
||||
},
|
||||
|
||||
|
@ -131,30 +92,18 @@ var PlacesUIUtils = {
|
|||
* The string to wrap
|
||||
* @returns A nsISupportsString object containing a string.
|
||||
*/
|
||||
_wrapString: function PU__wrapString(aString) {
|
||||
_wrapString: function PUIU__wrapString(aString) {
|
||||
var s = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
s.data = aString;
|
||||
return s;
|
||||
},
|
||||
|
||||
/**
|
||||
* String bundle helpers
|
||||
*/
|
||||
get _bundle() {
|
||||
const PLACES_STRING_BUNDLE_URI =
|
||||
"chrome://browser/locale/places/places.properties";
|
||||
delete this._bundle;
|
||||
return this._bundle = Cc["@mozilla.org/intl/stringbundle;1"].
|
||||
getService(Ci.nsIStringBundleService).
|
||||
createBundle(PLACES_STRING_BUNDLE_URI);
|
||||
},
|
||||
|
||||
getFormattedString: function PU_getFormattedString(key, params) {
|
||||
getFormattedString: function PUIU_getFormattedString(key, params) {
|
||||
return this._bundle.formatStringFromName(key, params, params.length);
|
||||
},
|
||||
|
||||
getString: function PU_getString(key) {
|
||||
getString: function PUIU_getString(key) {
|
||||
return this._bundle.GetStringFromName(key);
|
||||
},
|
||||
|
||||
|
@ -189,7 +138,7 @@ var PlacesUIUtils = {
|
|||
* @returns A nsITransaction object that performs the copy.
|
||||
*/
|
||||
_getBookmarkItemCopyTransaction:
|
||||
function PU__getBookmarkItemCopyTransaction(aData, aContainer, aIndex,
|
||||
function PUIU__getBookmarkItemCopyTransaction(aData, aContainer, aIndex,
|
||||
aExcludeAnnotations) {
|
||||
var itemURL = PlacesUtils._uri(aData.uri);
|
||||
var itemTitle = aData.title;
|
||||
|
@ -236,8 +185,7 @@ var PlacesUIUtils = {
|
|||
* @returns A nsITransaction object that will perform the copy.
|
||||
*/
|
||||
_getFolderCopyTransaction:
|
||||
function PU__getFolderCopyTransaction(aData, aContainer, aIndex) {
|
||||
var self = this;
|
||||
function PUIU__getFolderCopyTransaction(aData, aContainer, aIndex) {
|
||||
function getChildItemsTransactions(aChildren) {
|
||||
var childItemsTransactions = [];
|
||||
var cc = aChildren.length;
|
||||
|
@ -254,18 +202,19 @@ var PlacesUIUtils = {
|
|||
|
||||
if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) {
|
||||
if (node.livemark && node.annos) // node is a livemark
|
||||
txn = self._getLivemarkCopyTransaction(node, aContainer, index);
|
||||
txn = PlacesUIUtils._getLivemarkCopyTransaction(node, aContainer, index);
|
||||
else
|
||||
txn = self._getFolderCopyTransaction(node, aContainer, index);
|
||||
txn = PlacesUIUtils._getFolderCopyTransaction(node, aContainer, index);
|
||||
}
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE_SEPARATOR)
|
||||
txn = self.ptm.createSeparator(-1, index);
|
||||
txn = PlacesUIUtils.ptm.createSeparator(-1, index);
|
||||
else if (node.type == PlacesUtils.TYPE_X_MOZ_PLACE)
|
||||
txn = self._getBookmarkItemCopyTransaction(node, -1, index);
|
||||
txn = PlacesUIUtils._getBookmarkItemCopyTransaction(node, -1, index);
|
||||
|
||||
NS_ASSERT(txn, "Unexpected item under a bookmarks folder");
|
||||
if (txn)
|
||||
childItemsTransactions.push(txn);
|
||||
else
|
||||
throw("Unexpected item under a bookmarks folder");
|
||||
}
|
||||
return childItemsTransactions;
|
||||
}
|
||||
|
@ -301,8 +250,9 @@ var PlacesUIUtils = {
|
|||
},
|
||||
|
||||
_getLivemarkCopyTransaction:
|
||||
function PU__getLivemarkCopyTransaction(aData, aContainer, aIndex) {
|
||||
NS_ASSERT(aData.livemark && aData.annos, "node is not a livemark");
|
||||
function PUIU__getLivemarkCopyTransaction(aData, aContainer, aIndex) {
|
||||
if (!aData.livemark || !aData.annos)
|
||||
throw("node is not a livemark");
|
||||
// Place is a Livemark Container
|
||||
var feedURI = null;
|
||||
var siteURI = null;
|
||||
|
@ -338,7 +288,7 @@ var PlacesUIUtils = {
|
|||
* @returns An object implementing nsITransaction that can perform
|
||||
* the move/insert.
|
||||
*/
|
||||
makeTransaction: function PU_makeTransaction(data, type, container,
|
||||
makeTransaction: function PUIU_makeTransaction(data, type, container,
|
||||
index, copy) {
|
||||
switch (data.type) {
|
||||
case PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||
|
@ -421,7 +371,7 @@ var PlacesUIUtils = {
|
|||
* - When aDefaultInsertionPoint is not set, the dialog defaults to the
|
||||
* bookmarks root folder.
|
||||
*/
|
||||
showAddBookmarkUI: function PU_showAddBookmarkUI(aURI,
|
||||
showAddBookmarkUI: function PUIU_showAddBookmarkUI(aURI,
|
||||
aTitle,
|
||||
aDescription,
|
||||
aDefaultInsertionPoint,
|
||||
|
@ -477,7 +427,7 @@ var PlacesUIUtils = {
|
|||
* was used.
|
||||
*/
|
||||
showMinimalAddBookmarkUI:
|
||||
function PU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription,
|
||||
function PUIU_showMinimalAddBookmarkUI(aURI, aTitle, aDescription,
|
||||
aDefaultInsertionPoint, aShowPicker,
|
||||
aLoadInSidebar, aKeyword, aPostData,
|
||||
aCharSet) {
|
||||
|
@ -520,7 +470,7 @@ var PlacesUIUtils = {
|
|||
else
|
||||
info.hiddenRows.push("keyword");
|
||||
|
||||
this._showBookmarkDialog(info, true);
|
||||
return this._showBookmarkDialog(info, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -545,7 +495,7 @@ var PlacesUIUtils = {
|
|||
* - When aDefaultInsertionPoint is not set, the dialog defaults to the
|
||||
* bookmarks root folder.
|
||||
*/
|
||||
showAddLivemarkUI: function PU_showAddLivemarkURI(aFeedURI,
|
||||
showAddLivemarkUI: function PUIU_showAddLivemarkURI(aFeedURI,
|
||||
aSiteURI,
|
||||
aTitle,
|
||||
aDescription,
|
||||
|
@ -585,7 +535,7 @@ var PlacesUIUtils = {
|
|||
* for the new live-bookmark.
|
||||
*/
|
||||
showMinimalAddLivemarkUI:
|
||||
function PU_showMinimalAddLivemarkURI(aFeedURI, aSiteURI, aTitle,
|
||||
function PUIU_showMinimalAddLivemarkURI(aFeedURI, aSiteURI, aTitle,
|
||||
aDescription, aDefaultInsertionPoint,
|
||||
aShowPicker) {
|
||||
var info = {
|
||||
|
@ -611,7 +561,7 @@ var PlacesUIUtils = {
|
|||
if (!aShowPicker)
|
||||
info.hiddenRows.push("folderPicker");
|
||||
}
|
||||
this._showBookmarkDialog(info, true);
|
||||
return this._showBookmarkDialog(info, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -623,16 +573,16 @@ var PlacesUIUtils = {
|
|||
* to be bookmarked.
|
||||
* @return true if any transaction has been performed.
|
||||
*/
|
||||
showMinimalAddMultiBookmarkUI: function PU_showAddMultiBookmarkUI(aURIList) {
|
||||
NS_ASSERT(aURIList.length,
|
||||
"showAddMultiBookmarkUI expects a list of nsIURI objects");
|
||||
showMinimalAddMultiBookmarkUI: function PUIU_showAddMultiBookmarkUI(aURIList) {
|
||||
if (aURIList.length == 0)
|
||||
throw("showAddMultiBookmarkUI expects a list of nsIURI objects");
|
||||
var info = {
|
||||
action: "add",
|
||||
type: "folder",
|
||||
hiddenRows: ["description"],
|
||||
URIList: aURIList
|
||||
};
|
||||
this._showBookmarkDialog(info, true);
|
||||
return this._showBookmarkDialog(info, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -646,7 +596,7 @@ var PlacesUIUtils = {
|
|||
* states if properties dialog should be readonly
|
||||
* @return true if any transaction has been performed.
|
||||
*/
|
||||
showItemProperties: function PU_showItemProperties(aItemId, aType, aReadOnly) {
|
||||
showItemProperties: function PUIU_showItemProperties(aItemId, aType, aReadOnly) {
|
||||
var info = {
|
||||
action: "edit",
|
||||
type: aType,
|
||||
|
@ -671,7 +621,7 @@ var PlacesUIUtils = {
|
|||
* @return true if any transaction has been performed.
|
||||
*/
|
||||
showAddFolderUI:
|
||||
function PU_showAddFolderUI(aTitle, aDefaultInsertionPoint, aShowPicker) {
|
||||
function PUIU_showAddFolderUI(aTitle, aDefaultInsertionPoint, aShowPicker) {
|
||||
var info = {
|
||||
action: "add",
|
||||
type: "folder",
|
||||
|
@ -702,7 +652,7 @@ var PlacesUIUtils = {
|
|||
*
|
||||
* @return true if any transaction has been performed, false otherwise.
|
||||
*/
|
||||
_showBookmarkDialog: function PU__showBookmarkDialog(aInfo, aMinimalUI) {
|
||||
_showBookmarkDialog: function PUIU__showBookmarkDialog(aInfo, aMinimalUI) {
|
||||
var dialogURL = aMinimalUI ?
|
||||
"chrome://browser/content/places/bookmarkProperties2.xul" :
|
||||
"chrome://browser/content/places/bookmarkProperties.xul";
|
||||
|
@ -712,17 +662,25 @@ var PlacesUIUtils = {
|
|||
features = "centerscreen,chrome,dialog,resizable,modal";
|
||||
else
|
||||
features = "centerscreen,chrome,modal,resizable=no";
|
||||
window.openDialog(dialogURL, "", features, aInfo);
|
||||
this._getCurrentActiveWin().openDialog(dialogURL, "", features, aInfo);
|
||||
return ("performed" in aInfo && aInfo.performed);
|
||||
},
|
||||
|
||||
_getTopBrowserWin: function PUIU__getTopBrowserWin() {
|
||||
return Services.wm.getMostRecentWindow("navigator:browser");
|
||||
},
|
||||
|
||||
_getCurrentActiveWin: function PUIU__getCurrentActiveWin() {
|
||||
return this.fm.activeWindow;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the closet ancestor places view for the given DOM node
|
||||
* @param aNode
|
||||
* a DOM node
|
||||
* @return the closet ancestor places view if exists, null otherwsie.
|
||||
*/
|
||||
getViewForNode: function PU_getViewForNode(aNode) {
|
||||
getViewForNode: function PUIU_getViewForNode(aNode) {
|
||||
var node = aNode;
|
||||
|
||||
// the view for a <menu> of which its associated menupopup is a places view,
|
||||
|
@ -750,7 +708,7 @@ var PlacesUIUtils = {
|
|||
* organizer. If this is not called visits will be marked as
|
||||
* TRANSITION_LINK.
|
||||
*/
|
||||
markPageAsTyped: function PU_markPageAsTyped(aURL) {
|
||||
markPageAsTyped: function PUIU_markPageAsTyped(aURL) {
|
||||
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory)
|
||||
.markPageAsTyped(this.createFixedURI(aURL));
|
||||
},
|
||||
|
@ -762,7 +720,7 @@ var PlacesUIUtils = {
|
|||
* personal toolbar, and bookmarks from within the places organizer.
|
||||
* If this is not called visits will be marked as TRANSITION_LINK.
|
||||
*/
|
||||
markPageAsFollowedBookmark: function PU_markPageAsFollowedBookmark(aURL) {
|
||||
markPageAsFollowedBookmark: function PUIU_markPageAsFollowedBookmark(aURL) {
|
||||
PlacesUtils.history.markPageAsFollowedBookmark(this.createFixedURI(aURL));
|
||||
},
|
||||
|
||||
|
@ -772,7 +730,7 @@ var PlacesUIUtils = {
|
|||
* This is actually used to distinguish user-initiated visits in frames
|
||||
* so automatic visits can be correctly ignored.
|
||||
*/
|
||||
markPageAsFollowedLink: function PU_markPageAsUserClicked(aURL) {
|
||||
markPageAsFollowedLink: function PUIU_markPageAsUserClicked(aURL) {
|
||||
PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory)
|
||||
.markPageAsFollowedLink(this.createFixedURI(aURL));
|
||||
},
|
||||
|
@ -785,7 +743,7 @@ var PlacesUIUtils = {
|
|||
* @return true if it's safe to open the node in the browser, false otherwise.
|
||||
*
|
||||
*/
|
||||
checkURLSecurity: function PU_checkURLSecurity(aURINode) {
|
||||
checkURLSecurity: function PUIU_checkURLSecurity(aURINode, aWindow) {
|
||||
if (!PlacesUtils.nodeIsBookmark(aURINode)) {
|
||||
var uri = PlacesUtils._uri(aURINode.uri);
|
||||
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
|
||||
|
@ -794,11 +752,9 @@ var PlacesUIUtils = {
|
|||
getService(Ci.nsIStringBundleService).
|
||||
createBundle(BRANDING_BUNDLE_URI).
|
||||
GetStringFromName("brandShortName");
|
||||
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Ci.nsIPromptService);
|
||||
|
||||
var errorStr = this.getString("load-js-data-url-error");
|
||||
promptService.alert(window, brandShortName, errorStr);
|
||||
Services.prompt.alert(aWindow, brandShortName, errorStr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -813,7 +769,7 @@ var PlacesUIUtils = {
|
|||
* @returns A description string if a META element was discovered with a
|
||||
* "description" or "httpequiv" attribute, empty string otherwise.
|
||||
*/
|
||||
getDescriptionFromDocument: function PU_getDescriptionFromDocument(doc) {
|
||||
getDescriptionFromDocument: function PUIU_getDescriptionFromDocument(doc) {
|
||||
var metaElements = doc.getElementsByTagName("META");
|
||||
for (var i = 0; i < metaElements.length; ++i) {
|
||||
if (metaElements[i].name.toLowerCase() == "description" ||
|
||||
|
@ -831,26 +787,23 @@ var PlacesUIUtils = {
|
|||
* @returns the description of the given item, or an empty string if it is
|
||||
* not set.
|
||||
*/
|
||||
getItemDescription: function PU_getItemDescription(aItemId) {
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(aItemId, DESCRIPTION_ANNO))
|
||||
return PlacesUtils.annotations.getItemAnnotation(aItemId, DESCRIPTION_ANNO);
|
||||
getItemDescription: function PUIU_getItemDescription(aItemId) {
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(aItemId, this.DESCRIPTION_ANNO))
|
||||
return PlacesUtils.annotations.getItemAnnotation(aItemId, this.DESCRIPTION_ANNO);
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Gives the user a chance to cancel loading lots of tabs at once
|
||||
*/
|
||||
_confirmOpenInTabs: function PU__confirmOpenInTabs(numTabsToOpen) {
|
||||
var pref = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
|
||||
const kWarnOnOpenPref = "browser.tabs.warnOnOpen";
|
||||
_confirmOpenInTabs: function PUIU__confirmOpenInTabs(numTabsToOpen) {
|
||||
let pref = Services.prefs;
|
||||
let prompt = Services.prompt;
|
||||
const WARN_ON_OPEN_PREF = "browser.tabs.warnOnOpen";
|
||||
var reallyOpen = true;
|
||||
if (pref.getBoolPref(kWarnOnOpenPref)) {
|
||||
if (numTabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
|
||||
var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
||||
getService(Ci.nsIPromptService);
|
||||
|
||||
if (pref.getBoolPref(WARN_ON_OPEN_PREF)) {
|
||||
if (numTabsToOpen >= pref.getIntPref("browser.tabs.maxOpenBeforeWarn")) {
|
||||
// default to true: if it were false, we wouldn't get this far
|
||||
var warnOnOpen = { value: true };
|
||||
|
||||
|
@ -862,28 +815,32 @@ var PlacesUIUtils = {
|
|||
createBundle(BRANDING_BUNDLE_URI).
|
||||
GetStringFromName("brandShortName");
|
||||
|
||||
var buttonPressed = promptService.confirmEx(window,
|
||||
var buttonPressed = prompt.confirmEx(
|
||||
this._getCurrentActiveWin(),
|
||||
this.getString("tabs.openWarningTitle"),
|
||||
this.getFormattedString(messageKey, [numTabsToOpen, brandShortName]),
|
||||
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
|
||||
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
|
||||
(prompt.BUTTON_TITLE_IS_STRING * prompt.BUTTON_POS_0) +
|
||||
(prompt.BUTTON_TITLE_CANCEL * prompt.BUTTON_POS_1),
|
||||
this.getString(openKey), null, null,
|
||||
this.getFormattedString("tabs.openWarningPromptMeBranded",
|
||||
[brandShortName]), warnOnOpen);
|
||||
[brandShortName]),
|
||||
warnOnOpen
|
||||
);
|
||||
|
||||
reallyOpen = (buttonPressed == 0);
|
||||
// don't set the pref unless they press OK and it's false
|
||||
if (reallyOpen && !warnOnOpen.value)
|
||||
pref.setBoolPref(kWarnOnOpenPref, false);
|
||||
pref.setBoolPref(WARN_ON_OPEN_PREF, false);
|
||||
}
|
||||
}
|
||||
|
||||
return reallyOpen;
|
||||
},
|
||||
|
||||
/** aItemsToOpen needs to be an array of objects of the form:
|
||||
* {uri: string, isBookmark: boolean}
|
||||
*/
|
||||
_openTabset: function PU__openTabset(aItemsToOpen, aEvent) {
|
||||
_openTabset: function PUIU__openTabset(aItemsToOpen, aEvent) {
|
||||
if (!aItemsToOpen.length)
|
||||
return;
|
||||
|
||||
|
@ -898,12 +855,13 @@ var PlacesUIUtils = {
|
|||
urls.push(item.uri);
|
||||
}
|
||||
|
||||
var browserWindow = getTopWin();
|
||||
var browserWindow = this._getTopBrowserWin();
|
||||
var where = browserWindow ?
|
||||
whereToOpenLink(aEvent, false, true) : "window";
|
||||
browserWindow.whereToOpenLink(aEvent, false, true) : "window";
|
||||
if (where == "window") {
|
||||
window.openDialog(getBrowserURL(), "_blank",
|
||||
"chrome,all,dialog=no", urls.join("|"));
|
||||
let win = this._getCurrentActiveWin();
|
||||
win.openDialog(win.getBrowserURL(), "_blank",
|
||||
"chrome,all,dialog=no", urls.join("|"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -912,7 +870,7 @@ var PlacesUIUtils = {
|
|||
browserWindow.gBrowser.loadTabs(urls, loadInBackground, replaceCurrentTab);
|
||||
},
|
||||
|
||||
openContainerNodeInTabs: function PU_openContainerInTabs(aNode, aEvent) {
|
||||
openContainerNodeInTabs: function PUIU_openContainerInTabs(aNode, aEvent) {
|
||||
var urlsToOpen = PlacesUtils.getURLsForContainerNode(aNode);
|
||||
if (!this._confirmOpenInTabs(urlsToOpen.length))
|
||||
return;
|
||||
|
@ -920,7 +878,7 @@ var PlacesUIUtils = {
|
|||
this._openTabset(urlsToOpen, aEvent);
|
||||
},
|
||||
|
||||
openURINodesInTabs: function PU_openURINodesInTabs(aNodes, aEvent) {
|
||||
openURINodesInTabs: function PUIU_openURINodesInTabs(aNodes, aEvent) {
|
||||
var urlsToOpen = [];
|
||||
for (var i=0; i < aNodes.length; i++) {
|
||||
// skip over separators and folders
|
||||
|
@ -940,8 +898,8 @@ var PlacesUIUtils = {
|
|||
* The DOM mouse/key event with modifier keys set that track the
|
||||
* user's preferred destination window or tab.
|
||||
*/
|
||||
openNodeWithEvent: function PU_openNodeWithEvent(aNode, aEvent) {
|
||||
this.openNodeIn(aNode, whereToOpenLink(aEvent));
|
||||
openNodeWithEvent: function PUIU_openNodeWithEvent(aNode, aEvent) {
|
||||
this.openNodeIn(aNode, this._getCurrentActiveWin().whereToOpenLink(aEvent));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -949,9 +907,9 @@ var PlacesUIUtils = {
|
|||
* web panel.
|
||||
* see also openUILinkIn
|
||||
*/
|
||||
openNodeIn: function PU_openNodeIn(aNode, aWhere) {
|
||||
openNodeIn: function PUIU_openNodeIn(aNode, aWhere) {
|
||||
if (aNode && PlacesUtils.nodeIsURI(aNode) &&
|
||||
this.checkURLSecurity(aNode)) {
|
||||
this.checkURLSecurity(aNode, this._getCurrentActiveWin())) {
|
||||
var isBookmark = PlacesUtils.nodeIsBookmark(aNode);
|
||||
|
||||
if (isBookmark)
|
||||
|
@ -963,15 +921,15 @@ var PlacesUIUtils = {
|
|||
// a web panel
|
||||
if (aWhere == "current" && isBookmark) {
|
||||
if (PlacesUtils.annotations
|
||||
.itemHasAnnotation(aNode.itemId, LOAD_IN_SIDEBAR_ANNO)) {
|
||||
var w = getTopWin();
|
||||
if (w) {
|
||||
w.openWebPanel(aNode.title, aNode.uri);
|
||||
.itemHasAnnotation(aNode.itemId, this.LOAD_IN_SIDEBAR_ANNO)) {
|
||||
var browserWin = this._getTopBrowserWin();
|
||||
if (browserWin) {
|
||||
browserWin.openWebPanel(aNode.title, aNode.uri);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
openUILinkIn(aNode.uri, aWhere);
|
||||
this._getCurrentActiveWin().openUILinkIn(aNode.uri, aWhere);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -995,9 +953,11 @@ var PlacesUIUtils = {
|
|||
createMenuItemForNode:
|
||||
function PUU_createMenuItemForNode(aNode) {
|
||||
var element;
|
||||
var document = this._getCurrentActiveWin().document;
|
||||
var type = aNode.type;
|
||||
if (type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR)
|
||||
if (type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR) {
|
||||
element = document.createElement("menuseparator");
|
||||
}
|
||||
else {
|
||||
if (PlacesUtils.uriTypes.indexOf(type) != -1) {
|
||||
element = document.createElement("menuitem");
|
||||
|
@ -1054,7 +1014,7 @@ var PlacesUIUtils = {
|
|||
return element;
|
||||
},
|
||||
|
||||
cleanPlacesPopup: function PU_cleanPlacesPopup(aPopup) {
|
||||
cleanPlacesPopup: function PUIU_cleanPlacesPopup(aPopup) {
|
||||
// Remove places popup children and update markers to keep track of
|
||||
// their indices.
|
||||
var start = aPopup._startMarker != -1 ? aPopup._startMarker + 1 : 0;
|
||||
|
@ -1077,10 +1037,11 @@ var PlacesUIUtils = {
|
|||
}
|
||||
else {
|
||||
// This is static content...
|
||||
if (!placesNodeFound)
|
||||
if (!placesNodeFound) {
|
||||
// ...at the start of the popup
|
||||
// Initialized in menu.xml, in the base binding
|
||||
aPopup._startMarker++;
|
||||
}
|
||||
else {
|
||||
// ...after places nodes
|
||||
aPopup._endMarker = i;
|
||||
|
@ -1096,7 +1057,7 @@ var PlacesUIUtils = {
|
|||
}
|
||||
},
|
||||
|
||||
getBestTitle: function PU_getBestTitle(aNode) {
|
||||
getBestTitle: function PUIU_getBestTitle(aNode) {
|
||||
var title;
|
||||
if (!aNode.title && PlacesUtils.uriTypes.indexOf(aNode.type) != -1) {
|
||||
// if node title is empty, try to set the label using host and filename
|
||||
|
@ -1161,16 +1122,16 @@ var PlacesUIUtils = {
|
|||
// Removes an item and associated annotations, ignoring eventual errors.
|
||||
function safeRemoveItem(aItemId) {
|
||||
try {
|
||||
if (as.itemHasAnnotation(aItemId, ORGANIZER_QUERY_ANNO) &&
|
||||
!(as.getItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO) in queries)) {
|
||||
if (as.itemHasAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO) &&
|
||||
!(as.getItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO) in queries)) {
|
||||
// Some extension annotated their roots with our query annotation,
|
||||
// so we should not delete them.
|
||||
return;
|
||||
}
|
||||
// removeItemAnnotation does not check if item exists, nor the anno,
|
||||
// so this is safe to do.
|
||||
as.removeItemAnnotation(aItemId, ORGANIZER_FOLDER_ANNO);
|
||||
as.removeItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO);
|
||||
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
as.removeItemAnnotation(aItemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO);
|
||||
// This will throw if the annotation is an orphan.
|
||||
bs.removeItem(aItemId);
|
||||
}
|
||||
|
@ -1189,7 +1150,7 @@ var PlacesUIUtils = {
|
|||
}
|
||||
|
||||
// Get all items marked as being the left pane folder.
|
||||
let items = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
let items = as.getItemsWithAnnotation(this.ORGANIZER_FOLDER_ANNO);
|
||||
if (items.length > 1) {
|
||||
// Something went wrong, we cannot have more than one left pane folder,
|
||||
// remove all left pane folders and continue. We will create a new one.
|
||||
|
@ -1197,10 +1158,10 @@ var PlacesUIUtils = {
|
|||
}
|
||||
else if (items.length == 1 && items[0] != -1) {
|
||||
leftPaneRoot = items[0];
|
||||
|
||||
// Check that organizer left pane root is valid.
|
||||
let version = as.getItemAnnotation(leftPaneRoot, ORGANIZER_FOLDER_ANNO);
|
||||
if (version != ORGANIZER_LEFTPANE_VERSION || !itemExists(leftPaneRoot)) {
|
||||
let version = as.getItemAnnotation(leftPaneRoot, this.ORGANIZER_FOLDER_ANNO);
|
||||
if (version != this.ORGANIZER_LEFTPANE_VERSION ||
|
||||
!itemExists(leftPaneRoot)) {
|
||||
// Invalid root, we must rebuild the left pane.
|
||||
safeRemoveItem(leftPaneRoot);
|
||||
leftPaneRoot = -1;
|
||||
|
@ -1214,11 +1175,12 @@ var PlacesUIUtils = {
|
|||
delete this.leftPaneQueries;
|
||||
this.leftPaneQueries = {};
|
||||
|
||||
let items = as.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO);
|
||||
let items = as.getItemsWithAnnotation(this.ORGANIZER_QUERY_ANNO);
|
||||
// While looping through queries we will also check for their validity.
|
||||
let queriesCount = 0;
|
||||
for(let i = 0; i < items.length; i++) {
|
||||
let queryName = as.getItemAnnotation(items[i], ORGANIZER_QUERY_ANNO);
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
let queryName = as.getItemAnnotation(items[i], this.ORGANIZER_QUERY_ANNO);
|
||||
|
||||
// Some extension did use our annotation to decorate their items
|
||||
// with icons, so we should check only our elements, to avoid dataloss.
|
||||
if (!(queryName in queries))
|
||||
|
@ -1269,7 +1231,6 @@ var PlacesUIUtils = {
|
|||
}
|
||||
|
||||
// Create a new left pane folder.
|
||||
var self = this;
|
||||
var callback = {
|
||||
// Helper to create an organizer special query.
|
||||
create_query: function CB_create_query(aQueryName, aParentId, aQueryUrl) {
|
||||
|
@ -1278,13 +1239,13 @@ var PlacesUIUtils = {
|
|||
bs.DEFAULT_INDEX,
|
||||
queries[aQueryName].title);
|
||||
// Mark as special organizer query.
|
||||
as.setItemAnnotation(itemId, ORGANIZER_QUERY_ANNO, aQueryName,
|
||||
as.setItemAnnotation(itemId, PlacesUIUtils.ORGANIZER_QUERY_ANNO, aQueryName,
|
||||
0, as.EXPIRE_NEVER);
|
||||
// We should never backup this, since it changes between profiles.
|
||||
as.setItemAnnotation(itemId, PlacesUtils.EXCLUDE_FROM_BACKUP_ANNO, 1,
|
||||
0, as.EXPIRE_NEVER);
|
||||
// Add to the queries map.
|
||||
self.leftPaneQueries[aQueryName] = itemId;
|
||||
PlacesUIUtils.leftPaneQueries[aQueryName] = itemId;
|
||||
return itemId;
|
||||
},
|
||||
|
||||
|
@ -1302,22 +1263,22 @@ var PlacesUIUtils = {
|
|||
|
||||
if (aIsRoot) {
|
||||
// Mark as special left pane root.
|
||||
as.setItemAnnotation(folderId, ORGANIZER_FOLDER_ANNO,
|
||||
ORGANIZER_LEFTPANE_VERSION,
|
||||
as.setItemAnnotation(folderId, PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
|
||||
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION,
|
||||
0, as.EXPIRE_NEVER);
|
||||
}
|
||||
else {
|
||||
// Mark as special organizer folder.
|
||||
as.setItemAnnotation(folderId, ORGANIZER_QUERY_ANNO, aFolderName,
|
||||
as.setItemAnnotation(folderId, PlacesUIUtils.ORGANIZER_QUERY_ANNO, aFolderName,
|
||||
0, as.EXPIRE_NEVER);
|
||||
self.leftPaneQueries[aFolderName] = folderId;
|
||||
PlacesUIUtils.leftPaneQueries[aFolderName] = folderId;
|
||||
}
|
||||
return folderId;
|
||||
},
|
||||
|
||||
runBatched: function CB_runBatched(aUserData) {
|
||||
delete self.leftPaneQueries;
|
||||
self.leftPaneQueries = { };
|
||||
delete PlacesUIUtils.leftPaneQueries;
|
||||
PlacesUIUtils.leftPaneQueries = { };
|
||||
|
||||
// Left Pane Root Folder.
|
||||
leftPaneRoot = this.create_folder("PlacesRoot", bs.placesRoot, true);
|
||||
|
@ -1377,14 +1338,14 @@ var PlacesUIUtils = {
|
|||
* @param aItemId id of a container
|
||||
* @returns the name of the query, or empty string if not a left-pane query
|
||||
*/
|
||||
getLeftPaneQueryNameFromId: function PU_getLeftPaneQueryNameFromId(aItemId) {
|
||||
getLeftPaneQueryNameFromId: function PUIU_getLeftPaneQueryNameFromId(aItemId) {
|
||||
var queryName = "";
|
||||
// If the let pane hasn't been built, use the annotation service
|
||||
// directly, to avoid building the left pane too early.
|
||||
if (this.__lookupGetter__("leftPaneFolderId")) {
|
||||
try {
|
||||
queryName = PlacesUtils.annotations.
|
||||
getItemAnnotation(aItemId, ORGANIZER_QUERY_ANNO);
|
||||
getItemAnnotation(aItemId, this.ORGANIZER_QUERY_ANNO);
|
||||
}
|
||||
catch (ex) {
|
||||
// doesn't have the annotation
|
||||
|
@ -1408,7 +1369,7 @@ var PlacesUIUtils = {
|
|||
* The livemark container popup
|
||||
*/
|
||||
ensureLivemarkStatusMenuItem:
|
||||
function PU_ensureLivemarkStatusMenuItem(aPopup) {
|
||||
function PUIU_ensureLivemarkStatusMenuItem(aPopup) {
|
||||
var itemId = aPopup._resultNode.itemId;
|
||||
|
||||
var lmStatus = null;
|
||||
|
@ -1421,6 +1382,7 @@ var PlacesUIUtils = {
|
|||
|
||||
if (lmStatus && !aPopup._lmStatusMenuItem) {
|
||||
// Create the status menuitem and cache it in the popup object.
|
||||
let document = this._getCurrentActiveWin().document;
|
||||
aPopup._lmStatusMenuItem = document.createElement("menuitem");
|
||||
aPopup._lmStatusMenuItem.setAttribute("lmStatus", lmStatus);
|
||||
aPopup._lmStatusMenuItem.setAttribute("label", this.getString(lmStatus));
|
||||
|
@ -1443,3 +1405,40 @@ var PlacesUIUtils = {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "RDF",
|
||||
"@mozilla.org/rdf/rdf-service;1",
|
||||
"nsIRDFService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "localStore", function() {
|
||||
return PlacesUIUtils.RDF.GetDataSource("rdf:local-store");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "ptm",
|
||||
"@mozilla.org/browser/placesTransactionsService;1",
|
||||
"nsIPlacesTransactionsService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "URIFixup",
|
||||
"@mozilla.org/docshell/urifixup;1",
|
||||
"nsIURIFixup");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() {
|
||||
return Services.prefs.getComplexValue("intl.ellipsis",
|
||||
Ci.nsIPrefLocalizedString).data;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "privateBrowsing",
|
||||
"@mozilla.org/privatebrowsing;1",
|
||||
"nsIPrivateBrowsingService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "_bundle", function() {
|
||||
const PLACES_STRING_BUNDLE_URI =
|
||||
"chrome://browser/locale/places/places.properties";
|
||||
return Cc["@mozilla.org/intl/stringbundle;1"].
|
||||
getService(Ci.nsIStringBundleService).
|
||||
createBundle(PLACES_STRING_BUNDLE_URI);
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "fm",
|
||||
"@mozilla.org/focus-manager;1",
|
||||
"nsIFocusManager");
|
|
@ -41,21 +41,24 @@
|
|||
let Ci = Components.interfaces;
|
||||
let Cc = Components.classes;
|
||||
let Cr = Components.results;
|
||||
let Cu = Components.utils;
|
||||
|
||||
const LOAD_IN_SIDEBAR_ANNO = "bookmarkProperties/loadInSidebar";
|
||||
const DESCRIPTION_ANNO = "bookmarkProperties/description";
|
||||
const GUID_ANNO = "placesInternal/GUID";
|
||||
|
||||
const CLASS_ID = Components.ID("c0844a84-5a12-4808-80a8-809cb002bb4f");
|
||||
const CONTRACT_ID = "@mozilla.org/browser/placesTransactionsService;1";
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
__defineGetter__("PlacesUtils", function() {
|
||||
delete this.PlacesUtils
|
||||
var tmpScope = {};
|
||||
Components.utils.import("resource://gre/modules/utils.js", tmpScope);
|
||||
return this.PlacesUtils = tmpScope.PlacesUtils;
|
||||
XPCOMUtils.defineLazyGetter(this, "Services", function() {
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
return Services;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
|
||||
Cu.import("resource://gre/modules/utils.js");
|
||||
return PlacesUtils;
|
||||
});
|
||||
|
||||
// The minimum amount of transactions we should tell our observers to begin
|
||||
|
@ -63,6 +66,7 @@ __defineGetter__("PlacesUtils", function() {
|
|||
const MIN_TRANSACTIONS_FOR_BATCH = 5;
|
||||
|
||||
function placesTransactionsService() {
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
this.mTransactionManager = Cc["@mozilla.org/transactionmanager;1"].
|
||||
createInstance(Ci.nsITransactionManager);
|
||||
}
|
||||
|
@ -72,8 +76,19 @@ placesTransactionsService.prototype = {
|
|||
classID: CLASS_ID,
|
||||
contractID: CONTRACT_ID,
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPlacesTransactionsService,
|
||||
Ci.nsITransactionManager]),
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIPlacesTransactionsService,
|
||||
Ci.nsITransactionManager,
|
||||
Ci.nsIObserver,
|
||||
]),
|
||||
|
||||
// nsIObserver
|
||||
observe: function PlacesTxn_observe(aSubject, aTopic, aData) {
|
||||
if (aTopic == "xpcom-shutdown") {
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
delete this.mTransactionManager;
|
||||
}
|
||||
},
|
||||
|
||||
aggregateTransactions:
|
||||
function placesTxn_aggregateTransactions(aName, aTransactions) {
|
||||
|
@ -228,9 +243,7 @@ placesTransactionsService.prototype = {
|
|||
// Update commands in the undo group of the active window
|
||||
// commands in inactive windows will are updated on-focus
|
||||
_updateCommands: function placesTxn__updateCommands() {
|
||||
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
getService(Ci.nsIWindowMediator);
|
||||
var win = wm.getMostRecentWindow(null);
|
||||
var win = Services.wm.getMostRecentWindow(null);
|
||||
if (win)
|
||||
win.updateCommands("undo");
|
||||
},
|
||||
|
@ -445,7 +458,7 @@ placesCreateFolderTransactions.prototype = {
|
|||
}
|
||||
|
||||
// If a GUID exists for this item, preserve it before removing the item.
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
|
||||
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
|
||||
|
||||
// Remove item only after all child transactions have been reverted.
|
||||
|
@ -503,7 +516,7 @@ placesCreateItemTransactions.prototype = {
|
|||
}
|
||||
|
||||
// If a GUID exists for this item, preserve it before removing the item.
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
|
||||
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
|
||||
|
||||
// Remove item only after all child transactions have been reverted.
|
||||
|
@ -534,7 +547,7 @@ placesCreateSeparatorTransactions.prototype = {
|
|||
|
||||
undoTransaction: function PCST_undoTransaction() {
|
||||
// If a GUID exists for this item, preserve it before removing the item.
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
|
||||
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
|
||||
|
||||
PlacesUtils.bookmarks.removeItem(this._id);
|
||||
|
@ -572,7 +585,7 @@ placesCreateLivemarkTransactions.prototype = {
|
|||
|
||||
undoTransaction: function PCLT_undoTransaction() {
|
||||
// If a GUID exists for this item, preserve it before removing the item.
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, GUID_ANNO))
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._id, PlacesUtils.GUID_ANNO))
|
||||
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._id);
|
||||
|
||||
PlacesUtils.bookmarks.removeItem(this._id);
|
||||
|
@ -1134,7 +1147,7 @@ placesTagURITransaction.prototype = {
|
|||
undoTransaction: function PTU_undoTransaction() {
|
||||
if (this._unfiledItemId != -1) {
|
||||
// If a GUID exists for this item, preserve it before removing the item.
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._unfiledItemId, GUID_ANNO)) {
|
||||
if (PlacesUtils.annotations.itemHasAnnotation(this._unfiledItemId, PlacesUtils.GUID_ANNO)) {
|
||||
this._GUID = PlacesUtils.bookmarks.getItemGUID(this._unfiledItemId);
|
||||
}
|
||||
PlacesUtils.bookmarks.removeItem(this._unfiledItemId);
|
||||
|
|
|
@ -44,6 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_BROWSER_TEST_FILES = \
|
||||
head.js \
|
||||
browser_0_library_left_pane_migration.js \
|
||||
browser_library_left_pane_fixnames.js \
|
||||
browser_425884.js \
|
||||
|
|
|
@ -60,7 +60,7 @@ function windowObserver(aSubject, aTopic, aData) {
|
|||
"Left pane folder correctly created");
|
||||
var leftPaneItems =
|
||||
PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(leftPaneItems.length, 1,
|
||||
"We correctly have only 1 left pane folder");
|
||||
var leftPaneRoot = leftPaneItems[0];
|
||||
|
@ -69,8 +69,8 @@ function windowObserver(aSubject, aTopic, aData) {
|
|||
// Check version has been upgraded.
|
||||
var version =
|
||||
PlacesUtils.annotations.getItemAnnotation(leftPaneRoot,
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION,
|
||||
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION,
|
||||
"Left pane version has been correctly upgraded");
|
||||
|
||||
// Check left pane is populated.
|
||||
|
@ -92,20 +92,20 @@ function test() {
|
|||
// Sanity checks.
|
||||
ok(PlacesUtils, "PlacesUtils is running in chrome context");
|
||||
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
|
||||
ok(ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
"Left pane version in chrome context, current version is: " + ORGANIZER_LEFTPANE_VERSION );
|
||||
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
"Left pane version in chrome context, current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
|
||||
|
||||
// Check if we have any left pane folder already set, remove it eventually.
|
||||
var leftPaneItems = PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
if (leftPaneItems.length > 0) {
|
||||
// The left pane has already been created, touching it now would cause
|
||||
// next tests to rely on wrong values (and possibly crash)
|
||||
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
|
||||
// Check version.
|
||||
var version = PlacesUtils.annotations.getItemAnnotation(leftPaneItems[0],
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
|
||||
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
|
||||
ok(true, "left pane has already been created, skipping test");
|
||||
finish();
|
||||
return;
|
||||
|
@ -116,21 +116,21 @@ function test() {
|
|||
PlacesUtils.bookmarks.createFolder(PlacesUtils.placesRootId, "",
|
||||
PlacesUtils.bookmarks.DEFAULT_INDEX);
|
||||
PlacesUtils.annotations.setItemAnnotation(fakeLeftPaneRoot,
|
||||
ORGANIZER_FOLDER_ANNO,
|
||||
ORGANIZER_LEFTPANE_VERSION - 1,
|
||||
PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
|
||||
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION - 1,
|
||||
0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
|
||||
// Check fake left pane root has been correctly created.
|
||||
var leftPaneItems =
|
||||
PlacesUtils.annotations.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
PlacesUtils.annotations.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
|
||||
is(leftPaneItems[0], fakeLeftPaneRoot, "left pane root itemId is correct");
|
||||
|
||||
// Check version.
|
||||
var version = PlacesUtils.annotations.getItemAnnotation(fakeLeftPaneRoot,
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION - 1, "Left pane version correctly set");
|
||||
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION - 1, "Left pane version correctly set");
|
||||
|
||||
// Open Library, this will upgrade our left pane version.
|
||||
ww.registerNotification(windowObserver);
|
||||
|
|
|
@ -143,7 +143,9 @@ function test() {
|
|||
var xferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
createInstance(Ci.nsITransferable);
|
||||
xferable.addDataFlavor(PU.TYPE_X_MOZ_PLACE);
|
||||
PUIU.clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
|
||||
var clipboard = Cc["@mozilla.org/widget/clipboard;1"].
|
||||
getService(Ci.nsIClipboard);
|
||||
clipboard.getData(xferable, Ci.nsIClipboard.kGlobalClipboard);
|
||||
var data = { }, type = { };
|
||||
xferable.getAnyTransferData(type, data, { });
|
||||
// Data is in the clipboard
|
||||
|
|
|
@ -81,32 +81,32 @@ function test() {
|
|||
// Sanity checks.
|
||||
ok(PlacesUtils, "PlacesUtils is running in chrome context");
|
||||
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
|
||||
ok(ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
"Left pane version in chrome context, current version is: " + ORGANIZER_LEFTPANE_VERSION );
|
||||
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
"Left pane version in chrome context, current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
|
||||
|
||||
// Ensure left pane is initialized.
|
||||
ok(PlacesUIUtils.leftPaneFolderId > 0, "left pane folder is initialized");
|
||||
|
||||
// Get the left pane folder.
|
||||
var leftPaneItems = PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
|
||||
is(leftPaneItems.length, 1, "We correctly have only 1 left pane folder");
|
||||
// Check version.
|
||||
var version = PlacesUtils.annotations
|
||||
.getItemAnnotation(leftPaneItems[0],
|
||||
ORGANIZER_FOLDER_ANNO);
|
||||
is(version, ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
|
||||
PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(version, PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, "Left pane version is actual");
|
||||
|
||||
// Get all left pane queries.
|
||||
var items = PlacesUtils.annotations
|
||||
.getItemsWithAnnotation(ORGANIZER_QUERY_ANNO);
|
||||
.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_QUERY_ANNO);
|
||||
// Get current queries names.
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var itemId = items[i];
|
||||
var queryName = PlacesUtils.annotations
|
||||
.getItemAnnotation(items[i],
|
||||
ORGANIZER_QUERY_ANNO);
|
||||
PlacesUIUtils.ORGANIZER_QUERY_ANNO);
|
||||
var query = { name: queryName,
|
||||
itemId: itemId,
|
||||
correctTitle: PlacesUtils.bookmarks.getItemTitle(itemId) }
|
||||
|
@ -131,6 +131,8 @@ function test() {
|
|||
PlacesUtils.bookmarks.setItemTitle(query.concreteId, "badName");
|
||||
}
|
||||
|
||||
PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter);
|
||||
|
||||
// Open Library, this will kick-off left pane code.
|
||||
ww.registerNotification(windowObserver);
|
||||
ww.openWindow(null,
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
// We need to cache this before test runs...
|
||||
let cachedLeftPaneFolderIdGetter;
|
||||
let (getter = PlacesUIUtils.__lookupGetter__("leftPaneFolderId")) {
|
||||
if (!cachedLeftPaneFolderIdGetter && typeof(getter) == "function")
|
||||
cachedLeftPaneFolderIdGetter = getter;
|
||||
}
|
||||
// ...And restore it when test ends.
|
||||
registerCleanupFunction(function(){
|
||||
let (getter = PlacesUIUtils.__lookupGetter__("leftPaneFolderId")) {
|
||||
if (cachedLeftPaneFolderIdGetter && typeof(getter) != "function")
|
||||
PlacesUIUtils.__defineGetter__("leftPaneFolderId",
|
||||
cachedLeftPaneFolderIdGetter);
|
||||
}
|
||||
});
|
|
@ -47,8 +47,8 @@ _CHROME_TEST_FILES = \
|
|||
test_treeview_date.xul \
|
||||
test_bug485100-change-case-loses-tag.xul \
|
||||
test_bug427633_no_newfolder_if_noip.xul \
|
||||
test_multiple_left_pane.xul \
|
||||
test_bug510634.xul \
|
||||
test_0_multiple_left_pane.xul \
|
||||
test_0_bug510634.xul \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_CHROME_TEST_FILES)
|
||||
|
|
|
@ -127,6 +127,9 @@
|
|||
// Close the root node
|
||||
tree.getResult().root.containerOpen = false;
|
||||
|
||||
// Restore the getter for the next test.
|
||||
PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
|
@ -71,9 +71,9 @@
|
|||
// Sanity checks.
|
||||
ok(PlacesUtils, "PlacesUtils is running in chrome context");
|
||||
ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
|
||||
ok(ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
|
||||
"Left pane version in chrome context, " +
|
||||
"current version is: " + ORGANIZER_LEFTPANE_VERSION );
|
||||
"current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );
|
||||
|
||||
var fakeLeftPanes = [];
|
||||
var as = PlacesUtils.annotations;
|
||||
|
@ -81,12 +81,12 @@
|
|||
|
||||
// We need 2 left pane folders to simulate a corrupt profile.
|
||||
do {
|
||||
let leftPaneItems = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
let leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
// Create a fake left pane folder.
|
||||
let fakeLeftPaneRoot = bs.createFolder(PlacesUtils.placesRootId, "",
|
||||
bs.DEFAULT_INDEX);
|
||||
as.setItemAnnotation(fakeLeftPaneRoot, ORGANIZER_FOLDER_ANNO,
|
||||
ORGANIZER_LEFTPANE_VERSION, 0,
|
||||
as.setItemAnnotation(fakeLeftPaneRoot, PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
|
||||
PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, 0,
|
||||
as.EXPIRE_NEVER);
|
||||
fakeLeftPanes.push(fakeLeftPaneRoot);
|
||||
} while (fakeLeftPanes.length < 2);
|
||||
|
@ -97,7 +97,7 @@
|
|||
// Check left pane.
|
||||
ok(PlacesUIUtils.leftPaneFolderId > 0,
|
||||
"Left pane folder correctly created");
|
||||
var leftPaneItems = as.getItemsWithAnnotation(ORGANIZER_FOLDER_ANNO);
|
||||
var leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
|
||||
is(leftPaneItems.length, 1,
|
||||
"We correctly have only 1 left pane folder");
|
||||
|
|
@ -53,6 +53,16 @@ let (commonFile = do_get_file("../../test_places/head_common.js", false)) {
|
|||
// Put any other stuff relative to this test folder below.
|
||||
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "PlacesUIUtils", function() {
|
||||
Cu.import("resource://gre/modules/PlacesUIUtils.jsm");
|
||||
return PlacesUIUtils;
|
||||
});
|
||||
|
||||
|
||||
const ORGANIZER_FOLDER_ANNO = "PlacesOrganizer/OrganizerFolder";
|
||||
const ORGANIZER_QUERY_ANNO = "PlacesOrganizer/OrganizerQuery";
|
||||
|
||||
|
||||
// Needed by some test that relies on having an app registered.
|
||||
let (XULAppInfo = {
|
||||
vendor: "Mozilla",
|
||||
|
|
|
@ -116,10 +116,7 @@ function run_test() {
|
|||
// We want empty roots.
|
||||
remove_all_bookmarks();
|
||||
|
||||
// Import PlacesUIUtils.
|
||||
let scriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].
|
||||
getService(Ci.mozIJSSubScriptLoader);
|
||||
scriptLoader.loadSubScript("chrome://browser/content/places/utils.js", this);
|
||||
// Sanity check.
|
||||
do_check_true(!!PlacesUIUtils);
|
||||
|
||||
// Check getters.
|
||||
|
|
Загрузка…
Ссылка в новой задаче