2009-12-01 07:34:27 -08:00
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2010-07-13 07:36:09 -07:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2010-06-30 14:29:22 -07:00
|
|
|
|
2010-12-15 23:00:33 -08:00
|
|
|
|
2011-10-10 17:40:17 -07:00
|
|
|
function dump(a) {
|
2011-10-15 13:27:03 -07:00
|
|
|
Cc["@mozilla.org/consoleservice;1"]
|
|
|
|
.getService(Ci.nsIConsoleService)
|
|
|
|
.logStringMessage(a);
|
2011-07-12 10:25:35 -07:00
|
|
|
}
|
2011-01-03 13:08:54 -08:00
|
|
|
|
2011-10-14 19:58:04 -07:00
|
|
|
function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
|
|
|
|
let argString = null;
|
|
|
|
if (aArgs && !(aArgs instanceof Ci.nsISupportsArray)) {
|
|
|
|
argString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
|
|
|
argString.data = aArgs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, argString || aArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 12:46:31 -08:00
|
|
|
function resolveURIInternal(aCmdLine, aArgument) {
|
|
|
|
let uri = aCmdLine.resolveURI(aArgument);
|
|
|
|
|
|
|
|
if (!(uri instanceof Ci.nsIFileURL))
|
|
|
|
return uri;
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (uri.file.exists())
|
|
|
|
return uri;
|
|
|
|
} catch (e) {
|
|
|
|
Cu.reportError(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
let urifixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
|
|
|
|
uri = urifixup.createFixupURI(aArgument, 0);
|
|
|
|
} catch (e) {
|
|
|
|
Cu.reportError(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return uri;
|
|
|
|
}
|
|
|
|
|
2011-10-15 13:27:03 -07:00
|
|
|
function BrowserCLH() {}
|
2009-12-01 07:34:27 -08:00
|
|
|
|
|
|
|
BrowserCLH.prototype = {
|
2011-10-10 17:40:17 -07:00
|
|
|
handle: function fs_handle(aCmdLine) {
|
2011-10-23 21:11:29 -07:00
|
|
|
let urlParam = "about:home";
|
|
|
|
try {
|
|
|
|
urlParam = aCmdLine.handleFlagWithParam("remote", false);
|
2011-10-25 08:49:22 -07:00
|
|
|
} catch (e) {
|
|
|
|
// Optional so not a real error
|
|
|
|
}
|
2011-10-15 13:27:03 -07:00
|
|
|
dump("fs_handle: " + urlParam);
|
2011-11-10 12:46:31 -08:00
|
|
|
|
2011-10-15 13:27:03 -07:00
|
|
|
try {
|
2011-11-10 12:46:31 -08:00
|
|
|
let uri = resolveURIInternal(aCmdLine, urlParam);
|
2011-10-15 13:27:03 -07:00
|
|
|
if (!uri)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
|
|
|
|
if (browserWin) {
|
|
|
|
browserWin.browserDOMWindow.openURI(uri,
|
|
|
|
null,
|
|
|
|
Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW,
|
|
|
|
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
|
|
|
} else {
|
|
|
|
browserWin = openWindow(null, "chrome://browser/content/browser.xul", "_blank", "chrome,dialog=no,all", urlParam);
|
2010-12-10 19:44:37 -08:00
|
|
|
}
|
2011-10-15 13:27:03 -07:00
|
|
|
|
|
|
|
aCmdLine.preventDefault = true;
|
|
|
|
} catch (x) {
|
|
|
|
Cc["@mozilla.org/consoleservice;1"]
|
|
|
|
.getService(Ci.nsIConsoleService)
|
|
|
|
.logStringMessage("fs_handle exception!: " + x);
|
|
|
|
}
|
2009-12-01 07:34:27 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
// QI
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
|
|
|
|
|
|
|
|
// XPCOMUtils factory
|
2011-10-15 13:27:03 -07:00
|
|
|
classID: Components.ID("{be623d20-d305-11de-8a39-0800200c9a66}")
|
2009-12-01 07:34:27 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
var components = [ BrowserCLH ];
|
2010-06-29 14:02:25 -07:00
|
|
|
const NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|