Fix blank window/tab when file.launch() fails

Use nsIExternalProtocolService.loadUrl() as a fallback rather than window.loadURI()

If "Remember my choice for file links" is selected, there's currently
no way to change that in Standalone short of deleting mimeTypes.rdf.
This commit is contained in:
Dan Stillman 2011-12-14 17:46:21 -05:00
parent 87c4dfb893
commit f87bee9f7c

View file

@ -3386,15 +3386,21 @@ var ZoteroPane = new function()
this.loadURI(url, event, { attachmentID: itemID});
}
else {
// Some platforms don't have nsILocalFile.launch, so we just load it and
// Some platforms don't have nsILocalFile.launch, so we just
// let the Firefox external helper app window handle it
try {
file.launch();
}
catch (e) {
Zotero.debug("launch() not supported -- passing file to loadURI()");
var fileURL = attachment.getLocalFileURL();
this.loadURI(fileURL);
Zotero.debug("launch() not supported -- passing file to loadUrl()");
var uri = Components.classes["@mozilla.org/network/standard-url;1"].
createInstance(Components.interfaces.nsIURI);
uri.spec = attachment.getLocalFileURL();
var nsIEPS = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Components.interfaces.nsIExternalProtocolService);
nsIEPS.loadUrl(uri);
}
}
}