[Pale-Moon] Issue MoonchildProductions/UXP#516 - Remove named function syntax from palemoon/components/downloads.

This commit is contained in:
athenian200 2020-02-06 06:47:04 -06:00 • committed by Roy Tam
commit dd6ed2537f
8 changed files with 162 additions and 162 deletions

View file

@ -97,7 +97,7 @@ const kPrefBranch = Services.prefs.getBranch("browser.download.");
var PrefObserver = { var PrefObserver = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver, QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]), Ci.nsISupportsWeakReference]),
getPref: function PO_getPref(name) { getPref: function (name) {
try { try {
switch (typeof this.prefs[name]) { switch (typeof this.prefs[name]) {
case "boolean": case "boolean":
@ -106,12 +106,12 @@ var PrefObserver = {
} catch (ex) { } } catch (ex) { }
return this.prefs[name]; return this.prefs[name];
}, },
observe: function PO_observe(aSubject, aTopic, aData) { observe: function (aSubject, aTopic, aData) {
if (this.prefs.hasOwnProperty(aData)) { if (this.prefs.hasOwnProperty(aData)) {
return this[aData] = this.getPref(aData); return this[aData] = this.getPref(aData);
} }
}, },
register: function PO_register(prefs) { register: function (prefs) {
this.prefs = prefs; this.prefs = prefs;
kPrefBranch.addObserver("", this, true); kPrefBranch.addObserver("", this, true);
for (let key in prefs) { for (let key in prefs) {
@ -138,9 +138,9 @@ PrefObserver.register({
* and provides shared methods for all the instances of the user interface. * and provides shared methods for all the instances of the user interface.
*/ */
this.DownloadsCommon = { this.DownloadsCommon = {
log: function DC_log(...aMessageArgs) { log: function (...aMessageArgs) {
delete this.log; delete this.log;
this.log = function DC_log(...aMessageArgs) { this.log = function (...aMessageArgs) {
if (!PrefObserver.debug) { if (!PrefObserver.debug) {
return; return;
} }
@ -149,9 +149,9 @@ this.DownloadsCommon = {
this.log.apply(this, aMessageArgs); this.log.apply(this, aMessageArgs);
}, },
error: function DC_error(...aMessageArgs) { error: function (...aMessageArgs) {
delete this.error; delete this.error;
this.error = function DC_error(...aMessageArgs) { this.error = function (...aMessageArgs) {
if (!PrefObserver.debug) { if (!PrefObserver.debug) {
return; return;
} }
@ -205,7 +205,7 @@ this.DownloadsCommon = {
* @return Formatted string, for example "30s" or "2h". The returned value is * @return Formatted string, for example "30s" or "2h". The returned value is
* maximum three characters long, at least in English. * maximum three characters long, at least in English.
*/ */
formatTimeLeft: function DC_formatTimeLeft(aSeconds) formatTimeLeft: function (aSeconds)
{ {
// Decide what text to show for the time // Decide what text to show for the time
let seconds = Math.round(aSeconds); let seconds = Math.round(aSeconds);
@ -259,7 +259,7 @@ this.DownloadsCommon = {
* @param aWindow * @param aWindow
* The browser window which owns the download button. * The browser window which owns the download button.
*/ */
getData: function DC_getData(aWindow) { getData: function (aWindow) {
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
return PrivateDownloadsData; return PrivateDownloadsData;
} else { } else {
@ -277,7 +277,7 @@ this.DownloadsCommon = {
* called, and we must ensure to register our listeners before the * called, and we must ensure to register our listeners before the
* getService call for the Download Manager returns. * getService call for the Download Manager returns.
*/ */
initializeAllDataLinks: function DC_initializeAllDataLinks(aDownloadManagerService) { initializeAllDataLinks: function (aDownloadManagerService) {
DownloadsData.initializeDataLink(aDownloadManagerService); DownloadsData.initializeDataLink(aDownloadManagerService);
PrivateDownloadsData.initializeDataLink(aDownloadManagerService); PrivateDownloadsData.initializeDataLink(aDownloadManagerService);
}, },
@ -286,7 +286,7 @@ this.DownloadsCommon = {
* Terminates the data link for both the private and non-private downloads * Terminates the data link for both the private and non-private downloads
* data objects. * data objects.
*/ */
terminateAllDataLinks: function DC_terminateAllDataLinks() { terminateAllDataLinks: function () {
DownloadsData.terminateDataLink(); DownloadsData.terminateDataLink();
PrivateDownloadsData.terminateDataLink(); PrivateDownloadsData.terminateDataLink();
}, },
@ -299,7 +299,7 @@ this.DownloadsCommon = {
* True to load only active downloads from the database. * True to load only active downloads from the database.
*/ */
ensureAllPersistentDataLoaded: ensureAllPersistentDataLoaded:
function DC_ensureAllPersistentDataLoaded(aActiveOnly) { function (aActiveOnly) {
DownloadsData.ensurePersistentDataLoaded(aActiveOnly); DownloadsData.ensurePersistentDataLoaded(aActiveOnly);
}, },
@ -308,7 +308,7 @@ this.DownloadsCommon = {
* PrivateDownloadsIndicatorData objects, depending on the privacy status of * PrivateDownloadsIndicatorData objects, depending on the privacy status of
* the window in question. * the window in question.
*/ */
getIndicatorData: function DC_getIndicatorData(aWindow) { getIndicatorData: function (aWindow) {
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
return PrivateDownloadsIndicatorData; return PrivateDownloadsIndicatorData;
} else { } else {
@ -326,7 +326,7 @@ this.DownloadsCommon = {
* The number of items on the top of the downloads list to exclude * The number of items on the top of the downloads list to exclude
* from the summary. * from the summary.
*/ */
getSummary: function DC_getSummary(aWindow, aNumToExclude) getSummary: function (aWindow, aNumToExclude)
{ {
if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) { if (PrivateBrowsingUtils.isWindowPrivate(aWindow)) {
if (this._privateSummary) { if (this._privateSummary) {
@ -465,7 +465,7 @@ this.DownloadsCommon = {
* downloads. This is a floating point value to help get sub-second * downloads. This is a floating point value to help get sub-second
* accuracy for current and future estimates. * accuracy for current and future estimates.
*/ */
smoothSeconds: function DC_smoothSeconds(aSeconds, aLastSeconds) smoothSeconds: function (aSeconds, aLastSeconds)
{ {
// We apply an algorithm similar to the DownloadUtils.getTimeLeft function, // We apply an algorithm similar to the DownloadUtils.getTimeLeft function,
// though tailored to a single time estimation for all downloads. We never // though tailored to a single time estimation for all downloads. We never
@ -503,7 +503,7 @@ this.DownloadsCommon = {
* @param aOwnerWindow * @param aOwnerWindow
* the window with which this action is associated. * the window with which this action is associated.
*/ */
openDownloadedFile: function DC_openDownloadedFile(aFile, aMimeInfo, aOwnerWindow) { openDownloadedFile: function (aFile, aMimeInfo, aOwnerWindow) {
if (!(aFile instanceof Ci.nsIFile)) if (!(aFile instanceof Ci.nsIFile))
throw new Error("aFile must be a nsIFile object"); throw new Error("aFile must be a nsIFile object");
if (aMimeInfo && !(aMimeInfo instanceof Ci.nsIMIMEInfo)) if (aMimeInfo && !(aMimeInfo instanceof Ci.nsIMIMEInfo))
@ -572,7 +572,7 @@ this.DownloadsCommon = {
* @param aFile * @param aFile
* a downloaded file. * a downloaded file.
*/ */
showDownloadedFile: function DC_showDownloadedFile(aFile) { showDownloadedFile: function (aFile) {
if (!(aFile instanceof Ci.nsIFile)) if (!(aFile instanceof Ci.nsIFile))
throw new Error("aFile must be a nsIFile object"); throw new Error("aFile must be a nsIFile object");
try { try {
@ -669,7 +669,7 @@ DownloadsDataCtor.prototype = {
/** /**
* Stops receiving events for current downloads and cancels any pending read. * Stops receiving events for current downloads and cancels any pending read.
*/ */
terminateDataLink: function DD_terminateDataLink() terminateDataLink: function ()
{ {
Cu.reportError("terminateDataLink not applicable with JS Transfers"); Cu.reportError("terminateDataLink not applicable with JS Transfers");
return; return;
@ -698,7 +698,7 @@ DownloadsDataCtor.prototype = {
/** /**
* Asks the back-end to remove finished downloads from the list. * Asks the back-end to remove finished downloads from the list.
*/ */
removeFinished: function DD_removeFinished() removeFinished: function ()
{ {
let promiseList = Downloads.getList(this._isPrivate ? Downloads.PRIVATE let promiseList = Downloads.getList(this._isPrivate ? Downloads.PRIVATE
: Downloads.PUBLIC); : Downloads.PUBLIC);
@ -804,7 +804,7 @@ DownloadsDataCtor.prototype = {
* DownloadsView object to be added. This reference must be passed to * DownloadsView object to be added. This reference must be passed to
* removeView before termination. * removeView before termination.
*/ */
addView: function DD_addView(aView) addView: function (aView)
{ {
this._views.push(aView); this._views.push(aView);
this._updateView(aView); this._updateView(aView);
@ -816,7 +816,7 @@ DownloadsDataCtor.prototype = {
* @param aView * @param aView
* DownloadsView object to be removed. * DownloadsView object to be removed.
*/ */
removeView: function DD_removeView(aView) removeView: function (aView)
{ {
let index = this._views.indexOf(aView); let index = this._views.indexOf(aView);
if (index != -1) { if (index != -1) {
@ -830,7 +830,7 @@ DownloadsDataCtor.prototype = {
* @param aView * @param aView
* DownloadsView object to be initialized. * DownloadsView object to be initialized.
*/ */
_updateView: function DD_updateView(aView) _updateView: function (aView)
{ {
// Indicate to the view that a batch loading operation is in progress. // Indicate to the view that a batch loading operation is in progress.
aView.onDataLoadStarting(); aView.onDataLoadStarting();
@ -857,7 +857,7 @@ DownloadsDataCtor.prototype = {
/** /**
* Clears the loaded data. * Clears the loaded data.
*/ */
clear: function DD_clear() clear: function ()
{ {
this._terminateDataAccess(); this._terminateDataAccess();
this.dataItems = {}; this.dataItems = {};
@ -890,7 +890,7 @@ DownloadsDataCtor.prototype = {
* @return New or existing data item, or null if the item was deleted from the * @return New or existing data item, or null if the item was deleted from the
* list of available downloads. * list of available downloads.
*/ */
_getOrAddDataItem: function DD_getOrAddDataItem(aSource, aMayReuseGUID) _getOrAddDataItem: function (aSource, aMayReuseGUID)
{ {
let downloadGuid = (aSource instanceof Ci.nsIDownload) let downloadGuid = (aSource instanceof Ci.nsIDownload)
? aSource.guid ? aSource.guid
@ -920,7 +920,7 @@ DownloadsDataCtor.prototype = {
* *
* This method can be called at most once per download identifier. * This method can be called at most once per download identifier.
*/ */
_removeDataItem: function DD_removeDataItem(aDownloadId) _removeDataItem: function (aDownloadId)
{ {
if (aDownloadId in this.dataItems) { if (aDownloadId in this.dataItems) {
let dataItem = this.dataItems[aDownloadId]; let dataItem = this.dataItems[aDownloadId];
@ -961,7 +961,7 @@ DownloadsDataCtor.prototype = {
* True to load only active downloads from the database. * True to load only active downloads from the database.
*/ */
ensurePersistentDataLoaded: ensurePersistentDataLoaded:
function DD_ensurePersistentDataLoaded(aActiveOnly) function (aActiveOnly)
{ {
if (this == PrivateDownloadsData) { if (this == PrivateDownloadsData) {
Cu.reportError("ensurePersistentDataLoaded should not be called on PrivateDownloadsData"); Cu.reportError("ensurePersistentDataLoaded should not be called on PrivateDownloadsData");
@ -1022,7 +1022,7 @@ DownloadsDataCtor.prototype = {
/** /**
* Cancels any pending data access and ensures views are notified. * Cancels any pending data access and ensures views are notified.
*/ */
_terminateDataAccess: function DD_terminateDataAccess() _terminateDataAccess: function ()
{ {
if (this._pendingStatement) { if (this._pendingStatement) {
this._pendingStatement.cancel(); this._pendingStatement.cancel();
@ -1039,7 +1039,7 @@ DownloadsDataCtor.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// mozIStorageStatementCallback //// mozIStorageStatementCallback
handleResult: function DD_handleResult(aResultSet) handleResult: function (aResultSet)
{ {
for (let row = aResultSet.getNextRow(); for (let row = aResultSet.getNextRow();
row; row;
@ -1051,13 +1051,13 @@ DownloadsDataCtor.prototype = {
} }
}, },
handleError: function DD_handleError(aError) handleError: function (aError)
{ {
DownloadsCommon.error("Database statement execution error (", DownloadsCommon.error("Database statement execution error (",
aError.result, "): ", aError.message); aError.result, "): ", aError.message);
}, },
handleCompletion: function DD_handleCompletion(aReason) handleCompletion: function (aReason)
{ {
DownloadsCommon.log("Loading all downloads from database completed with reason:", DownloadsCommon.log("Loading all downloads from database completed with reason:",
aReason); aReason);
@ -1083,7 +1083,7 @@ DownloadsDataCtor.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsIObserver //// nsIObserver
observe: function DD_observe(aSubject, aTopic, aData) observe: function (aSubject, aTopic, aData)
{ {
switch (aTopic) { switch (aTopic) {
case "download-manager-remove-download-guid": case "download-manager-remove-download-guid":
@ -1121,7 +1121,7 @@ DownloadsDataCtor.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsIDownloadProgressListener //// nsIDownloadProgressListener
onDownloadStateChange: function DD_onDownloadStateChange(aOldState, aDownload) onDownloadStateChange: function (aOldState, aDownload)
{ {
if (aDownload.isPrivate != this._isPrivate) { if (aDownload.isPrivate != this._isPrivate) {
// Ignore the downloads with a privacy status other than what we are // Ignore the downloads with a privacy status other than what we are
@ -1202,7 +1202,7 @@ DownloadsDataCtor.prototype = {
} }
}, },
onProgressChange: function DD_onProgressChange(aWebProgress, aRequest, onProgressChange: function (aWebProgress, aRequest,
aCurSelfProgress, aCurSelfProgress,
aMaxSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aCurTotalProgress,
@ -1259,7 +1259,7 @@ DownloadsDataCtor.prototype = {
* @param aType * @param aType
* Set to "start" for new downloads, "finish" for completed downloads. * Set to "start" for new downloads, "finish" for completed downloads.
*/ */
_notifyDownloadEvent: function DD_notifyDownloadEvent(aType) _notifyDownloadEvent: function (aType)
{ {
DownloadsCommon.log("Attempting to notify that a new download has started or finished."); DownloadsCommon.log("Attempting to notify that a new download has started or finished.");
if (DownloadsCommon.useToolkitUI) { if (DownloadsCommon.useToolkitUI) {
@ -1329,7 +1329,7 @@ const DownloadsViewPrototype = {
* View object to be added. This reference must be * View object to be added. This reference must be
* passed to removeView before termination. * passed to removeView before termination.
*/ */
addView: function DVP_addView(aView) addView: function (aView)
{ {
// Start receiving events when the first of our views is registered. // Start receiving events when the first of our views is registered.
if (this._views.length == 0) { if (this._views.length == 0) {
@ -1350,7 +1350,7 @@ const DownloadsViewPrototype = {
* @param aView * @param aView
* View object to be updated. * View object to be updated.
*/ */
refreshView: function DVP_refreshView(aView) refreshView: function (aView)
{ {
// Update immediately even if we are still loading data asynchronously. // Update immediately even if we are still loading data asynchronously.
// Subclasses must provide these two functions! // Subclasses must provide these two functions!
@ -1364,7 +1364,7 @@ const DownloadsViewPrototype = {
* @param aView * @param aView
* View object to be removed. * View object to be removed.
*/ */
removeView: function DVP_removeView(aView) removeView: function (aView)
{ {
let index = this._views.indexOf(aView); let index = this._views.indexOf(aView);
if (index != -1) { if (index != -1) {
@ -1392,7 +1392,7 @@ const DownloadsViewPrototype = {
/** /**
* Called before multiple downloads are about to be loaded. * Called before multiple downloads are about to be loaded.
*/ */
onDataLoadStarting: function DVP_onDataLoadStarting() onDataLoadStarting: function ()
{ {
this._loading = true; this._loading = true;
}, },
@ -1400,7 +1400,7 @@ const DownloadsViewPrototype = {
/** /**
* Called after data loading finished. * Called after data loading finished.
*/ */
onDataLoadCompleted: function DVP_onDataLoadCompleted() onDataLoadCompleted: function ()
{ {
this._loading = false; this._loading = false;
}, },
@ -1412,7 +1412,7 @@ const DownloadsViewPrototype = {
* *
* @note Subclasses should override this. * @note Subclasses should override this.
*/ */
onDataInvalidated: function DVP_onDataInvalidated() onDataInvalidated: function ()
{ {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED; throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}, },
@ -1481,7 +1481,7 @@ const DownloadsViewPrototype = {
* *
* @note Subclasses should override this. * @note Subclasses should override this.
*/ */
_refreshProperties: function DID_refreshProperties() _refreshProperties: function ()
{ {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED; throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
}, },
@ -1491,7 +1491,7 @@ const DownloadsViewPrototype = {
* *
* @note Subclasses should override this. * @note Subclasses should override this.
*/ */
_updateView: function DID_updateView() _updateView: function ()
{ {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED; throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
} }
@ -1523,7 +1523,7 @@ DownloadsIndicatorDataCtor.prototype = {
* @param aView * @param aView
* DownloadsIndicatorView object to be removed. * DownloadsIndicatorView object to be removed.
*/ */
removeView: function DID_removeView(aView) removeView: function (aView)
{ {
DownloadsViewPrototype.removeView.call(this, aView); DownloadsViewPrototype.removeView.call(this, aView);
@ -1535,7 +1535,7 @@ DownloadsIndicatorDataCtor.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// Callback functions from DownloadsData //// Callback functions from DownloadsData
onDataLoadCompleted: function DID_onDataLoadCompleted() onDataLoadCompleted: function ()
{ {
DownloadsViewPrototype.onDataLoadCompleted.call(this); DownloadsViewPrototype.onDataLoadCompleted.call(this);
this._updateViews(); this._updateViews();
@ -1546,7 +1546,7 @@ DownloadsIndicatorDataCtor.prototype = {
* entered Private Browsing Mode and the database backend changed). * entered Private Browsing Mode and the database backend changed).
* References to existing data should be discarded. * References to existing data should be discarded.
*/ */
onDataInvalidated: function DID_onDataInvalidated() onDataInvalidated: function ()
{ {
this._itemCount = 0; this._itemCount = 0;
}, },
@ -1612,7 +1612,7 @@ DownloadsIndicatorDataCtor.prototype = {
/** /**
* Computes aggregate values and propagates the changes to our views. * Computes aggregate values and propagates the changes to our views.
*/ */
_updateViews: function DID_updateViews() _updateViews: function ()
{ {
// Do not update the status indicators during batch loads of download items. // Do not update the status indicators during batch loads of download items.
if (this._loading) { if (this._loading) {
@ -1629,7 +1629,7 @@ DownloadsIndicatorDataCtor.prototype = {
* @param aView * @param aView
* DownloadsIndicatorView object to be updated. * DownloadsIndicatorView object to be updated.
*/ */
_updateView: function DID_updateView(aView) _updateView: function (aView)
{ {
aView.hasDownloads = this._hasDownloads; aView.hasDownloads = this._hasDownloads;
aView.counter = this._counter; aView.counter = this._counter;
@ -1681,7 +1681,7 @@ DownloadsIndicatorDataCtor.prototype = {
/** /**
* Computes aggregate values based on the current state of downloads. * Computes aggregate values based on the current state of downloads.
*/ */
_refreshProperties: function DID_refreshProperties() _refreshProperties: function ()
{ {
let summary = let summary =
DownloadsCommon.summarizeDownloads(this._activeDownloads()); DownloadsCommon.summarizeDownloads(this._activeDownloads());
@ -1780,7 +1780,7 @@ DownloadsSummaryData.prototype = {
* @param aView * @param aView
* DownloadsSummary view to be removed. * DownloadsSummary view to be removed.
*/ */
removeView: function DSD_removeView(aView) removeView: function (aView)
{ {
DownloadsViewPrototype.removeView.call(this, aView); DownloadsViewPrototype.removeView.call(this, aView);
@ -1796,13 +1796,13 @@ DownloadsSummaryData.prototype = {
//// DownloadsViewPrototype for more information on what these functions //// DownloadsViewPrototype for more information on what these functions
//// are used for. //// are used for.
onDataLoadCompleted: function DSD_onDataLoadCompleted() onDataLoadCompleted: function ()
{ {
DownloadsViewPrototype.onDataLoadCompleted.call(this); DownloadsViewPrototype.onDataLoadCompleted.call(this);
this._updateViews(); this._updateViews();
}, },
onDataInvalidated: function DSD_onDataInvalidated() onDataInvalidated: function ()
{ {
this._dataItems = []; this._dataItems = [];
}, },
@ -1839,7 +1839,7 @@ DownloadsSummaryData.prototype = {
/** /**
* Computes aggregate values and propagates the changes to our views. * Computes aggregate values and propagates the changes to our views.
*/ */
_updateViews: function DSD_updateViews() _updateViews: function ()
{ {
// Do not update the status indicators during batch loads of download items. // Do not update the status indicators during batch loads of download items.
if (this._loading) { if (this._loading) {
@ -1856,7 +1856,7 @@ DownloadsSummaryData.prototype = {
* @param aView * @param aView
* DownloadsIndicatorView object to be updated. * DownloadsIndicatorView object to be updated.
*/ */
_updateView: function DSD_updateView(aView) _updateView: function (aView)
{ {
aView.showingProgress = this._showingProgress; aView.showingProgress = this._showingProgress;
aView.percentComplete = this._percentComplete; aView.percentComplete = this._percentComplete;
@ -1885,7 +1885,7 @@ DownloadsSummaryData.prototype = {
/** /**
* Computes aggregate values based on the current state of downloads. * Computes aggregate values based on the current state of downloads.
*/ */
_refreshProperties: function DSD_refreshProperties() _refreshProperties: function ()
{ {
// Pre-load summary with default values. // Pre-load summary with default values.
let summary = let summary =

View file

@ -24,7 +24,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
this.DownloadsLogger = { this.DownloadsLogger = {
_generateLogMessage: function _generateLogMessage(args) { _generateLogMessage: function (args) {
// create a string representation of a list of arbitrary things // create a string representation of a list of arbitrary things
let strings = []; let strings = [];
@ -51,7 +51,7 @@ this.DownloadsLogger = {
* *
* Enable with about:config pref browser.download.debug * Enable with about:config pref browser.download.debug
*/ */
log: function DL_log(...args) { log: function (...args) {
let output = this._generateLogMessage(args); let output = this._generateLogMessage(args);
dump(output + "\n"); dump(output + "\n");
@ -63,7 +63,7 @@ this.DownloadsLogger = {
* reportError() - report an error through component utils as well as * reportError() - report an error through component utils as well as
* our log function * our log function
*/ */
reportError: function DL_reportError(...aArgs) { reportError: function (...aArgs) {
// Report the error in the browser // Report the error in the browser
let output = this._generateLogMessage(aArgs); let output = this._generateLogMessage(aArgs);
Cu.reportError(output); Cu.reportError(output);

View file

@ -82,7 +82,7 @@ DownloadsStartup.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsIObserver //// nsIObserver
observe: function DS_observe(aSubject, aTopic, aData) observe: function (aSubject, aTopic, aData)
{ {
switch (aTopic) { switch (aTopic) {
case "profile-after-change": case "profile-after-change":
@ -259,7 +259,7 @@ DownloadsStartup.prototype = {
/** /**
* Ensures that persistent download data is reloaded at the appropriate time. * Ensures that persistent download data is reloaded at the appropriate time.
*/ */
_ensureDataLoaded: function DS_ensureDataLoaded() _ensureDataLoaded: function ()
{ {
if (!this._downloadsServiceInitialized) { if (!this._downloadsServiceInitialized) {
return; return;

View file

@ -60,7 +60,7 @@ DownloadsUI.prototype = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsIDownloadManagerUI //// nsIDownloadManagerUI
show: function DUI_show(aWindowContext, aDownload, aReason, aUsePrivateUI) show: function (aWindowContext, aDownload, aReason, aUsePrivateUI)
{ {
if (DownloadsCommon.useToolkitUI && !PrivateBrowsingUtils.isWindowPrivate(aWindowContext)) { if (DownloadsCommon.useToolkitUI && !PrivateBrowsingUtils.isWindowPrivate(aWindowContext)) {
this._toolkitUI.show(aWindowContext, aDownload, aReason, aUsePrivateUI); this._toolkitUI.show(aWindowContext, aDownload, aReason, aUsePrivateUI);
@ -101,7 +101,7 @@ DownloadsUI.prototype = {
return DownloadsCommon.useToolkitUI ? this._toolkitUI.visible : true; return DownloadsCommon.useToolkitUI ? this._toolkitUI.visible : true;
}, },
getAttention: function DUI_getAttention() getAttention: function ()
{ {
if (DownloadsCommon.useToolkitUI) { if (DownloadsCommon.useToolkitUI) {
this._toolkitUI.getAttention(); this._toolkitUI.getAttention();
@ -112,7 +112,7 @@ DownloadsUI.prototype = {
* Helper function that opens the download manager UI. * Helper function that opens the download manager UI.
*/ */
_showDownloadManagerUI: _showDownloadManagerUI:
function DUI_showDownloadManagerUI(aWindowContext, aUsePrivateUI) function (aWindowContext, aUsePrivateUI)
{ {
// If we weren't given a window context, try to find a browser window // If we weren't given a window context, try to find a browser window
// to use as our parent - and if that doesn't work, error out and give up. // to use as our parent - and if that doesn't work, error out and give up.

View file

@ -213,7 +213,7 @@ HistoryDownloadElementShell.prototype = {
* be activated when entering the visible area. Session downloads are always * be activated when entering the visible area. Session downloads are always
* active. * active.
*/ */
ensureActive: function DES_ensureActive() { ensureActive: function () {
if (!this._active) { if (!this._active) {
this._active = true; this._active = true;
this.element.setAttribute("active", true); this.element.setAttribute("active", true);
@ -305,7 +305,7 @@ HistoryDownloadElementShell.prototype = {
}, },
/* nsIController */ /* nsIController */
isCommandEnabled: function DES_isCommandEnabled(aCommand) { isCommandEnabled: function (aCommand) {
// The only valid command for inactive elements is cmd_delete. // The only valid command for inactive elements is cmd_delete.
if (!this.active && aCommand != "cmd_delete") if (!this.active && aCommand != "cmd_delete")
return false; return false;
@ -340,7 +340,7 @@ HistoryDownloadElementShell.prototype = {
}, },
/* nsIController */ /* nsIController */
doCommand: function DES_doCommand(aCommand) { doCommand: function (aCommand) {
switch (aCommand) { switch (aCommand) {
case "downloadsCmd_open": { case "downloadsCmd_open": {
let file = new FileUtils.File(this.download.target.path); let file = new FileUtils.File(this.download.target.path);
@ -391,7 +391,7 @@ HistoryDownloadElementShell.prototype = {
// Returns whether or not the download handled by this shell should // Returns whether or not the download handled by this shell should
// show up in the search results for the given term. Both the display // show up in the search results for the given term. Both the display
// name for the download and the url are searched. // name for the download and the url are searched.
matchesSearchTerm: function DES_matchesSearchTerm(aTerm) { matchesSearchTerm: function (aTerm) {
if (!aTerm) if (!aTerm)
return true; return true;
aTerm = aTerm.toLowerCase(); aTerm = aTerm.toLowerCase();
@ -401,7 +401,7 @@ HistoryDownloadElementShell.prototype = {
// Handles return keypress on the element (the keypress listener is // Handles return keypress on the element (the keypress listener is
// set in the DownloadsPlacesView object). // set in the DownloadsPlacesView object).
doDefaultCommand: function DES_doDefaultCommand() { doDefaultCommand: function () {
function getDefaultCommandForState(aState) { function getDefaultCommandForState(aState) {
switch (aState) { switch (aState) {
case nsIDM.DOWNLOAD_FINISHED: case nsIDM.DOWNLOAD_FINISHED:
@ -435,7 +435,7 @@ HistoryDownloadElementShell.prototype = {
* existence of the target file already, we can do it now and then update * existence of the target file already, we can do it now and then update
* the commands as needed. * the commands as needed.
*/ */
onSelect: function DES_onSelect() { onSelect: function () {
if (!this.active) if (!this.active)
return; return;
@ -775,7 +775,7 @@ DownloadsPlacesView.prototype = {
} }
}, },
_removeElement: function DPV__removeElement(aElement) { _removeElement: function (aElement) {
// If the element was selected exclusively, select its next // If the element was selected exclusively, select its next
// sibling first, if not, try for previous sibling, if any. // sibling first, if not, try for previous sibling, if any.
if ((aElement.nextSibling || aElement.previousSibling) && if ((aElement.nextSibling || aElement.previousSibling) &&
@ -796,7 +796,7 @@ DownloadsPlacesView.prototype = {
}, },
_removeHistoryDownloadFromView: _removeHistoryDownloadFromView:
function DPV__removeHistoryDownloadFromView(aPlacesNode) { function (aPlacesNode) {
let downloadURI = aPlacesNode.uri; let downloadURI = aPlacesNode.uri;
let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI); let shellsForURI = this._downloadElementsShellsForURI.get(downloadURI);
if (shellsForURI) { if (shellsForURI) {
@ -857,7 +857,7 @@ DownloadsPlacesView.prototype = {
}, },
_ensureVisibleElementsAreActive: _ensureVisibleElementsAreActive:
function DPV__ensureVisibleElementsAreActive() { function () {
if (!this.active || this._ensureVisibleTimer || !this._richlistbox.firstChild) if (!this.active || this._ensureVisibleTimer || !this._richlistbox.firstChild)
return; return;
@ -964,12 +964,12 @@ DownloadsPlacesView.prototype = {
get hasSelection() this.selectedNodes.length > 0, get hasSelection() this.selectedNodes.length > 0,
containerStateChanged: containerStateChanged:
function DPV_containerStateChanged(aNode, aOldState, aNewState) { function (aNode, aOldState, aNewState) {
this.invalidateContainer(aNode) this.invalidateContainer(aNode)
}, },
invalidateContainer: invalidateContainer:
function DPV_invalidateContainer(aContainer) { function (aContainer) {
if (aContainer != this._resultNode) if (aContainer != this._resultNode)
throw new Error("Unexpected container node"); throw new Error("Unexpected container node");
if (!aContainer.containerOpen) if (!aContainer.containerOpen)
@ -1015,7 +1015,7 @@ DownloadsPlacesView.prototype = {
goUpdateDownloadCommands(); goUpdateDownloadCommands();
}, },
_appendDownloadsFragment: function DPV__appendDownloadsFragment(aDOMFragment) { _appendDownloadsFragment: function (aDOMFragment) {
// Workaround multiple reflows hang by removing the richlistbox // Workaround multiple reflows hang by removing the richlistbox
// and adding it back when we're done. // and adding it back when we're done.
@ -1037,11 +1037,11 @@ DownloadsPlacesView.prototype = {
} }
}, },
nodeInserted: function DPV_nodeInserted(aParent, aPlacesNode) { nodeInserted: function (aParent, aPlacesNode) {
this._addDownloadData(null, aPlacesNode); this._addDownloadData(null, aPlacesNode);
}, },
nodeRemoved: function DPV_nodeRemoved(aParent, aPlacesNode, aOldIndex) { nodeRemoved: function (aParent, aPlacesNode, aOldIndex) {
this._removeHistoryDownloadFromView(aPlacesNode); this._removeHistoryDownloadFromView(aPlacesNode);
}, },
@ -1086,7 +1086,7 @@ DownloadsPlacesView.prototype = {
* data is done loading. However, if the selection has changed in-between, * data is done loading. However, if the selection has changed in-between,
* we assume the user has already started using the view and give up. * we assume the user has already started using the view and give up.
*/ */
_ensureInitialSelection: function DPV__ensureInitialSelection() { _ensureInitialSelection: function () {
// Either they're both null, or the selection has not changed in between. // Either they're both null, or the selection has not changed in between.
if (this._richlistbox.selectedItem == this._initiallySelectedElement) { if (this._richlistbox.selectedItem == this._initiallySelectedElement) {
let firstDownloadElement = this._richlistbox.firstChild; let firstDownloadElement = this._richlistbox.firstChild;
@ -1106,7 +1106,7 @@ DownloadsPlacesView.prototype = {
}, },
onDataLoadStarting: function() { }, onDataLoadStarting: function() { },
onDataLoadCompleted: function DPV_onDataLoadCompleted() { onDataLoadCompleted: function () {
this._ensureInitialSelection(); this._ensureInitialSelection();
}, },
@ -1126,7 +1126,7 @@ DownloadsPlacesView.prototype = {
this._removeSessionDownloadFromView(download); this._removeSessionDownloadFromView(download);
}, },
supportsCommand: function DPV_supportsCommand(aCommand) { supportsCommand: function (aCommand) {
if (DOWNLOAD_VIEW_SUPPORTED_COMMANDS.indexOf(aCommand) != -1) { if (DOWNLOAD_VIEW_SUPPORTED_COMMANDS.indexOf(aCommand) != -1) {
// The clear-downloads command may be performed by the toolbar-button, // The clear-downloads command may be performed by the toolbar-button,
// which can be focused on OS X. Thus enable this command even if the // which can be focused on OS X. Thus enable this command even if the
@ -1144,7 +1144,7 @@ DownloadsPlacesView.prototype = {
return false; return false;
}, },
isCommandEnabled: function DPV_isCommandEnabled(aCommand) { isCommandEnabled: function (aCommand) {
switch (aCommand) { switch (aCommand) {
case "cmd_copy": case "cmd_copy":
return this._richlistbox.selectedItems.length > 0; return this._richlistbox.selectedItems.length > 0;
@ -1161,7 +1161,7 @@ DownloadsPlacesView.prototype = {
} }
}, },
_canClearDownloads: function DPV__canClearDownloads() { _canClearDownloads: function () {
// Downloads can be cleared if there's at least one removable download in // Downloads can be cleared if there's at least one removable download in
// the list (either a history download or a completed session download). // the list (either a history download or a completed session download).
// Because history downloads are always removable and are listed after the // Because history downloads are always removable and are listed after the
@ -1177,7 +1177,7 @@ DownloadsPlacesView.prototype = {
}, },
_copySelectedDownloadsToClipboard: _copySelectedDownloadsToClipboard:
function DPV__copySelectedDownloadsToClipboard() { function () {
let urls = [for (element of this._richlistbox.selectedItems) let urls = [for (element of this._richlistbox.selectedItems)
element._shell.download.source.url]; element._shell.download.source.url];
@ -1186,7 +1186,7 @@ DownloadsPlacesView.prototype = {
.copyString(urls.join("\n"), document); .copyString(urls.join("\n"), document);
}, },
_getURLFromClipboardData: function DPV__getURLFromClipboardData() { _getURLFromClipboardData: function () {
let trans = Cc["@mozilla.org/widget/transferable;1"]. let trans = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable); createInstance(Ci.nsITransferable);
trans.init(null); trans.init(null);
@ -1210,19 +1210,19 @@ DownloadsPlacesView.prototype = {
return ["", ""]; return ["", ""];
}, },
_canDownloadClipboardURL: function DPV__canDownloadClipboardURL() { _canDownloadClipboardURL: function () {
let [url, name] = this._getURLFromClipboardData(); let [url, name] = this._getURLFromClipboardData();
return url != ""; return url != "";
}, },
_downloadURLFromClipboard: function DPV__downloadURLFromClipboard() { _downloadURLFromClipboard: function () {
let [url, name] = this._getURLFromClipboardData(); let [url, name] = this._getURLFromClipboardData();
let browserWin = RecentWindow.getMostRecentBrowserWindow(); let browserWin = RecentWindow.getMostRecentBrowserWindow();
let initiatingDoc = browserWin ? browserWin.document : document; let initiatingDoc = browserWin ? browserWin.document : document;
DownloadURL(url, name, initiatingDoc); DownloadURL(url, name, initiatingDoc);
}, },
doCommand: function DPV_doCommand(aCommand) { doCommand: function (aCommand) {
// Commands may be invoked with keyboard shortcuts even if disabled. // Commands may be invoked with keyboard shortcuts even if disabled.
if (!this.isCommandEnabled(aCommand)) { if (!this.isCommandEnabled(aCommand)) {
return; return;
@ -1263,7 +1263,7 @@ DownloadsPlacesView.prototype = {
onEvent: function() { }, onEvent: function() { },
onContextMenu: function DPV_onContextMenu(aEvent) onContextMenu: function (aEvent)
{ {
let element = this._richlistbox.selectedItem; let element = this._richlistbox.selectedItem;
if (!element || !element._shell) if (!element || !element._shell)
@ -1283,7 +1283,7 @@ DownloadsPlacesView.prototype = {
return true; return true;
}, },
onKeyPress: function DPV_onKeyPress(aEvent) { onKeyPress: function (aEvent) {
let selectedElements = this._richlistbox.selectedItems; let selectedElements = this._richlistbox.selectedItems;
if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) { if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN) {
// In the content tree, opening bookmarks by pressing return is only // In the content tree, opening bookmarks by pressing return is only
@ -1304,7 +1304,7 @@ DownloadsPlacesView.prototype = {
} }
}, },
onDoubleClick: function DPV_onDoubleClick(aEvent) { onDoubleClick: function (aEvent) {
if (aEvent.button != 0) if (aEvent.button != 0)
return; return;
@ -1317,11 +1317,11 @@ DownloadsPlacesView.prototype = {
element._shell.doDefaultCommand(); element._shell.doDefaultCommand();
}, },
onScroll: function DPV_onScroll() { onScroll: function () {
this._ensureVisibleElementsAreActive(); this._ensureVisibleElementsAreActive();
}, },
onSelect: function DPV_onSelect() { onSelect: function () {
goUpdateDownloadCommands(); goUpdateDownloadCommands();
let selectedElements = this._richlistbox.selectedItems; let selectedElements = this._richlistbox.selectedItems;
@ -1331,7 +1331,7 @@ DownloadsPlacesView.prototype = {
} }
}, },
onDragStart: function DPV_onDragStart(aEvent) { onDragStart: function (aEvent) {
// TODO Bug 831358: Support d&d for multiple selection. // TODO Bug 831358: Support d&d for multiple selection.
// For now, we just drag the first element. // For now, we just drag the first element.
let selectedItem = this._richlistbox.selectedItem; let selectedItem = this._richlistbox.selectedItem;
@ -1357,7 +1357,7 @@ DownloadsPlacesView.prototype = {
dt.addElement(selectedItem); dt.addElement(selectedItem);
}, },
onDragOver: function DPV_onDragOver(aEvent) { onDragOver: function (aEvent) {
let types = aEvent.dataTransfer.types; let types = aEvent.dataTransfer.types;
if (types.contains("text/uri-list") || if (types.contains("text/uri-list") ||
types.contains("text/x-moz-url") || types.contains("text/x-moz-url") ||
@ -1366,7 +1366,7 @@ DownloadsPlacesView.prototype = {
} }
}, },
onDrop: function DPV_onDrop(aEvent) { onDrop: function (aEvent) {
let dt = aEvent.dataTransfer; let dt = aEvent.dataTransfer;
// If dragged item is from our source, do not try to // If dragged item is from our source, do not try to
// redownload already downloaded file. // redownload already downloaded file.

View file

@ -5,7 +5,7 @@
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm"); Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
var ContentAreaDownloadsView = { var ContentAreaDownloadsView = {
init: function CADV_init() { init: function () {
let view = new DownloadsPlacesView(document.getElementById("downloadsRichListBox")); let view = new DownloadsPlacesView(document.getElementById("downloadsRichListBox"));
// Do not display the Places downloads in private windows // Do not display the Places downloads in private windows
if (!PrivateBrowsingUtils.isWindowPrivate(window)) { if (!PrivateBrowsingUtils.isWindowPrivate(window)) {

View file

@ -122,7 +122,7 @@ const DownloadsPanel = {
* @param aCallback * @param aCallback
* Called when initialization is complete. * Called when initialization is complete.
*/ */
initialize: function DP_initialize(aCallback) initialize: function (aCallback)
{ {
DownloadsCommon.log("Attempting to initialize DownloadsPanel for a window."); DownloadsCommon.log("Attempting to initialize DownloadsPanel for a window.");
if (this._state != this.kStateUninitialized) { if (this._state != this.kStateUninitialized) {
@ -164,7 +164,7 @@ const DownloadsPanel = {
* downloads. The downloads panel can be reopened later, even after this * downloads. The downloads panel can be reopened later, even after this
* function has been called. * function has been called.
*/ */
terminate: function DP_terminate() terminate: function ()
{ {
DownloadsCommon.log("Attempting to terminate DownloadsPanel for a window."); DownloadsCommon.log("Attempting to terminate DownloadsPanel for a window.");
if (this._state == this.kStateUninitialized) { if (this._state == this.kStateUninitialized) {
@ -214,7 +214,7 @@ const DownloadsPanel = {
* initialized the first time this method is called, and the panel is shown * initialized the first time this method is called, and the panel is shown
* only when data is ready. * only when data is ready.
*/ */
showPanel: function DP_showPanel() showPanel: function ()
{ {
DownloadsCommon.log("Opening the downloads panel."); DownloadsCommon.log("Opening the downloads panel.");
@ -240,7 +240,7 @@ const DownloadsPanel = {
* Hides the downloads panel, if visible, but keeps the internal state so that * Hides the downloads panel, if visible, but keeps the internal state so that
* the panel can be reopened quickly if required. * the panel can be reopened quickly if required.
*/ */
hidePanel: function DP_hidePanel() hidePanel: function ()
{ {
DownloadsCommon.log("Closing the downloads panel."); DownloadsCommon.log("Closing the downloads panel.");
@ -297,7 +297,7 @@ const DownloadsPanel = {
* Handles the mousemove event for the panel, which disables focusring * Handles the mousemove event for the panel, which disables focusring
* visualization. * visualization.
*/ */
handleEvent: function DP_handleEvent(aEvent) handleEvent: function (aEvent)
{ {
if (aEvent.type == "mousemove") { if (aEvent.type == "mousemove") {
this.keyFocusing = false; this.keyFocusing = false;
@ -310,7 +310,7 @@ const DownloadsPanel = {
/** /**
* Called after data loading finished. * Called after data loading finished.
*/ */
onViewLoadCompleted: function DP_onViewLoadCompleted() onViewLoadCompleted: function ()
{ {
this._openPopupIfDataReady(); this._openPopupIfDataReady();
}, },
@ -318,13 +318,13 @@ const DownloadsPanel = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// User interface event functions //// User interface event functions
onWindowUnload: function DP_onWindowUnload() onWindowUnload: function ()
{ {
// This function is registered as an event listener, we can't use "this". // This function is registered as an event listener, we can't use "this".
DownloadsPanel.terminate(); DownloadsPanel.terminate();
}, },
onPopupShown: function DP_onPopupShown(aEvent) onPopupShown: function (aEvent)
{ {
// Ignore events raised by nested popups. // Ignore events raised by nested popups.
if (aEvent.target != aEvent.currentTarget) { if (aEvent.target != aEvent.currentTarget) {
@ -346,7 +346,7 @@ const DownloadsPanel = {
this._focusPanel(); this._focusPanel();
}, },
onPopupHidden: function DP_onPopupHidden(aEvent) onPopupHidden: function (aEvent)
{ {
// Ignore events raised by nested popups. // Ignore events raised by nested popups.
if (aEvent.target != aEvent.currentTarget) { if (aEvent.target != aEvent.currentTarget) {
@ -375,7 +375,7 @@ const DownloadsPanel = {
/** /**
* Shows or focuses the user interface dedicated to downloads history. * Shows or focuses the user interface dedicated to downloads history.
*/ */
showDownloadsHistory: function DP_showDownloadsHistory() showDownloadsHistory: function ()
{ {
DownloadsCommon.log("Showing download history."); DownloadsCommon.log("Showing download history.");
// Hide the panel before showing another window, otherwise focus will return // Hide the panel before showing another window, otherwise focus will return
@ -393,7 +393,7 @@ const DownloadsPanel = {
* removed in _unattachEventListeners. This is called automatically after the * removed in _unattachEventListeners. This is called automatically after the
* panel has successfully loaded. * panel has successfully loaded.
*/ */
_attachEventListeners: function DP__attachEventListeners() _attachEventListeners: function ()
{ {
// Handle keydown to support accel-V. // Handle keydown to support accel-V.
this.panel.addEventListener("keydown", this._onKeyDown.bind(this), false); this.panel.addEventListener("keydown", this._onKeyDown.bind(this), false);
@ -406,7 +406,7 @@ const DownloadsPanel = {
* Unattach event listeners that were added in _attachEventListeners. This * Unattach event listeners that were added in _attachEventListeners. This
* is called automatically on panel termination. * is called automatically on panel termination.
*/ */
_unattachEventListeners: function DP__unattachEventListeners() _unattachEventListeners: function ()
{ {
this.panel.removeEventListener("keydown", this._onKeyDown.bind(this), this.panel.removeEventListener("keydown", this._onKeyDown.bind(this),
false); false);
@ -414,7 +414,7 @@ const DownloadsPanel = {
false); false);
}, },
_onKeyPress: function DP__onKeyPress(aEvent) _onKeyPress: function (aEvent)
{ {
// Handle unmodified keys only. // Handle unmodified keys only.
if (aEvent.altKey || aEvent.ctrlKey || aEvent.shiftKey || aEvent.metaKey) { if (aEvent.altKey || aEvent.ctrlKey || aEvent.shiftKey || aEvent.metaKey) {
@ -462,7 +462,7 @@ const DownloadsPanel = {
* as the the accel-V "paste" event, which initiates a file download if the * as the the accel-V "paste" event, which initiates a file download if the
* pasted item can be resolved to a URI. * pasted item can be resolved to a URI.
*/ */
_onKeyDown: function DP__onKeyDown(aEvent) _onKeyDown: function (aEvent)
{ {
// If the footer is focused and the downloads list has at least 1 element // If the footer is focused and the downloads list has at least 1 element
// in it, focus the last element in the list when going up. // in it, focus the last element in the list when going up.
@ -516,7 +516,7 @@ const DownloadsPanel = {
* Move focus to the main element in the downloads panel, unless another * Move focus to the main element in the downloads panel, unless another
* element in the panel is already focused. * element in the panel is already focused.
*/ */
_focusPanel: function DP_focusPanel() _focusPanel: function ()
{ {
// We may be invoked while the panel is still waiting to be shown. // We may be invoked while the panel is still waiting to be shown.
if (this._state != this.kStateShown) { if (this._state != this.kStateShown) {
@ -539,7 +539,7 @@ const DownloadsPanel = {
/** /**
* Opens the downloads panel when data is ready to be displayed. * Opens the downloads panel when data is ready to be displayed.
*/ */
_openPopupIfDataReady: function DP_openPopupIfDataReady() _openPopupIfDataReady: function ()
{ {
// We don't want to open the popup if we already displayed it, or if we are // We don't want to open the popup if we already displayed it, or if we are
// still loading data. // still loading data.
@ -627,7 +627,7 @@ const DownloadsOverlayLoader = {
* Invoked when loading is completed. If the overlay is already * Invoked when loading is completed. If the overlay is already
* loaded, the function is called immediately. * loaded, the function is called immediately.
*/ */
ensureOverlayLoaded: function DOL_ensureOverlayLoaded(aOverlay, aCallback) ensureOverlayLoaded: function (aOverlay, aCallback)
{ {
// The overlay is already loaded, invoke the callback immediately. // The overlay is already loaded, invoke the callback immediately.
if (aOverlay in this._loadedOverlays) { if (aOverlay in this._loadedOverlays) {
@ -663,7 +663,7 @@ const DownloadsOverlayLoader = {
* and/or loading more overlays as needed. In most cases, there will be a * and/or loading more overlays as needed. In most cases, there will be a
* single request for one overlay, that will be processed immediately. * single request for one overlay, that will be processed immediately.
*/ */
processPendingRequests: function DOL_processPendingRequests() processPendingRequests: function ()
{ {
// Re-process all the currently pending requests, yet allow more requests // Re-process all the currently pending requests, yet allow more requests
// to be appended at the end of the array if we're not ready for them. // to be appended at the end of the array if we're not ready for them.
@ -721,7 +721,7 @@ const DownloadsView = {
/** /**
* Called when the number of items in the list changes. * Called when the number of items in the list changes.
*/ */
_itemCountChanged: function DV_itemCountChanged() _itemCountChanged: function ()
{ {
DownloadsCommon.log("The downloads item count has changed - we are tracking", DownloadsCommon.log("The downloads item count has changed - we are tracking",
this._downloads.length, "downloads in total."); this._downloads.length, "downloads in total.");
@ -766,7 +766,7 @@ const DownloadsView = {
/** /**
* Called before multiple downloads are about to be loaded. * Called before multiple downloads are about to be loaded.
*/ */
onDataLoadStarting: function DV_onDataLoadStarting() onDataLoadStarting: function ()
{ {
DownloadsCommon.log("onDataLoadStarting called for DownloadsView."); DownloadsCommon.log("onDataLoadStarting called for DownloadsView.");
this.loading = true; this.loading = true;
@ -775,7 +775,7 @@ const DownloadsView = {
/** /**
* Called after data loading finished. * Called after data loading finished.
*/ */
onDataLoadCompleted: function DV_onDataLoadCompleted() onDataLoadCompleted: function ()
{ {
DownloadsCommon.log("onDataLoadCompleted called for DownloadsView."); DownloadsCommon.log("onDataLoadCompleted called for DownloadsView.");
@ -795,7 +795,7 @@ const DownloadsView = {
* entering Private Browsing Mode). References to existing data should be * entering Private Browsing Mode). References to existing data should be
* discarded. * discarded.
*/ */
onDataInvalidated: function DV_onDataInvalidated() onDataInvalidated: function ()
{ {
DownloadsCommon.log("Downloads data has been invalidated. Cleaning up", DownloadsCommon.log("Downloads data has been invalidated. Cleaning up",
"DownloadsView."); "DownloadsView.");
@ -952,7 +952,7 @@ const DownloadsView = {
* @param aCommand * @param aCommand
* The command to be performed. * The command to be performed.
*/ */
onDownloadCommand: function DV_onDownloadCommand(aEvent, aCommand) onDownloadCommand: function (aEvent, aCommand)
{ {
let target = aEvent.target; let target = aEvent.target;
while (target.nodeName != "richlistitem") { while (target.nodeName != "richlistitem") {
@ -961,7 +961,7 @@ const DownloadsView = {
DownloadsView.controllerForElement(target).doCommand(aCommand); DownloadsView.controllerForElement(target).doCommand(aCommand);
}, },
onDownloadClick: function DV_onDownloadClick(aEvent) onDownloadClick: function (aEvent)
{ {
// Handle primary clicks only, and exclude the action button. // Handle primary clicks only, and exclude the action button.
if (aEvent.button == 0 && if (aEvent.button == 0 &&
@ -973,7 +973,7 @@ const DownloadsView = {
/** /**
* Handles keypress events on a download item. * Handles keypress events on a download item.
*/ */
onDownloadKeyPress: function DV_onDownloadKeyPress(aEvent) onDownloadKeyPress: function (aEvent)
{ {
// Pressing the key on buttons should not invoke the action because the // Pressing the key on buttons should not invoke the action because the
// event has already been handled by the button itself. // event has already been handled by the button itself.
@ -997,12 +997,12 @@ const DownloadsView = {
/** /**
* Mouse listeners to handle selection on hover. * Mouse listeners to handle selection on hover.
*/ */
onDownloadMouseOver: function DV_onDownloadMouseOver(aEvent) onDownloadMouseOver: function (aEvent)
{ {
if (aEvent.originalTarget.parentNode == this.richListBox) if (aEvent.originalTarget.parentNode == this.richListBox)
this.richListBox.selectedItem = aEvent.originalTarget; this.richListBox.selectedItem = aEvent.originalTarget;
}, },
onDownloadMouseOut: function DV_onDownloadMouseOut(aEvent) onDownloadMouseOut: function (aEvent)
{ {
if (aEvent.originalTarget.parentNode == this.richListBox) { if (aEvent.originalTarget.parentNode == this.richListBox) {
// If the destination element is outside of the richlistitem, clear the // If the destination element is outside of the richlistitem, clear the
@ -1016,7 +1016,7 @@ const DownloadsView = {
} }
}, },
onDownloadContextMenu: function DV_onDownloadContextMenu(aEvent) onDownloadContextMenu: function (aEvent)
{ {
let element = this.richListBox.selectedItem; let element = this.richListBox.selectedItem;
if (!element) { if (!element) {
@ -1030,7 +1030,7 @@ const DownloadsView = {
contextMenu.setAttribute("state", element.getAttribute("state")); contextMenu.setAttribute("state", element.getAttribute("state"));
}, },
onDownloadDragStart: function DV_onDownloadDragStart(aEvent) onDownloadDragStart: function (aEvent)
{ {
let element = this.richListBox.selectedItem; let element = this.richListBox.selectedItem;
if (!element) { if (!element) {
@ -1113,12 +1113,12 @@ const DownloadsViewController = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// Initialization and termination //// Initialization and termination
initialize: function DVC_initialize() initialize: function ()
{ {
window.controllers.insertControllerAt(0, this); window.controllers.insertControllerAt(0, this);
}, },
terminate: function DVC_terminate() terminate: function ()
{ {
window.controllers.removeController(this); window.controllers.removeController(this);
}, },
@ -1126,7 +1126,7 @@ const DownloadsViewController = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// nsIController //// nsIController
supportsCommand: function DVC_supportsCommand(aCommand) supportsCommand: function (aCommand)
{ {
// Firstly, determine if this is a command that we can handle. // Firstly, determine if this is a command that we can handle.
if (!(aCommand in this.commands) && if (!(aCommand in this.commands) &&
@ -1143,7 +1143,7 @@ const DownloadsViewController = {
return !!element; return !!element;
}, },
isCommandEnabled: function DVC_isCommandEnabled(aCommand) isCommandEnabled: function (aCommand)
{ {
// Handle commands that are not selection-specific. // Handle commands that are not selection-specific.
if (aCommand == "downloadsCmd_clearList") { if (aCommand == "downloadsCmd_clearList") {
@ -1156,7 +1156,7 @@ const DownloadsViewController = {
.isCommandEnabled(aCommand); .isCommandEnabled(aCommand);
}, },
doCommand: function DVC_doCommand(aCommand) doCommand: function (aCommand)
{ {
// If this command is not selection-specific, execute it. // If this command is not selection-specific, execute it.
if (aCommand in this.commands) { if (aCommand in this.commands) {
@ -1177,7 +1177,7 @@ const DownloadsViewController = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// Other functions //// Other functions
updateCommands: function DVC_updateCommands() updateCommands: function ()
{ {
Object.keys(this.commands).forEach(goUpdateCommand); Object.keys(this.commands).forEach(goUpdateCommand);
Object.keys(DownloadsViewItemController.prototype.commands) Object.keys(DownloadsViewItemController.prototype.commands)
@ -1192,7 +1192,7 @@ const DownloadsViewController = {
* the currently selected item in the list. * the currently selected item in the list.
*/ */
commands: { commands: {
downloadsCmd_clearList: function DVC_downloadsCmd_clearList() downloadsCmd_clearList: function ()
{ {
DownloadsCommon.getData(window).removeFinished(); DownloadsCommon.getData(window).removeFinished();
} }
@ -1213,7 +1213,7 @@ function DownloadsViewItemController(download) {
} }
DownloadsViewItemController.prototype = { DownloadsViewItemController.prototype = {
isCommandEnabled: function DVIC_isCommandEnabled(aCommand) isCommandEnabled: function (aCommand)
{ {
switch (aCommand) { switch (aCommand) {
case "downloadsCmd_open": { case "downloadsCmd_open": {
@ -1252,7 +1252,7 @@ DownloadsViewItemController.prototype = {
return false; return false;
}, },
doCommand: function DVIC_doCommand(aCommand) doCommand: function (aCommand)
{ {
if (this.isCommandEnabled(aCommand)) { if (this.isCommandEnabled(aCommand)) {
this.commands[aCommand].apply(this); this.commands[aCommand].apply(this);
@ -1268,20 +1268,20 @@ DownloadsViewItemController.prototype = {
* In commands, the "this" identifier points to the controller item. * In commands, the "this" identifier points to the controller item.
*/ */
commands: { commands: {
cmd_delete: function DVIC_cmd_delete() cmd_delete: function ()
{ {
DownloadsCommon.removeAndFinalizeDownload(this.download); DownloadsCommon.removeAndFinalizeDownload(this.download);
PlacesUtils.bhistory.removePage( PlacesUtils.bhistory.removePage(
NetUtil.newURI(this.download.source.url)); NetUtil.newURI(this.download.source.url));
}, },
downloadsCmd_cancel: function DVIC_downloadsCmd_cancel() downloadsCmd_cancel: function ()
{ {
this.download.cancel().catch(() => {}); this.download.cancel().catch(() => {});
this.download.removePartialData().catch(Cu.reportError); this.download.removePartialData().catch(Cu.reportError);
}, },
downloadsCmd_open: function DVIC_downloadsCmd_open() downloadsCmd_open: function ()
{ {
this.download.launch().catch(Cu.reportError); this.download.launch().catch(Cu.reportError);
@ -1293,7 +1293,7 @@ DownloadsViewItemController.prototype = {
DownloadsPanel.hidePanel(); DownloadsPanel.hidePanel();
}, },
downloadsCmd_show: function DVIC_downloadsCmd_show() downloadsCmd_show: function ()
{ {
let file = new FileUtils.File(this.download.target.path); let file = new FileUtils.File(this.download.target.path);
DownloadsCommon.showDownloadedFile(file); DownloadsCommon.showDownloadedFile(file);
@ -1306,7 +1306,7 @@ DownloadsViewItemController.prototype = {
DownloadsPanel.hidePanel(); DownloadsPanel.hidePanel();
}, },
downloadsCmd_pauseResume: function DVIC_downloadsCmd_pauseResume() downloadsCmd_pauseResume: function ()
{ {
if (this.download.stopped) { if (this.download.stopped) {
this.download.start(); this.download.start();
@ -1315,24 +1315,24 @@ DownloadsViewItemController.prototype = {
} }
}, },
downloadsCmd_retry: function DVIC_downloadsCmd_retry() downloadsCmd_retry: function ()
{ {
this.download.start().catch(() => {}); this.download.start().catch(() => {});
}, },
downloadsCmd_openReferrer: function DVIC_downloadsCmd_openReferrer() downloadsCmd_openReferrer: function ()
{ {
openURL(this.download.source.referrer); openURL(this.download.source.referrer);
}, },
downloadsCmd_copyLocation: function DVIC_downloadsCmd_copyLocation() downloadsCmd_copyLocation: function ()
{ {
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"] let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(Ci.nsIClipboardHelper); .getService(Ci.nsIClipboardHelper);
clipboard.copyString(this.download.source.url, document); clipboard.copyString(this.download.source.url, document);
}, },
downloadsCmd_doDefault: function DVIC_downloadsCmd_doDefault() downloadsCmd_doDefault: function ()
{ {
const nsIDM = Ci.nsIDownloadManager; const nsIDM = Ci.nsIDownloadManager;
@ -1478,7 +1478,7 @@ const DownloadsSummary = {
* @param aEvent * @param aEvent
* The keydown event being handled. * The keydown event being handled.
*/ */
onKeyDown: function DS_onKeyDown(aEvent) onKeyDown: function (aEvent)
{ {
if (aEvent.charCode == " ".charCodeAt(0) || if (aEvent.charCode == " ".charCodeAt(0) ||
aEvent.keyCode == KeyEvent.DOM_VK_ENTER || aEvent.keyCode == KeyEvent.DOM_VK_ENTER ||
@ -1493,7 +1493,7 @@ const DownloadsSummary = {
* @param aEvent * @param aEvent
* The click event being handled. * The click event being handled.
*/ */
onClick: function DS_onClick(aEvent) onClick: function (aEvent)
{ {
DownloadsPanel.showDownloadsHistory(); DownloadsPanel.showDownloadsHistory();
}, },
@ -1569,7 +1569,7 @@ const DownloadsFooter = {
* is visible, focus it. If not, focus the "Show All Downloads" * is visible, focus it. If not, focus the "Show All Downloads"
* button. * button.
*/ */
focus: function DF_focus() focus: function ()
{ {
if (this._showingSummary) { if (this._showingSummary) {
DownloadsSummary.focus(); DownloadsSummary.focus();

View file

@ -59,7 +59,7 @@ const DownloadsButton = {
* startup time, and in particular should not cause the Download Manager * startup time, and in particular should not cause the Download Manager
* service to start. * service to start.
*/ */
initializeIndicator: function DB_initializeIndicator() initializeIndicator: function ()
{ {
this._update(); this._update();
}, },
@ -77,7 +77,7 @@ const DownloadsButton = {
* placeholder is an ordinary button defined in the browser window that can be * placeholder is an ordinary button defined in the browser window that can be
* moved freely between the toolbars and the customization palette. * moved freely between the toolbars and the customization palette.
*/ */
customizeStart: function DB_customizeStart() customizeStart: function ()
{ {
// Hide the indicator and prevent it to be displayed as a temporary anchor // Hide the indicator and prevent it to be displayed as a temporary anchor
// during customization, even if requested using the getAnchor method. // during customization, even if requested using the getAnchor method.
@ -98,7 +98,7 @@ const DownloadsButton = {
/** /**
* This function is called when toolbar customization ends. * This function is called when toolbar customization ends.
*/ */
customizeDone: function DB_customizeDone() customizeDone: function ()
{ {
this._customizing = false; this._customizing = false;
this._update(); this._update();
@ -114,7 +114,7 @@ const DownloadsButton = {
* input/output it performs, and in particular should not cause the * input/output it performs, and in particular should not cause the
* Download Manager service to start. * Download Manager service to start.
*/ */
_update: function DB_update() { _update: function () {
this._updatePositionInternal(); this._updatePositionInternal();
if (!DownloadsCommon.useToolkitUI) { if (!DownloadsCommon.useToolkitUI) {
@ -131,7 +131,7 @@ const DownloadsButton = {
* that the panel doesn't flicker because we move the DOM element to which * that the panel doesn't flicker because we move the DOM element to which
* it's anchored. * it's anchored.
*/ */
updatePosition: function DB_updatePosition() updatePosition: function ()
{ {
if (!this._anchorRequested) { if (!this._anchorRequested) {
this._updatePositionInternal(); this._updatePositionInternal();
@ -144,7 +144,7 @@ const DownloadsButton = {
* *
* @return Anchor element, or null if the indicator is not visible. * @return Anchor element, or null if the indicator is not visible.
*/ */
_updatePositionInternal: function DB_updatePositionInternal() _updatePositionInternal: function ()
{ {
let indicator = DownloadsIndicatorView.indicator; let indicator = DownloadsIndicatorView.indicator;
if (!indicator) { if (!indicator) {
@ -187,7 +187,7 @@ const DownloadsButton = {
* Called once the indicator overlay has loaded. Gets a boolean * Called once the indicator overlay has loaded. Gets a boolean
* argument representing the indicator visibility. * argument representing the indicator visibility.
*/ */
checkIsVisible: function DB_checkIsVisible(aCallback) checkIsVisible: function (aCallback)
{ {
function DB_CEV_callback() { function DB_CEV_callback() {
if (!this._placeholder) { if (!this._placeholder) {
@ -215,7 +215,7 @@ const DownloadsButton = {
* panel should be anchored, or null if an anchor is not available (for * panel should be anchored, or null if an anchor is not available (for
* example because both the tab bar and the navigation bar are hidden). * example because both the tab bar and the navigation bar are hidden).
*/ */
getAnchor: function DB_getAnchor(aCallback) getAnchor: function (aCallback)
{ {
// Do not allow anchoring the panel to the element while customizing. // Do not allow anchoring the panel to the element while customizing.
if (this._customizing) { if (this._customizing) {
@ -235,7 +235,7 @@ const DownloadsButton = {
/** /**
* Allows the temporary anchor to be hidden. * Allows the temporary anchor to be hidden.
*/ */
releaseAnchor: function DB_releaseAnchor() releaseAnchor: function ()
{ {
this._anchorRequested = false; this._anchorRequested = false;
this._updatePositionInternal(); this._updatePositionInternal();
@ -284,7 +284,7 @@ const DownloadsIndicatorView = {
/** /**
* Prepares the downloads indicator to be displayed. * Prepares the downloads indicator to be displayed.
*/ */
ensureInitialized: function DIV_ensureInitialized() ensureInitialized: function ()
{ {
if (this._initialized) { if (this._initialized) {
return; return;
@ -298,7 +298,7 @@ const DownloadsIndicatorView = {
/** /**
* Frees the internal resources related to the indicator. * Frees the internal resources related to the indicator.
*/ */
ensureTerminated: function DIV_ensureTerminated() ensureTerminated: function ()
{ {
if (!this._initialized) { if (!this._initialized) {
return; return;
@ -320,7 +320,7 @@ const DownloadsIndicatorView = {
* Ensures that the user interface elements required to display the indicator * Ensures that the user interface elements required to display the indicator
* are loaded, then invokes the given callback. * are loaded, then invokes the given callback.
*/ */
_ensureOperational: function DIV_ensureOperational(aCallback) _ensureOperational: function (aCallback)
{ {
if (this._operational) { if (this._operational) {
aCallback(); aCallback();
@ -359,7 +359,7 @@ const DownloadsIndicatorView = {
* @param aType * @param aType
* Set to "start" for new downloads, "finish" for completed downloads. * Set to "start" for new downloads, "finish" for completed downloads.
*/ */
showEventNotification: function DIV_showEventNotification(aType) showEventNotification: function (aType)
{ {
if (!this._initialized) { if (!this._initialized) {
return; return;
@ -516,13 +516,13 @@ const DownloadsIndicatorView = {
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
//// User interface event functions //// User interface event functions
onWindowUnload: function DIV_onWindowUnload() onWindowUnload: function ()
{ {
// This function is registered as an event listener, we can't use "this". // This function is registered as an event listener, we can't use "this".
DownloadsIndicatorView.ensureTerminated(); DownloadsIndicatorView.ensureTerminated();
}, },
onCommand: function DIV_onCommand(aEvent) onCommand: function (aEvent)
{ {
if (DownloadsCommon.useToolkitUI) { if (DownloadsCommon.useToolkitUI) {
// The panel won't suppress attention for us, we need to clear now. // The panel won't suppress attention for us, we need to clear now.
@ -535,12 +535,12 @@ const DownloadsIndicatorView = {
aEvent.stopPropagation(); aEvent.stopPropagation();
}, },
onDragOver: function DIV_onDragOver(aEvent) onDragOver: function (aEvent)
{ {
browserDragAndDrop.dragOver(aEvent); browserDragAndDrop.dragOver(aEvent);
}, },
onDrop: function DIV_onDrop(aEvent) onDrop: function (aEvent)
{ {
let dt = aEvent.dataTransfer; let dt = aEvent.dataTransfer;
// If dragged item is from our source, do not try to // If dragged item is from our source, do not try to