diff --git a/chrome/content/zotero/preferences/preferences_search.js b/chrome/content/zotero/preferences/preferences_search.js index 6b3b56631..42bcc1831 100644 --- a/chrome/content/zotero/preferences/preferences_search.js +++ b/chrome/content/zotero/preferences/preferences_search.js @@ -392,13 +392,7 @@ Zotero_Preferences.Search = { wbp.progressListener = progressListener; Zotero.debug("Saving " + uri.spec + " to " + fileURL.spec); - try { - 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); - } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file); }, diff --git a/chrome/content/zotero/webpagedump/common.js b/chrome/content/zotero/webpagedump/common.js index 2e290d06b..00dbfb43f 100644 --- a/chrome/content/zotero/webpagedump/common.js +++ b/chrome/content/zotero/webpagedump/common.js @@ -672,13 +672,7 @@ var wpdCommon = { // has the url the same filetype like the file extension? //save file to target - try { - 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); - } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file); return true; diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js index 89c2005f5..80c841fea 100644 --- a/chrome/content/zotero/xpcom/attachments.js +++ b/chrome/content/zotero/xpcom/attachments.js @@ -347,13 +347,8 @@ Zotero.Attachments = new function(){ var nsIURL = Components.classes["@mozilla.org/network/standard-url;1"] .createInstance(Components.interfaces.nsIURL); nsIURL.spec = url; - try { - 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); - } + Zotero.Utilities.saveURI(wbp, nsIURL, file); + return attachmentItem; } @@ -663,13 +658,7 @@ Zotero.Attachments = new function(){ throw (e); } }); - try { - 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); - } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file); } // Add to collections diff --git a/chrome/content/zotero/xpcom/storage/webdav.js b/chrome/content/zotero/xpcom/storage/webdav.js index 55f104bb0..e6cf71963 100644 --- a/chrome/content/zotero/xpcom/storage/webdav.js +++ b/chrome/content/zotero/xpcom/storage/webdav.js @@ -963,13 +963,7 @@ Zotero.Sync.Storage.WebDAV = (function () { .createInstance(nsIWBP); wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE; wbp.progressListener = listener; - try { - 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); - } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file); return deferred.promise; }); diff --git a/chrome/content/zotero/xpcom/storage/zfs.js b/chrome/content/zotero/xpcom/storage/zfs.js index 21de3c52d..a4d1efbac 100644 --- a/chrome/content/zotero/xpcom/storage/zfs.js +++ b/chrome/content/zotero/xpcom/storage/zfs.js @@ -944,13 +944,7 @@ Zotero.Sync.Storage.ZFS = (function () { .createInstance(nsIWBP); wbp.persistFlags = nsIWBP.PERSIST_FLAGS_BYPASS_CACHE; wbp.progressListener = listener; - try { - 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); - } + Zotero.Utilities.Internal.saveURI(wbp, nsIURL, file); return deferred.promise; }); diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index d7d2e5f83..5edbf728a 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -469,5 +469,21 @@ Zotero.Utilities.Internal.Base64 = { } 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); + } + } } \ No newline at end of file