annotate chrome/quit.js @ 196:dd0018bc27de

Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
author Benjamin Smedberg <benjamin@smedbergs.us>
date Wed, 21 Jul 2010 15:57:39 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
196
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; -*- */
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
2 /* ***** BEGIN LICENSE BLOCK *****
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
4 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
5 * The contents of this file are subject to the Mozilla Public License Version
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
6 * 1.1 (the "License"); you may not use this file except in compliance with
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
7 * the License. You may obtain a copy of the License at
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
8 * http://www.mozilla.org/MPL/
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
9 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
10 * Software distributed under the License is distributed on an "AS IS" basis,
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
12 * for the specific language governing rights and limitations under the
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
13 * License.
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
14 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
15 * The Original Code is The Original Code is Mozilla Automated Testing Code
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
16 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
17 * The Initial Developer of the Original Code is
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
18 * Mozilla Corporation.
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
19 * Portions created by the Initial Developer are Copyright (C) 2005
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
20 * the Initial Developer. All Rights Reserved.
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
21 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
22 * Contributor(s): Bob Clary <bob@bclary.com>
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
23 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
24 * Alternatively, the contents of this file may be used under the terms of
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
27 * in which case the provisions of the GPL or the LGPL are applicable instead
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
28 * of those above. If you wish to allow use of your version of this file only
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
29 * under the terms of either the GPL or the LGPL, and not to allow others to
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
30 * use your version of this file under the terms of the MPL, indicate your
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
31 * decision by deleting the provisions above and replace them with the notice
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
32 * and other provisions required by the GPL or the LGPL. If you do not delete
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
33 * the provisions above, a recipient may use your version of this file under
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
34 * the terms of any one of the MPL, the GPL or the LGPL.
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
35 *
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
36 * ***** END LICENSE BLOCK ***** */
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
37
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
38 /*
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
39 From mozilla/toolkit/content
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
40 These files did not have a license
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
41 */
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
42
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
43 function canQuitApplication()
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
44 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
45 var os = Components.classes["@mozilla.org/observer-service;1"]
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
46 .getService(Components.interfaces.nsIObserverService);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
47 if (!os)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
48 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
49 return true;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
50 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
51
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
52 try
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
53 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
54 var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
55 .createInstance(Components.interfaces.nsISupportsPRBool);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
56 os.notifyObservers(cancelQuit, "quit-application-requested", null);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
57
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
58 // Something aborted the quit process.
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
59 if (cancelQuit.data)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
60 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
61 return false;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
62 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
63 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
64 catch (ex)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
65 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
66 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
67 return true;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
68 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
69
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
70 function goQuitApplication()
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
71 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
72 if (!canQuitApplication())
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
73 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
74 return false;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
75 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
76
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
77 const kAppStartup = '@mozilla.org/toolkit/app-startup;1';
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
78 const kAppShell = '@mozilla.org/appshell/appShellService;1';
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
79 var appService;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
80 var forceQuit;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
81
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
82 if (kAppStartup in Components.classes)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
83 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
84 appService = Components.classes[kAppStartup].
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
85 getService(Components.interfaces.nsIAppStartup);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
86 forceQuit = Components.interfaces.nsIAppStartup.eForceQuit;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
87 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
88 else if (kAppShell in Components.classes)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
89 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
90 appService = Components.classes[kAppShell].
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
91 getService(Components.interfaces.nsIAppShellService);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
92 forceQuit = Components.interfaces.nsIAppShellService.eForceQuit;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
93 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
94 else
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
95 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
96 throw 'goQuitApplication: no AppStartup/appShell';
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
97 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
98
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
99 try
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
100 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
101 appService.quit(forceQuit);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
102 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
103 catch(ex)
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
104 {
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
105 throw('goQuitApplication: ' + ex);
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
106 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
107
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
108 return true;
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
109 }
dd0018bc27de Copy the pageloader from CVS and into a bundle format (single chrome.manifest).
Benjamin Smedberg <benjamin@smedbergs.us>
parents:
diff changeset
110