author | Marco Bonardo <mbonardo@mozilla.com> |
Wed, 04 Oct 2017 16:33:46 +0200 | |
changeset 674920 | cbdf1197133f33b3fd40555725e2777f3a17beff |
parent 674178 | 11fe0a2895aab26c57bcfe61b3041d7837e954cd |
child 734455 | 864df36c206a8c7fccfa062b0f37c9f03e7c7831 |
push id | 82971 |
push user | mak77@bonardo.net |
push date | Wed, 04 Oct 2017 15:00:11 +0000 |
bugs | 1405687 |
milestone | 58.0a1 |
--- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -518,20 +518,16 @@ toolbar:not(#TabsToolbar) > #personal-bo :root[lwthemefooter=true] #browser-bottombox:-moz-lwtheme { background-repeat: no-repeat; background-position: bottom left; background-color: var(--lwt-accent-color); 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; } /* ::::: location bar & search bar ::::: */ /* url bar min-width is defined further down, together with the maximum size
--- a/browser/base/content/urlbarBindings.xml +++ b/browser/base/content/urlbarBindings.xml @@ -3088,21 +3088,9 @@ file, You can obtain one at http://mozil </method> </implementation> <handlers> <!-- The _accept method checks for .defaultPrevented so that if focus is in a button, enter activates the button and not this default action --> <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>
--- a/browser/components/places/PlacesUIUtils.jsm +++ b/browser/components/places/PlacesUIUtils.jsm @@ -1,44 +1,37 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 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; // Map from windows to arrays of data about pending favicon loads. let gFaviconLoadDataMap = new Map(); const ITEM_CHANGED_BATCH_NOTIFICATION_THRESHOLD = 10; @@ -57,18 +50,16 @@ function IsLivemark(aItemId) { const LIVEMARK_ANNO = PlacesUtils.LMANNO_FEEDURI; let idsVec = PlacesUtils.annotations.getItemsWithAnnotation(LIVEMARK_ANNO); self.ids = new Set(idsVec); 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) { self.ids.add(itemId); } }, onItemRemoved(itemId) { @@ -80,17 +71,17 @@ function IsLivemark(aItemId) { onItemAdded() {}, onBeginUpdateBatch() {}, onEndUpdateBatch() {}, onItemVisited() {}, onItemMoved() {}, onPageAnnotationSet() { }, onPageAnnotationRemoved() { }, skipDescendantsOnItemRemoval: false, - skipTags: false, + skipTags: true, }); PlacesUtils.bookmarks.addObserver(obs); PlacesUtils.registerShutdownFunction(() => { PlacesUtils.bookmarks.removeObserver(obs); }); } return self.ids.has(aItemId); @@ -275,17 +266,17 @@ this.PlacesUIUtils = { /** * Makes a URI from a spec, and do fixup * @param aSpec * The string spec of the URI * @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) { return bundle.formatStringFromName(key, params, params.length); }, /** * Get a localized plural string for the specified key name and numeric value @@ -431,17 +422,17 @@ this.PlacesUIUtils = { if (aContainer == PlacesUtils.tagsFolderId) { // Copying into a tag folder. let transactions = []; if (!aData.livemark && aData.type == PlacesUtils.TYPE_X_MOZ_PLACE_CONTAINER) { let {root} = PlacesUtils.getFolderContents(aData.id, false, false); let urls = PlacesUtils.getURLsForContainerNode(root); 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]) ); } } return new PlacesAggregatedTransaction("addTags", transactions); } if (aData.livemark && aData.annos) { // Copying a livemark. return this._getLivemarkCopyTransaction(aData, aContainer, aIndex); @@ -673,20 +664,16 @@ this.PlacesUIUtils = { topUndoEntry != PlacesTransactions.topUndoEntry) { PlacesTransactions.undo().catch(Components.utils.reportError); } } 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. * @param principal {Principal} The loading principal to use for the fetch. * @param uri {URI} The URI to fetch. */ loadFavicon(browser, principal, uri, requestContextID) { if (gInContentProcess) { @@ -956,17 +943,17 @@ this.PlacesUIUtils = { if (!aItemsToOpen.length) return; // Prefer the caller window if it's a browser window, otherwise use // the top browser window. 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); for (let item of aItemsToOpen) { urls.push(item.uri); if (skipMarking) { continue; } @@ -1090,17 +1077,17 @@ this.PlacesUIUtils = { this.markPageAsTyped(aNode.uri); } // Check whether the node is a bookmark which should be opened as // a web panel 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; } } } aWindow.openUILinkIn(aNode.uri, aWhere, { @@ -1585,208 +1572,21 @@ PlacesUIUtils.PLACES_FLAVORS = [PlacesUt PlacesUIUtils.URI_FLAVORS = [PlacesUtils.TYPE_X_MOZ_URL, TAB_DROP_TYPE, PlacesUtils.TYPE_UNICODE], 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) - } -});
--- a/browser/components/places/content/controller.js +++ b/browser/components/places/content/controller.js @@ -1005,29 +1005,29 @@ PlacesController.prototype = { * @param [in] aContainerNode * The container node to remove. * * @note history deletes are not undoable. */ _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]; let beginTime = query.beginTime; let endTime = query.endTime; NS_ASSERT(query && beginTime && endTime, "A valid date container query should exist!"); // We want to exclude beginTime from the removal because // 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); } }, /** * Removes the selection * @param aTxnName * A name for the transaction if this is being performed * as part of another operation.
--- a/browser/components/places/content/editBookmarkOverlay.js +++ b/browser/components/places/content/editBookmarkOverlay.js @@ -16,18 +16,17 @@ var gEditItemOverlay = { if (!aInitInfo) return this._paneInfo = null; if ("uris" in aInitInfo && "node" in aInitInfo) throw new Error("ambiguous pane info"); 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 // folders), when the pane shows for them it's opened in read-only mode, showing the // properties of the target folder. let itemId = node ? node.itemId : -1; let itemGuid = node ? PlacesUtils.getConcreteItemGuid(node) : null; let isItem = itemId != -1;
--- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -32,17 +32,16 @@ Cu.importGlobalProperties(["URL"]); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetters(this, { Services: "resource://gre/modules/Services.jsm", 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", PlacesSyncUtils: "resource://gre/modules/PlacesSyncUtils.jsm", }); // The minimum amount of transactions before starting a batch. Usually we do // do incremental updates, a batch will cause views to completely @@ -1941,20 +1940,16 @@ XPCOMUtils.defineLazyGetter(PlacesUtils, } })); }); 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"); XPCOMUtils.defineLazyServiceGetter(this, "bmsvc", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService"); XPCOMUtils.defineLazyGetter(PlacesUtils, "bookmarks", () => {
--- a/toolkit/components/places/nsIBrowserHistory.idl +++ b/toolkit/components/places/nsIBrowserHistory.idl @@ -9,40 +9,16 @@ #include "nsISupports.idl" #include "nsIGlobalHistory2.idl" [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. * * @param aHost * Hostname to be removed. * An empty host name means local files and anything else with no * hostname. You can also pass in the localized "(local files)" * title given to you from a history query to remove all * history information from local files.
--- a/toolkit/components/places/nsLivemarkService.js +++ b/toolkit/components/places/nsLivemarkService.js @@ -7,18 +7,16 @@ const { classes: Cc, interfaces: Ci, res // Modules and services. Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); 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. PlacesUtils.history.addObserver(PlacesUtils.livemarks, true); return PlacesUtils.asyncHistory; }); // Constants
--- a/toolkit/components/places/nsNavHistory.cpp +++ b/toolkit/components/places/nsNavHistory.cpp @@ -2532,91 +2532,16 @@ nsNavHistory::CleanupPlacesOnVisitsDelet nsINavHistoryObserver, OnDeleteURI(URIs[i], GUIDs[i], nsINavHistoryObserver::REASON_DELETED)); } return NS_OK; } -// 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 // given host. If aEntireDomain is set, we will also delete pages from // sub hosts (so if we are passed in "microsoft.com" we delete // "www.microsoft.com", "msdn.microsoft.com", etc.). An empty host name // means local files and anything else with no host name. You can also pass // in the localized "(local files)" title given to you from a history query.
--- a/toolkit/components/places/nsTaggingService.js +++ b/toolkit/components/places/nsTaggingService.js @@ -5,18 +5,16 @@ const Cc = Components.classes; const Ci = Components.interfaces; 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"; /** * The Places Tagging Service */ function TaggingService() { // Observe bookmarks changes. @@ -216,18 +214,18 @@ TaggingService.prototype = { aTags = this.getTagsForURI(aURI); } // This also does some input validation. let tags = this._convertInputMixedTagsArray(aTags); 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) { if (tag.id != -1) { // A tag could exist. let itemId = this._getItemIdForTaggedURI(aURI, tag.name); if (itemId != -1) { // There is a tagged item. @@ -239,18 +237,18 @@ TaggingService.prototype = { // nsITaggingService getURIsForTag: function TS_getURIsForTag(aTagName) { if (!aTagName || aTagName.length == 0) { throw Components.Exception("Invalid tag name", Cr.NS_ERROR_INVALID_ARG); } 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 = []; let tagId = this._getItemIdForTag(aTagName); if (tagId == -1) return uris; let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
--- a/toolkit/components/places/tests/unit/test_browserhistory.js +++ b/toolkit/components/places/tests/unit/test_browserhistory.js @@ -69,38 +69,38 @@ add_task(async function test_removePages uri: NetUtil.newURI(TEST_URI.spec + i), visitDate: startDate + i * 1000 }); } 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++) { do_check_eq(page_in_database(NetUtil.newURI(TEST_URI.spec + i)) == 0, i > 0 && i < 9); } // 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); }); add_task(async function test_history_clear() { await PlacesTestUtils.clearHistory(); do_check_eq(0, PlacesUtils.history.hasHistoryEntries); });