Properly fix frame argument handling to work with both Mozilla 1.9 and Mozilla 1.8
[conkeror.git] / modules / daemon-mode.js
blobe3574d1ad9a8c61655430ae3d9bc895eea4e5da0
2 /*
3  * Daemon Mode
4  *
5  *   This mode gets loaded into application scope.
6  */
8 require("mode.js");
10 var daemon_quit_exits = true;
12 function daemon_quit_exits_p () {
13     return daemon_quit_exits;
16 function daemon_quit_hook_fn () {
17     if (daemon_quit_exits_p ())
18         daemon_mode (-1);
21 define_global_mode("daemon_mode",
22                    function () { // enable
23                        var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
24                            .getService(Components.interfaces.nsIAppStartup);
25                        appStartup.enterLastWindowClosingSurvivalArea();
26                        add_hook("quit_hook", daemon_quit_hook_fn);
27                    },
28                    function () { // disable
29                        var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
30                            .getService(Ci.nsIAppStartup);
31                        appStartup.exitLastWindowClosingSurvivalArea ();
32                        remove_hook("quit_hook", daemon_quit_hook_fn);
33                    });
35 require_later("command-line.js");
37 call_after_load("command-line.js", function () {
38         command_line_param_handler("daemon", true, function () {
39                 daemon_mode(true);
40                 var frame = make_frame();
41                 frame.setTimeout(function() { frame.close(); }, 0);
42             });
43     });