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