commit 21cc9f16bff02dce7dd1e5140071abca6c96c938
parent 678a6e15cc5c6c5a1c7e040667ff88ee87c4f1d6
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 10 Aug 2017 04:49:42 +0200
Move ZoteroPane.launchURL() to Zotero.launchURL()
And add deprecation warning to ZoteroPane.launchURL()
Diffstat:
2 files changed, 51 insertions(+), 42 deletions(-)
diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js
@@ -1117,6 +1117,54 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
/**
+ * Launch an HTTP URL externally, the best way we can
+ *
+ * Used only by Standalone
+ */
+ this.launchURL = function (url) {
+ if (!url.match(/^https?/)) {
+ throw new Error("launchURL() requires an HTTP(S) URL");
+ }
+
+ try {
+ var io = Components.classes['@mozilla.org/network/io-service;1']
+ .getService(Components.interfaces.nsIIOService);
+ var uri = io.newURI(url, null, null);
+ var handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
+ .getService(Components.interfaces.nsIExternalProtocolService)
+ .getProtocolHandlerInfo('http');
+ handler.preferredAction = Components.interfaces.nsIHandlerInfo.useSystemDefault;
+ handler.launchWithURI(uri, null);
+ }
+ catch (e) {
+ Zotero.debug("launchWithURI() not supported -- trying fallback executable");
+
+ if (Zotero.isWin) {
+ var pref = "fallbackLauncher.windows";
+ }
+ else {
+ var pref = "fallbackLauncher.unix";
+ }
+ var path = Zotero.Prefs.get(pref);
+
+ var exec = Components.classes["@mozilla.org/file/local;1"]
+ .createInstance(Components.interfaces.nsILocalFile);
+ exec.initWithPath(path);
+ if (!exec.exists()) {
+ throw ("Fallback executable not found -- check extensions.zotero." + pref + " in about:config");
+ }
+
+ var proc = Components.classes["@mozilla.org/process/util;1"]
+ .createInstance(Components.interfaces.nsIProcess);
+ proc.init(exec);
+
+ var args = [url];
+ proc.runw(false, args, args.length);
+ }
+ }
+
+
+ /**
* Opens a URL in the basic viewer, and optionally run a callback on load
*
* @param {String} uri
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -4165,50 +4165,11 @@ var ZoteroPane = new function()
/**
- * Launch an HTTP URL externally, the best way we can
- *
- * Used only by Standalone
+ * @deprecated
*/
this.launchURL = function (url) {
- if (!url.match(/^https?/)) {
- throw new Error("launchURL() requires an HTTP(S) URL");
- }
-
- try {
- var io = Components.classes['@mozilla.org/network/io-service;1']
- .getService(Components.interfaces.nsIIOService);
- var uri = io.newURI(url, null, null);
- var handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
- .getService(Components.interfaces.nsIExternalProtocolService)
- .getProtocolHandlerInfo('http');
- handler.preferredAction = Components.interfaces.nsIHandlerInfo.useSystemDefault;
- handler.launchWithURI(uri, null);
- }
- catch (e) {
- Zotero.debug("launchWithURI() not supported -- trying fallback executable");
-
- if (Zotero.isWin) {
- var pref = "fallbackLauncher.windows";
- }
- else {
- var pref = "fallbackLauncher.unix";
- }
- var path = Zotero.Prefs.get(pref);
-
- var exec = Components.classes["@mozilla.org/file/local;1"]
- .createInstance(Components.interfaces.nsILocalFile);
- exec.initWithPath(path);
- if (!exec.exists()) {
- throw ("Fallback executable not found -- check extensions.zotero." + pref + " in about:config");
- }
-
- var proc = Components.classes["@mozilla.org/process/util;1"]
- .createInstance(Components.interfaces.nsIProcess);
- proc.init(exec);
-
- var args = [url];
- proc.runw(false, args, args.length);
- }
+ Zotero.debug("ZoteroPane.launchURI() is deprecated -- use Zotero.launchURI()", 2);
+ Zotero.launchURI(launchURI);
}