From c384035b924db747c125f12a409c9ca8455c6241 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 21 Sep 2010 09:42:46 -0400 Subject: [PATCH] Add missing common/components/commandline-handler.js --HG-- extra : rebase_source : de67d58a3da7ae888ef08dcb9dffacbd02160655 --- common/components/commandline-handler.js | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 common/components/commandline-handler.js diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js new file mode 100644 index 00000000..3fd67be0 --- /dev/null +++ b/common/components/commandline-handler.js @@ -0,0 +1,46 @@ +// Copyright (c) 2009 by Doug Kearns +// +// This work is licensed for reuse under an MIT license. Details are +// given in the LICENSE.txt file included with this file. +"use strict"; + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const Name = Components.classes["@dactyl.googlecode.com/base/dactyl"] + .getService().wrappedJSObject.name; +const name = Name.toLowerCase(); +function CommandLineHandler() { + this.wrappedJSObject = this; +} +CommandLineHandler.prototype = { + + classDescription: Name + " Command-line Handler", + + classID: Components.ID("{16dc34f7-6d22-4aa4-a67f-2921fb5dcb69}"), + + contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=" + name, + + _xpcom_categories: [{ + category: "command-line-handler", + entry: "m-" + name + }], + + QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsICommandLineHandler]), + + handle: function (commandLine) { + // TODO: handle remote launches differently? + try { + this.optionValue = commandLine.handleFlagWithParam(name, false); + } + catch (e) { + dump(name + ": option '-" + name + "' requires an argument\n"); + } + } +}; + +if (XPCOMUtils.generateNSGetFactory) + const NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]); +else + const NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]); + +// vim: set ft=javascript fdm=marker sw=4 ts=4 et: