michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:sw=4:sr:sta:et:sts: */ michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: function jsConsoleHandler() {} michael@0: jsConsoleHandler.prototype = { michael@0: handle: function clh_handle(cmdLine) { michael@0: if (!cmdLine.handleFlag("jsconsole", false)) michael@0: return; michael@0: michael@0: var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. michael@0: getService(Ci.nsIWindowMediator); michael@0: var console = wm.getMostRecentWindow("global:console"); michael@0: if (!console) { michael@0: var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]. michael@0: getService(Ci.nsIWindowWatcher); michael@0: wwatch.openWindow(null, "chrome://global/content/console.xul", "_blank", michael@0: "chrome,dialog=no,all", cmdLine); michael@0: } else { michael@0: console.focus(); // the Error console was already open michael@0: } michael@0: michael@0: if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) michael@0: cmdLine.preventDefault = true; michael@0: }, michael@0: michael@0: helpInfo : " -jsconsole Open the Error console.\n", michael@0: michael@0: classID: Components.ID("{2cd0c310-e127-44d0-88fc-4435c9ab4d4b}"), michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([jsConsoleHandler]);