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