commit d8f2d4b26801ee23713b65f16ba87750fc7f6b14
parent 783ba4a0b710d95030bfe553cc90f60d36a9d8cf
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 30 Jan 2015 03:56:58 -0500
Merge branch 'fx36-saveURI' into 4.0
Diffstat:
6 files changed, 24 insertions(+), 43 deletions(-)
diff --git 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
@@ -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
@@ -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;
}
@@ -664,13 +659,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
@@ -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
@@ -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
@@ -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