|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 var Ci = Components.interfaces; |
|
6 var Cc = Components.classes; |
|
7 |
|
8 function Quitter() { |
|
9 } |
|
10 |
|
11 Quitter.prototype = { |
|
12 toString: function() { return "[Quitter]"; }, |
|
13 quit: function() { |
|
14 sendSyncMessage('Quitter.Quit', {}); |
|
15 }, |
|
16 __exposedProps__: { |
|
17 'toString': 'r', |
|
18 'quit': 'r' |
|
19 } |
|
20 }; |
|
21 |
|
22 // This is a frame script, so it may be running in a content process. |
|
23 // In any event, it is targeted at a specific "tab", so we listen for |
|
24 // the DOMWindowCreated event to be notified about content windows |
|
25 // being created in this context. |
|
26 |
|
27 function QuitterManager() { |
|
28 addEventListener("DOMWindowCreated", this, false); |
|
29 } |
|
30 |
|
31 QuitterManager.prototype = { |
|
32 handleEvent: function handleEvent(aEvent) { |
|
33 var window = aEvent.target.defaultView; |
|
34 window.wrappedJSObject.Quitter = new Quitter(window); |
|
35 } |
|
36 }; |
|
37 |
|
38 var quittermanager = new QuitterManager(); |