Fix saveURI() in Firefox 36+
This commit is contained in:
parent
0b3b296e28
commit
5f8b56ef86
|
@ -392,13 +392,7 @@ Zotero_Preferences.Search = {
|
||||||
|
|
||||||
wbp.progressListener = progressListener;
|
wbp.progressListener = progressListener;
|
||||||
Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
|
Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec);
|
||||||
try {
|
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
|
||||||
wbp.saveURI(uri, null, null, null, null, fileURL);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
wbp.saveURI(uri, null, null, null, null, fileURL, null);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -672,13 +672,7 @@ var wpdCommon = {
|
||||||
|
|
||||||
// has the url the same filetype like the file extension?
|
// has the url the same filetype like the file extension?
|
||||||
//save file to target
|
//save file to target
|
||||||
try {
|
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
|
||||||
obj_Persist.saveURI(obj_URI, null, null, null, null, obj_TargetFile);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
obj_Persist.saveURI(obj_URI, null, null, null, null, obj_TargetFile, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -347,13 +347,8 @@ Zotero.Attachments = new function(){
|
||||||
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"]
|
var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"]
|
||||||
.createInstance(Components.interfaces.nsIURL);
|
.createInstance(Components.interfaces.nsIURL);
|
||||||
nsIURL.spec = url;
|
nsIURL.spec = url;
|
||||||
try {
|
Zotero.Utilities.saveURI(wbp, nsIURL, file);
|
||||||
wbp.saveURI(nsIURL, null, null, null, null, file);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
wbp.saveURI(nsIURL, null, null, null, null, file, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return attachmentItem;
|
return attachmentItem;
|
||||||
}
|
}
|
||||||
|
@ -663,13 +658,7 @@ Zotero.Attachments = new function(){
|
||||||
throw (e);
|
throw (e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
|
||||||
wbp.saveURI(nsIURL, null, null, null, null, file);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
wbp.saveURI(nsIURL, null, null, null, null, file, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to collections
|
// Add to collections
|
||||||
|
|
|
@ -963,13 +963,7 @@ Zotero.Sync.Storage.WebDAV = (function () {
|
||||||
.createInstance(nsIWBP);
|
.createInstance(nsIWBP);
|
||||||
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
|
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
|
||||||
wbp.progressListener = listener;
|
wbp.progressListener = listener;
|
||||||
try {
|
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
|
||||||
wbp.saveURI(uri, null, null, null, null, destFile);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
wbp.saveURI(uri, null, null, null, null, destFile, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
});
|
});
|
||||||
|
|
|
@ -944,13 +944,7 @@ Zotero.Sync.Storage.ZFS = (function () {
|
||||||
.createInstance(nsIWBP);
|
.createInstance(nsIWBP);
|
||||||
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
|
wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE;
|
||||||
wbp.progressListener = listener;
|
wbp.progressListener = listener;
|
||||||
try {
|
Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file);
|
||||||
wbp.saveURI(uri, null, null, null, null, destFile);
|
|
||||||
} catch(e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=794602
|
|
||||||
// XXX Always use when we no longer support Firefox < 18
|
|
||||||
wbp.saveURI(uri, null, null, null, null, destFile, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
});
|
});
|
||||||
|
|
|
@ -469,5 +469,21 @@ Zotero.Utilities.Internal.Base64 = {
|
||||||
}
|
}
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
},
|
||||||
|
/**
|
||||||
|
* saveURI wrapper function
|
||||||
|
* @param {nsIWebBrowserPersist} nsIWebBrowserPersist
|
||||||
|
* @param {nsIURI} source URL
|
||||||
|
* @param {nsISupports} target file
|
||||||
|
*/
|
||||||
|
saveURI: function (wbp, source, target) {
|
||||||
|
// Firefox 35 and below
|
||||||
|
try {
|
||||||
|
wbp.saveURI(source, null, null, null, null, target, null);
|
||||||
|
}
|
||||||
|
// Firefox 36+ needs one more parameter
|
||||||
|
catch (e if e.name === "NS_ERROR_XPC_NOT_ENOUGH_ARGS") {
|
||||||
|
wbp.saveURI(source, null, null, null, null, null, target, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user