jsconsole-clhandler.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
  2. /* vim:sw=4:sr:sta:et:sts: */
  3. /* This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. const Cc = Components.classes;
  7. const Ci = Components.interfaces;
  8. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  9. function jsConsoleHandler() {}
  10. jsConsoleHandler.prototype = {
  11. handle: function clh_handle(cmdLine) {
  12. if (!cmdLine.handleFlag("jsconsole", false))
  13. return;
  14. var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
  15. getService(Ci.nsIWindowMediator);
  16. var console = wm.getMostRecentWindow("global:console");
  17. if (!console) {
  18. var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"].
  19. getService(Ci.nsIWindowWatcher);
  20. wwatch.openWindow(null, "chrome://global/content/console.xul", "_blank",
  21. "chrome,dialog=no,all", cmdLine);
  22. } else {
  23. console.focus(); // the Error console was already open
  24. }
  25. if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO)
  26. cmdLine.preventDefault = true;
  27. },
  28. helpInfo : " --jsconsole Open the Error console.\n",
  29. classID: Components.ID("{2cd0c310-e127-44d0-88fc-4435c9ab4d4b}"),
  30. QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
  31. };
  32. this.NSGetFactory = XPCOMUtils.generateNSGetFactory([jsConsoleHandler]);