browser-next-form-field: skip non-visible elements
[conkeror.git] / modules / daemon.js
blob4130aa1499eb56a1187c5ba7875bc5184bd9aada
1 /**
2  * (C) Copyright 2007 John J. Foerch
3  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
4  *
5  * Use, modification, and distribution are subject to the terms specified in the
6  * COPYING file.
7 **/
9 /*
10  * Daemon Mode
11  *
12  *   This mode gets loaded into application scope.
13  */
15 require("mode.js");
17 var daemon_quit_exits = true;
19 function daemon_quit_exits_p () {
20     return daemon_quit_exits;
23 function daemon_quit_hook_fn () {
24     if (daemon_quit_exits_p ())
25         daemon_mode (-1);
28 define_global_mode("daemon_mode",
29                    function () { // enable
30                        var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
31                            .getService(Components.interfaces.nsIAppStartup);
32                        appStartup.enterLastWindowClosingSurvivalArea();
33                        add_hook("quit_hook", daemon_quit_hook_fn);
34                    },
35                    function () { // disable
36                        var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
37                            .getService(Ci.nsIAppStartup);
38                        appStartup.exitLastWindowClosingSurvivalArea ();
39                        remove_hook("quit_hook", daemon_quit_hook_fn);
40                    });
42 require_later("command-line.js");
44 call_after_load("command-line.js", function () {
45         command_line_handler("daemon", true, function () {
46                 daemon_mode(true);
47                 var window = make_chrome_window(conkeror_chrome_URI);
48                 window.setTimeout(function() { window.close(); }, 0);
49             });
50     });