.downloadDetails[tooltiptext]::after { content: attr(tooltiptext) !important; }
const DownloadsView = { ////////////////////////////////////////////////////////////////////////////// //// Functions handling download items in the list /** * Maximum number of items shown by the list at any given time. */ kItemCountLimit: 3,
/** * Returns a reference to the DownloadsSummaryData singleton - creating one * in the process if one hasn't been instantiated yet. * * @param aWindow * The browser window which owns the download button. * @param aNumToExclude * The number of items on the top of the downloads list to exclude * from the summary. */ getSummary: function DC_getSummary(aWindow, aNumToExclude) { if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (this._privateSummary) { return this._privateSummary; } return this._privateSummary = new DownloadsSummaryData(true, aNumToExclude); } else { if (this._summary) { return this._summary; } return this._summary = new DownloadsSummaryData(false, aNumToExclude); } },
/** * DownloadsSummaryData is a view for DownloadsData that produces a summary * of all downloads after a certain exclusion point aNumToExclude. For example, * if there were 5 downloads in progress, and a DownloadsSummaryData was * constructed with aNumToExclude equal to 3, then that DownloadsSummaryData * would produce a summary of the last 2 downloads. * * @param aIsPrivate * True if the browser window which owns the download button is a private * window. * @param aNumToExclude * The number of items to exclude from the summary, starting from the * top of the list. */ function DownloadsSummaryData(aIsPrivate, aNumToExclude) { this._numToExclude = aNumToExclude;
var itemCountLimit = 5; // 3 5 if(DownloadsCommon._privateSummary) DownloadsCommon._privateSummary._numToExclude = itemCountLimit; if(DownloadsCommon._summary) DownloadsCommon._summary._numToExclude = itemCountLimit;
DownloadsView._viewItems = {}; DownloadsView._dataItems = [];
DownloadsView._viewItems = new window.Object(); DownloadsView._dataItems = new window.Array();
case "browser-lastwindow-close-granted": // When using the panel interface, downloads that are already completed // should be removed when the last full browser window is closed. This // event is invoked only if the application is not shutting down yet. // If the Download Manager service is not initialized, we don't want to // initialize it just to clean up completed downloads, because they can // be present only in case there was a browser crash or restart. if (this._downloadsServiceInitialized && !DownloadsCommon.useToolkitUI) { Services.downloads.cleanUp(); } break; ... case "quit-application": ... // When using the panel interface, downloads that are already completed // should be removed when quitting the application. if (!DownloadsCommon.useToolkitUI && aData != "restart") { this._cleanupOnShutdown = true; } break; case "profile-change-teardown": // If we need to clean up, we must do it synchronously after all the // "quit-application" listeners are invoked, so that the Download // Manager service has a chance to pause or cancel in-progress downloads // before we remove completed downloads from the list. Note that, since // "quit-application" was invoked, we've already exited Private Browsing // Mode, thus we are always working on the disk database. if (this._cleanupOnShutdown) { Services.downloads.cleanUp(); }
Components.classes["@mozilla.org/download-manager;1"] .getService(Components.interfaces.nsIDownloadManager);
Object.defineProperty(Services.downloads, "cleanUp", { value: function() {}, enumerable: true, configurable: true, writable: true }); // Exception: can't redefine non-configurable property 'cleanUp'
var downloads = Services.downloads; var downloadsWrapper = { __proto__: downloads, cleanUp: function() { ... } }; this.setProperty(Services, "downloads", downloadsWrapper);
this.DownloadStore.prototype = { ... /** * This function is called with a Download object as its first argument, and * should return true if the item should be saved. */ onsaveitem: () => true, ... /** * Saves persistent downloads from the list to the file. * * If an error occurs, the previous file is not deleted. * * @return {Promise} * @resolves When the operation finished successfully. * @rejects JavaScript exception. */ save: function DS_save() { return Task.spawn(function task_DS_save() { let downloads = yield this.list.getAll(); ... for (let download of downloads) { try { if (!this.onsaveitem(download)) { continue; }
this.DownloadIntegration = { ... initializePublicDownloadList: function(aList) { return Task.spawn(function task_DI_initializePublicDownloadList() { ... this._store.onsaveitem = this.shouldPersistDownload.bind(this); ... /** * Determines if a Download object from the list of persistent downloads * should be saved into a file, so that it can be restored across sessions. * * This function allows filtering out downloads that the host application is * not interested in persisting across sessions, for example downloads that * finished successfully. * * @param aDownload * The Download object to be inspected. This is originally taken from * the global DownloadList object for downloads that were not started * from a private browsing window. The item may have been removed * from the list since the save operation started, though in this case * the save operation will be repeated later. * * @return True to save the download, false otherwise. */ shouldPersistDownload: function (aDownload) { // In the default implementation, we save all the downloads currently in // progress, as well as stopped downloads for which we retained partially // downloaded data. Stopped downloads for which we don't need to track the // presence of a ".part" file are only retained in the browser history. // On b2g, we keep a few days of history. //@line 319 "c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\toolkit\components\jsdownloads\src\DownloadIntegration.jsm" return aDownload.hasPartialData || !aDownload.stopped; //@line 321 "c:\builds\moz2_slave\m-cen-w32-ntly-000000000000000\build\toolkit\components\jsdownloads\src\DownloadIntegration.jsm" },
shouldPersistDownload: function (aDownload) { // In the default implementation, we save all the downloads currently in // progress, as well as stopped downloads for which we retained partially // downloaded data. Stopped downloads for which we don't need to track the // presence of a ".part" file are only retained in the browser history. // On b2g, we keep a few days of history. #ifdef MOZ_B2G let maxTime = Date.now() - Services.prefs.getIntPref("dom.downloads.max_retention_days") * 24 * 60 * 60 * 1000; return (aDownload.startTime > maxTime) || aDownload.hasPartialData || !aDownload.stopped; #else return aDownload.hasPartialData || !aDownload.stopped; #endif },
/** * Represents a single item in the list of downloads. * * The endTime property is initialized to the current date and time. * * @param aDownload * The Download object with the current state. */ function DownloadsDataItem(aDownload) { this._download = aDownload; ... this.endTime = Date.now(); this.updateFromDownload(); }
/** * Loads persistent downloads from the file to the list. * * @return {Promise} * @resolves When the operation finished successfully. * @rejects JavaScript exception. */ load: function DS_load() { return Task.spawn(function task_DS_load() { let bytes; try { bytes = yield OS.File.read(this.path); } catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) { // If the file does not exist, there are no downloads to load. return; } let storeData = JSON.parse(gTextDecoder.decode(bytes)); // Create live downloads based on the static snapshot. for (let downloadData of storeData.list) { try { let download = yield Downloads.createDownload(downloadData);
let {Download} = Components.utils.import("resource://gre/modules/DownloadCore.jsm", {}); let download = Download.fromSerializable(downloadData);
Error: Win error 2 during operation open (Can not find the file specified.(This is if you delete the file of the paused download)
)
Source file: resource: //gre/modules/commonjs/sdk/core/promise.js
Line: 133
Source: https://habr.com/ru/post/215175/
All Articles