Skip to content

Commit

Permalink
Use gCombinedDownloadIntegration in Firefox 49+
Browse files Browse the repository at this point in the history
(#47)
  • Loading branch information
Infocatcher committed Oct 17, 2016
1 parent eb9e76a commit 44907ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions downloadsEnhancements.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ var downloadsEnhancements = {
var logPrefix = "dontRemoveFinishedDownloads(" + patch + "): ";
try { // Firefox 26+
// http://mxr.mozilla.org/mozilla-central/source/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
var {DownloadIntegration} = Components.utils.import("resource://gre/modules/DownloadIntegration.jsm", {});
var dig = Components.utils.import("resource://gre/modules/DownloadIntegration.jsm", {});
var {DownloadIntegration} = dig;
// Note: how ensure, that we patch/restore the same object/method? Some new API?
if("gCombinedDownloadIntegration" in dig) // Firefox 49+
DownloadIntegration = dig.gCombinedDownloadIntegration;
var dcg = Components.utils.import("resource:///modules/DownloadsCommon.jsm", {});
var {DownloadsDataItem} = dcg;
if(DownloadsDataItem && DownloadsDataItem.prototype) {
Expand Down Expand Up @@ -426,11 +430,15 @@ var downloadsEnhancements = {
},
saveDownloads: function() {
try { // Firefox 26+
var {DownloadIntegration} = Components.utils.import("resource://gre/modules/DownloadIntegration.jsm", {});
var dig = Components.utils.import("resource://gre/modules/DownloadIntegration.jsm", {});
var DownloadIntegration = dig.gCombinedDownloadIntegration || dig.DownloadIntegration;
if(DownloadIntegration._store) {
DownloadIntegration._store.save();
_log("saveDownloads()");
}
else {
_log("saveDownloads() failed: DownloadIntegration._store is " + DownloadIntegration._store);
}
}
catch(e) {
if(!DownloadIntegration)
Expand Down

0 comments on commit 44907ff

Please sign in to comment.