Standalone: Open HTTP(S) URLs externally in default browser

Other URLs (such as zotero://attachment) won't work yet
This commit is contained in:
Dan Stillman 2010-09-23 06:10:04 +00:00
parent 9f2d231741
commit 1adf489801

View file

@ -2557,6 +2557,18 @@ var ZoteroPane = new function()
* shift-click == new window, no modifier == frontmost tab
*/
function loadURI(uri, event, data) {
if (Zotero.isStandalone && uri.match("^https?")) {
var io = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);
var uri = io.newURI(uri, 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);
return;
}
// Open in new tab
if (event && (event.metaKey || (!Zotero.isMac && event.ctrlKey))) {
var tab = gBrowser.addTab(uri);