зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1405687 - Remove some deprecated code from Places related code. r=standard8
MozReview-Commit-ID: 411z07otlfN --HG-- extra : rebase_source : 43f91cb30a7ad85f633b653d153a657ebdad1893
This commit is contained in:
Родитель
3aa5ba0c3e
Коммит
e5991df3ec
|
@ -523,10 +523,6 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
|
|||
background-image: var(--lwt-footer-image);
|
||||
}
|
||||
|
||||
.menuitem-iconic-tooltip {
|
||||
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#menuitem-iconic-tooltip");
|
||||
}
|
||||
|
||||
/* Hide menu elements intended for keyboard access support */
|
||||
#main-menubar[openedwithkey=false] .show-only-for-keyboard {
|
||||
display: none;
|
||||
|
|
|
@ -3107,16 +3107,4 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|||
<handler event="keypress" keycode="VK_RETURN" group="system" action="this._accept(event);"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
<!-- This binding is only retained for add-ons compatibility -->
|
||||
<binding id="menuitem-iconic-tooltip" extends="chrome://global/content/bindings/menu.xml#menuitem-iconic">
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
this.setAttribute("tooltiptext", this.getAttribute("acceltext"));
|
||||
// TODO: Simplify this to this.setAttribute("acceltext", "") once bug
|
||||
// 592424 is fixed
|
||||
document.getAnonymousElementByAttribute(this, "anonid", "accel").firstChild.setAttribute("value", "");
|
||||
]]></constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
|
|
@ -5,35 +5,28 @@
|
|||
|
||||
this.EXPORTED_SYMBOLS = ["PlacesUIUtils"];
|
||||
|
||||
var Ci = Components.interfaces;
|
||||
var Cc = Components.classes;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Timer.jsm");
|
||||
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
|
||||
"resource:///modules/RecentWindow.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
|
||||
"resource://gre/modules/PromiseUtils.jsm");
|
||||
|
||||
// PlacesUtils exposes multiple symbols, so we can't use defineLazyModuleGetter.
|
||||
// PlacesUtils exposes multiple symbols, so we can't use defineLazyModuleGetter
|
||||
// until we remove legacy transactions (Bug 1131491).
|
||||
Cu.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTransactions",
|
||||
"resource://gre/modules/PlacesTransactions.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetters(this, {
|
||||
PluralForm: "resource://gre/modules/PluralForm.jsm",
|
||||
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
|
||||
RecentWindow: "resource:///modules/RecentWindow.jsm",
|
||||
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
|
||||
PlacesTransactions: "resource://gre/modules/PlacesTransactions.jsm",
|
||||
Weave: "resource://services-sync/main.js",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Weave",
|
||||
"resource://services-sync/main.js");
|
||||
XPCOMUtils.defineLazyGetter(this, "bundle", function() {
|
||||
return Services.strings.createBundle("chrome://browser/locale/places/places.properties");
|
||||
});
|
||||
|
||||
const gInContentProcess = Services.appinfo.processType == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT;
|
||||
const FAVICON_REQUEST_TIMEOUT = 60 * 1000;
|
||||
|
@ -62,8 +55,6 @@ function IsLivemark(aItemId) {
|
|||
let obs = Object.freeze({
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsINavBookmarksObserver]),
|
||||
|
||||
// Ci.nsINavBookmarkObserver items.
|
||||
|
||||
onItemChanged(itemId, property, isAnnoProperty, newValue, lastModified,
|
||||
itemType, parentId, guid) {
|
||||
if (isAnnoProperty && property == LIVEMARK_ANNO) {
|
||||
|
@ -85,7 +76,7 @@ function IsLivemark(aItemId) {
|
|||
onPageAnnotationSet() { },
|
||||
onPageAnnotationRemoved() { },
|
||||
skipDescendantsOnItemRemoval: false,
|
||||
skipTags: false,
|
||||
skipTags: true,
|
||||
});
|
||||
|
||||
PlacesUtils.bookmarks.addObserver(obs);
|
||||
|
@ -280,7 +271,7 @@ this.PlacesUIUtils = {
|
|||
* @return A URI object for the spec.
|
||||
*/
|
||||
createFixedURI: function PUIU_createFixedURI(aSpec) {
|
||||
return URIFixup.createFixupURI(aSpec, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
|
||||
return Services.uriFixup.createFixupURI(aSpec, Ci.nsIURIFixup.FIXUP_FLAG_NONE);
|
||||
},
|
||||
|
||||
getFormattedString: function PUIU_getFormattedString(key, params) {
|
||||
|
@ -436,7 +427,7 @@ this.PlacesUIUtils = {
|
|||
root.containerOpen = false;
|
||||
for (let { uri } of urls) {
|
||||
transactions.push(
|
||||
new PlacesTagURITransaction(NetUtil.newURI(uri), [aData.title])
|
||||
new PlacesTagURITransaction(Services.io.newURI(uri), [aData.title])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -678,10 +669,6 @@ this.PlacesUIUtils = {
|
|||
return performed;
|
||||
},
|
||||
|
||||
_getTopBrowserWin: function PUIU__getTopBrowserWin() {
|
||||
return RecentWindow.getMostRecentBrowserWindow();
|
||||
},
|
||||
|
||||
/**
|
||||
* set and fetch a favicon. Can only be used from the parent process.
|
||||
* @param browser {Browser} The XUL browser element for which we're fetching a favicon.
|
||||
|
@ -961,7 +948,7 @@ this.PlacesUIUtils = {
|
|||
var browserWindow = null;
|
||||
browserWindow =
|
||||
aWindow && aWindow.document.documentElement.getAttribute("windowtype") == "navigator:browser" ?
|
||||
aWindow : this._getTopBrowserWin();
|
||||
aWindow : RecentWindow.getMostRecentBrowserWindow();
|
||||
|
||||
var urls = [];
|
||||
let skipMarking = browserWindow && PrivateBrowsingUtils.isWindowPrivate(browserWindow);
|
||||
|
@ -1095,7 +1082,7 @@ this.PlacesUIUtils = {
|
|||
if (aWhere == "current" && isBookmark) {
|
||||
if (PlacesUtils.annotations
|
||||
.itemHasAnnotation(aNode.itemId, this.LOAD_IN_SIDEBAR_ANNO)) {
|
||||
let browserWin = this._getTopBrowserWin();
|
||||
let browserWin = RecentWindow.getMostRecentBrowserWindow();
|
||||
if (browserWin) {
|
||||
browserWin.openWebPanel(aNode.title, aNode.uri);
|
||||
return;
|
||||
|
@ -1590,203 +1577,16 @@ PlacesUIUtils.URI_FLAVORS = [PlacesUtils.TYPE_X_MOZ_URL,
|
|||
PlacesUIUtils.SUPPORTED_FLAVORS = [...PlacesUIUtils.PLACES_FLAVORS,
|
||||
...PlacesUIUtils.URI_FLAVORS];
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUIUtils, "RDF",
|
||||
"@mozilla.org/rdf/rdf-service;1",
|
||||
"nsIRDFService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ellipsis", function() {
|
||||
return Services.prefs.getComplexValue("intl.ellipsis",
|
||||
Ci.nsIPrefLocalizedString).data;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "useAsyncTransactions", function() {
|
||||
try {
|
||||
return Services.prefs.getBoolPref("browser.places.useAsyncTransactions");
|
||||
} catch (ex) { }
|
||||
return false;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "useAsyncTransactions",
|
||||
"browser.places.useAsyncTransactions", false);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "loadBookmarksInBackground",
|
||||
PREF_LOAD_BOOKMARKS_IN_BACKGROUND, false);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "loadBookmarksInTabs",
|
||||
PREF_LOAD_BOOKMARKS_IN_TABS, false);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(PlacesUIUtils, "openInTabClosesMenu",
|
||||
"browser.bookmarks.openInTabClosesMenu", false);
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "URIFixup",
|
||||
"@mozilla.org/docshell/urifixup;1",
|
||||
"nsIURIFixup");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "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);
|
||||
});
|
||||
|
||||
/**
|
||||
* This is a compatibility shim for old PUIU.ptm users.
|
||||
*
|
||||
* If you're looking for transactions and writing new code using them, directly
|
||||
* use the transactions objects exported by the PlacesUtils.jsm module.
|
||||
*
|
||||
* This object will be removed once enough users are converted to the new API.
|
||||
*/
|
||||
XPCOMUtils.defineLazyGetter(PlacesUIUtils, "ptm", function() {
|
||||
// Ensure PlacesUtils is imported in scope.
|
||||
PlacesUtils;
|
||||
|
||||
return {
|
||||
aggregateTransactions: (aName, aTransactions) =>
|
||||
new PlacesAggregatedTransaction(aName, aTransactions),
|
||||
|
||||
createFolder: (aName, aContainer, aIndex, aAnnotations,
|
||||
aChildItemsTransactions) =>
|
||||
new PlacesCreateFolderTransaction(aName, aContainer, aIndex, aAnnotations,
|
||||
aChildItemsTransactions),
|
||||
|
||||
createItem: (aURI, aContainer, aIndex, aTitle, aKeyword,
|
||||
aAnnotations, aChildTransactions) =>
|
||||
new PlacesCreateBookmarkTransaction(aURI, aContainer, aIndex, aTitle,
|
||||
aKeyword, aAnnotations,
|
||||
aChildTransactions),
|
||||
|
||||
createSeparator: (aContainer, aIndex) =>
|
||||
new PlacesCreateSeparatorTransaction(aContainer, aIndex),
|
||||
|
||||
createLivemark: (aFeedURI, aSiteURI, aName, aContainer, aIndex,
|
||||
aAnnotations) =>
|
||||
new PlacesCreateLivemarkTransaction(aFeedURI, aSiteURI, aName, aContainer,
|
||||
aIndex, aAnnotations),
|
||||
|
||||
moveItem: (aItemId, aNewContainer, aNewIndex) =>
|
||||
new PlacesMoveItemTransaction(aItemId, aNewContainer, aNewIndex),
|
||||
|
||||
removeItem: (aItemId) =>
|
||||
new PlacesRemoveItemTransaction(aItemId),
|
||||
|
||||
editItemTitle: (aItemId, aNewTitle) =>
|
||||
new PlacesEditItemTitleTransaction(aItemId, aNewTitle),
|
||||
|
||||
editBookmarkURI: (aItemId, aNewURI) =>
|
||||
new PlacesEditBookmarkURITransaction(aItemId, aNewURI),
|
||||
|
||||
setItemAnnotation: (aItemId, aAnnotationObject) =>
|
||||
new PlacesSetItemAnnotationTransaction(aItemId, aAnnotationObject),
|
||||
|
||||
setPageAnnotation: (aURI, aAnnotationObject) =>
|
||||
new PlacesSetPageAnnotationTransaction(aURI, aAnnotationObject),
|
||||
|
||||
editBookmarkKeyword: (aItemId, aNewKeyword) =>
|
||||
new PlacesEditBookmarkKeywordTransaction(aItemId, aNewKeyword),
|
||||
|
||||
editLivemarkSiteURI: (aLivemarkId, aSiteURI) =>
|
||||
new PlacesEditLivemarkSiteURITransaction(aLivemarkId, aSiteURI),
|
||||
|
||||
editLivemarkFeedURI: (aLivemarkId, aFeedURI) =>
|
||||
new PlacesEditLivemarkFeedURITransaction(aLivemarkId, aFeedURI),
|
||||
|
||||
editItemDateAdded: (aItemId, aNewDateAdded) =>
|
||||
new PlacesEditItemDateAddedTransaction(aItemId, aNewDateAdded),
|
||||
|
||||
editItemLastModified: (aItemId, aNewLastModified) =>
|
||||
new PlacesEditItemLastModifiedTransaction(aItemId, aNewLastModified),
|
||||
|
||||
sortFolderByName: (aFolderId) =>
|
||||
new PlacesSortFolderByNameTransaction(aFolderId),
|
||||
|
||||
tagURI: (aURI, aTags) =>
|
||||
new PlacesTagURITransaction(aURI, aTags),
|
||||
|
||||
untagURI: (aURI, aTags) =>
|
||||
new PlacesUntagURITransaction(aURI, aTags),
|
||||
|
||||
/**
|
||||
* Transaction for setting/unsetting Load-in-sidebar annotation.
|
||||
*
|
||||
* @param aBookmarkId
|
||||
* id of the bookmark where to set Load-in-sidebar annotation.
|
||||
* @param aLoadInSidebar
|
||||
* boolean value.
|
||||
* @return nsITransaction object.
|
||||
*/
|
||||
setLoadInSidebar(aItemId, aLoadInSidebar) {
|
||||
let annoObj = { name: PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO,
|
||||
type: Ci.nsIAnnotationService.TYPE_INT32,
|
||||
flags: 0,
|
||||
value: aLoadInSidebar,
|
||||
expires: Ci.nsIAnnotationService.EXPIRE_NEVER };
|
||||
return new PlacesSetItemAnnotationTransaction(aItemId, annoObj);
|
||||
},
|
||||
|
||||
/**
|
||||
* Transaction for editing the description of a bookmark or a folder.
|
||||
*
|
||||
* @param aItemId
|
||||
* id of the item to edit.
|
||||
* @param aDescription
|
||||
* new description.
|
||||
* @return nsITransaction object.
|
||||
*/
|
||||
editItemDescription(aItemId, aDescription) {
|
||||
let annoObj = { name: PlacesUIUtils.DESCRIPTION_ANNO,
|
||||
type: Ci.nsIAnnotationService.TYPE_STRING,
|
||||
flags: 0,
|
||||
value: aDescription,
|
||||
expires: Ci.nsIAnnotationService.EXPIRE_NEVER };
|
||||
return new PlacesSetItemAnnotationTransaction(aItemId, annoObj);
|
||||
},
|
||||
|
||||
// nsITransactionManager forwarders.
|
||||
|
||||
beginBatch: () =>
|
||||
PlacesUtils.transactionManager.beginBatch(null),
|
||||
|
||||
endBatch: () =>
|
||||
PlacesUtils.transactionManager.endBatch(false),
|
||||
|
||||
doTransaction: (txn) =>
|
||||
PlacesUtils.transactionManager.doTransaction(txn),
|
||||
|
||||
undoTransaction: () =>
|
||||
PlacesUtils.transactionManager.undoTransaction(),
|
||||
|
||||
redoTransaction: () =>
|
||||
PlacesUtils.transactionManager.redoTransaction(),
|
||||
|
||||
get numberOfUndoItems() {
|
||||
return PlacesUtils.transactionManager.numberOfUndoItems;
|
||||
},
|
||||
get numberOfRedoItems() {
|
||||
return PlacesUtils.transactionManager.numberOfRedoItems;
|
||||
},
|
||||
get maxTransactionCount() {
|
||||
return PlacesUtils.transactionManager.maxTransactionCount;
|
||||
},
|
||||
set maxTransactionCount(val) {
|
||||
PlacesUtils.transactionManager.maxTransactionCount = val;
|
||||
},
|
||||
|
||||
clear: () =>
|
||||
PlacesUtils.transactionManager.clear(),
|
||||
|
||||
peekUndoStack: () =>
|
||||
PlacesUtils.transactionManager.peekUndoStack(),
|
||||
|
||||
peekRedoStack: () =>
|
||||
PlacesUtils.transactionManager.peekRedoStack(),
|
||||
|
||||
getUndoStack: () =>
|
||||
PlacesUtils.transactionManager.getUndoStack(),
|
||||
|
||||
getRedoStack: () =>
|
||||
PlacesUtils.transactionManager.getRedoStack(),
|
||||
|
||||
AddListener: (aListener) =>
|
||||
PlacesUtils.transactionManager.AddListener(aListener),
|
||||
|
||||
RemoveListener: (aListener) =>
|
||||
PlacesUtils.transactionManager.RemoveListener(aListener)
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1010,7 +1010,7 @@ PlacesController.prototype = {
|
|||
_removeHistoryContainer: function PC__removeHistoryContainer(aContainerNode) {
|
||||
if (PlacesUtils.nodeIsHost(aContainerNode)) {
|
||||
// Site container.
|
||||
PlacesUtils.bhistory.removePagesFromHost(aContainerNode.title, true);
|
||||
PlacesUtils.history.removePagesFromHost(aContainerNode.title, true);
|
||||
} else if (PlacesUtils.nodeIsDay(aContainerNode)) {
|
||||
// Day container.
|
||||
let query = aContainerNode.getQueries()[0];
|
||||
|
@ -1022,7 +1022,7 @@ PlacesController.prototype = {
|
|||
// removePagesByTimeframe includes both extremes, while date containers
|
||||
// exclude the lower extreme. So, if we would not exclude it, we would
|
||||
// end up removing more history than requested.
|
||||
PlacesUtils.bhistory.removePagesByTimeframe(beginTime + 1, endTime);
|
||||
PlacesUtils.history.removePagesByTimeframe(beginTime + 1, endTime);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -21,8 +21,7 @@ var gEditItemOverlay = {
|
|||
if (!("uris" in aInitInfo) && !("node" in aInitInfo))
|
||||
throw new Error("Neither node nor uris set for pane info");
|
||||
|
||||
// Once we stop supporting legacy add-ons the code should throw if a node is
|
||||
// not passed.
|
||||
// We either pass a node or uris.
|
||||
let node = "node" in aInitInfo ? aInitInfo.node : null;
|
||||
|
||||
// Since there's no true UI for folder shortcuts (they show up just as their target
|
||||
|
|
|
@ -37,7 +37,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
NetUtil: "resource://gre/modules/NetUtil.jsm",
|
||||
OS: "resource://gre/modules/osfile.jsm",
|
||||
Sqlite: "resource://gre/modules/Sqlite.jsm",
|
||||
Deprecated: "resource://gre/modules/Deprecated.jsm",
|
||||
Bookmarks: "resource://gre/modules/Bookmarks.jsm",
|
||||
History: "resource://gre/modules/History.jsm",
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.jsm",
|
||||
|
@ -1946,10 +1945,6 @@ XPCOMUtils.defineLazyServiceGetter(PlacesUtils, "asyncHistory",
|
|||
"@mozilla.org/browser/history;1",
|
||||
"mozIAsyncHistory");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(PlacesUtils, "bhistory", function() {
|
||||
return PlacesUtils.history;
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(PlacesUtils, "favicons",
|
||||
"@mozilla.org/browser/favicon-service;1",
|
||||
"mozIAsyncFavicons");
|
||||
|
|
|
@ -13,30 +13,6 @@
|
|||
[scriptable, uuid(20d31479-38de-49f4-9300-566d6e834c66)]
|
||||
interface nsIBrowserHistory : nsISupports
|
||||
{
|
||||
/**
|
||||
* Removes a page from global history.
|
||||
*
|
||||
* @note It is preferrable to use this one rather then RemovePages when
|
||||
* removing less than 10 pages, since it won't start a full batch
|
||||
* operation.
|
||||
* @deprecated Use PlacesUtils.history.remove() API instead.
|
||||
*/
|
||||
void removePage(in nsIURI aURI);
|
||||
|
||||
/**
|
||||
* Removes a list of pages from global history.
|
||||
*
|
||||
* @param aURIs
|
||||
* Array of URIs to be removed.
|
||||
* @param aLength
|
||||
* Length of the array.
|
||||
*
|
||||
* @note the removal happens in a batch.
|
||||
* @deprecated Use PlacesUtils.history.remove() API instead.
|
||||
*/
|
||||
void removePages([array, size_is(aLength)] in nsIURI aURIs,
|
||||
in unsigned long aLength);
|
||||
|
||||
/**
|
||||
* Removes all global history information about pages for a given host.
|
||||
*
|
||||
|
|
|
@ -12,8 +12,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
|||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
|
||||
"resource://gre/modules/Deprecated.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "asyncHistory", function() {
|
||||
// Lazily add an history observer when it's actually needed.
|
||||
|
|
|
@ -2537,81 +2537,6 @@ nsNavHistory::CleanupPlacesOnVisitsDelete(const nsCString& aPlaceIdsQueryString)
|
|||
}
|
||||
|
||||
|
||||
// nsNavHistory::RemovePages
|
||||
//
|
||||
// Removes a bunch of uris from history.
|
||||
// Has better performance than RemovePage when deleting a lot of history.
|
||||
// We don't do duplicates removal, URIs array should be cleaned-up before.
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistory::RemovePages(nsIURI **aURIs, uint32_t aLength)
|
||||
{
|
||||
PLACES_WARN_DEPRECATED();
|
||||
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
|
||||
NS_ENSURE_ARG(aURIs);
|
||||
|
||||
nsresult rv;
|
||||
// build a list of place ids to delete
|
||||
nsCString deletePlaceIdsQueryString;
|
||||
for (uint32_t i = 0; i < aLength; i++) {
|
||||
int64_t placeId;
|
||||
nsAutoCString guid;
|
||||
if (!aURIs[i])
|
||||
continue;
|
||||
rv = GetIdForPage(aURIs[i], &placeId, guid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (placeId != 0) {
|
||||
if (!deletePlaceIdsQueryString.IsEmpty())
|
||||
deletePlaceIdsQueryString.Append(',');
|
||||
deletePlaceIdsQueryString.AppendInt(placeId);
|
||||
}
|
||||
}
|
||||
|
||||
UpdateBatchScoper batch(*this); // sends Begin/EndUpdateBatch to observers
|
||||
|
||||
rv = RemovePagesInternal(deletePlaceIdsQueryString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Clear the registered embed visits.
|
||||
clearEmbedVisits();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsNavHistory::RemovePage
|
||||
//
|
||||
// Removes all visits and the main history entry for the given URI.
|
||||
// Silently fails if we have no knowledge of the page.
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNavHistory::RemovePage(nsIURI *aURI)
|
||||
{
|
||||
PLACES_WARN_DEPRECATED();
|
||||
NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
|
||||
NS_ENSURE_ARG(aURI);
|
||||
|
||||
// Build a list of place ids to delete.
|
||||
int64_t placeId;
|
||||
nsAutoCString guid;
|
||||
nsresult rv = GetIdForPage(aURI, &placeId, guid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (placeId == 0) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsAutoCString deletePlaceIdQueryString;
|
||||
deletePlaceIdQueryString.AppendInt(placeId);
|
||||
|
||||
rv = RemovePagesInternal(deletePlaceIdQueryString);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Clear the registered embed visits.
|
||||
clearEmbedVisits();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// nsNavHistory::RemovePagesFromHost
|
||||
//
|
||||
// This function will delete all history information about pages from a
|
||||
|
|
|
@ -10,8 +10,6 @@ const Cr = Components.results;
|
|||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
|
||||
"resource://gre/modules/Deprecated.jsm");
|
||||
|
||||
const TOPIC_SHUTDOWN = "places-shutdown";
|
||||
|
||||
|
@ -221,8 +219,8 @@ TaggingService.prototype = {
|
|||
|
||||
let isAnyTagNotTrimmed = tags.some(tag => /^\s|\s$/.test(tag.name));
|
||||
if (isAnyTagNotTrimmed) {
|
||||
Deprecated.warning("At least one tag passed to untagURI was not trimmed",
|
||||
"https://bugzilla.mozilla.org/show_bug.cgi?id=967196");
|
||||
throw Components.Exception("At least one tag passed to untagURI was not trimmed",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
|
||||
for (let tag of tags) {
|
||||
|
@ -244,8 +242,8 @@ TaggingService.prototype = {
|
|||
}
|
||||
|
||||
if (/^\s|\s$/.test(aTagName)) {
|
||||
Deprecated.warning("Tag passed to getURIsForTag was not trimmed",
|
||||
"https://bugzilla.mozilla.org/show_bug.cgi?id=967196");
|
||||
throw Components.Exception("Tag passed to getURIsForTag was not trimmed",
|
||||
Cr.NS_ERROR_INVALID_ARG);
|
||||
}
|
||||
|
||||
let uris = [];
|
||||
|
|
|
@ -74,7 +74,7 @@ add_task(async function test_removePagesByTimeframe() {
|
|||
await PlacesTestUtils.addVisits(visits);
|
||||
|
||||
// Delete all pages except the first and the last.
|
||||
PlacesUtils.bhistory.removePagesByTimeframe(startDate + 1000, startDate + 8000);
|
||||
PlacesUtils.history.removePagesByTimeframe(startDate + 1000, startDate + 8000);
|
||||
|
||||
// Check that we have removed the correct pages.
|
||||
for (let i = 0; i < 10; i++) {
|
||||
|
@ -83,19 +83,19 @@ add_task(async function test_removePagesByTimeframe() {
|
|||
}
|
||||
|
||||
// Clear remaining items and check that all pages have been removed.
|
||||
PlacesUtils.bhistory.removePagesByTimeframe(startDate, startDate + 9000);
|
||||
PlacesUtils.history.removePagesByTimeframe(startDate, startDate + 9000);
|
||||
do_check_eq(0, PlacesUtils.history.hasHistoryEntries);
|
||||
});
|
||||
|
||||
add_task(async function test_removePagesFromHost() {
|
||||
await PlacesTestUtils.addVisits(TEST_URI);
|
||||
PlacesUtils.bhistory.removePagesFromHost("mozilla.com", true);
|
||||
PlacesUtils.history.removePagesFromHost("mozilla.com", true);
|
||||
do_check_eq(0, PlacesUtils.history.hasHistoryEntries);
|
||||
});
|
||||
|
||||
add_task(async function test_removePagesFromHost_keepSubdomains() {
|
||||
await PlacesTestUtils.addVisits([{ uri: TEST_URI }, { uri: TEST_SUBDOMAIN_URI }]);
|
||||
PlacesUtils.bhistory.removePagesFromHost("mozilla.com", false);
|
||||
PlacesUtils.history.removePagesFromHost("mozilla.com", false);
|
||||
do_check_eq(1, PlacesUtils.history.hasHistoryEntries);
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче