Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
5 const Ci = Components.interfaces;
6 const Cr = Components.results;
7 const Cc = Components.classes;
8 const Cu = Components.utils;
10 Cu.import("resource://gre/modules/Services.jsm");
11 Cu.import("resource://gre/modules/CommonDialog.jsm");
13 let propBag, args, Dialog;
15 function commonDialogOnLoad() {
16 propBag = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2)
17 .QueryInterface(Ci.nsIWritablePropertyBag);
18 // Convert to a JS object
19 args = {};
20 let propEnum = propBag.enumerator;
21 while (propEnum.hasMoreElements()) {
22 let prop = propEnum.getNext().QueryInterface(Ci.nsIProperty);
23 args[prop.name] = prop.value;
24 }
26 let dialog = document.documentElement;
28 let ui = {
29 prompt : window,
30 loginContainer : document.getElementById("loginContainer"),
31 loginTextbox : document.getElementById("loginTextbox"),
32 loginLabel : document.getElementById("loginLabel"),
33 password1Container : document.getElementById("password1Container"),
34 password1Textbox : document.getElementById("password1Textbox"),
35 password1Label : document.getElementById("password1Label"),
36 infoBody : document.getElementById("info.body"),
37 infoTitle : document.getElementById("info.title"),
38 infoIcon : document.getElementById("info.icon"),
39 checkbox : document.getElementById("checkbox"),
40 checkboxContainer : document.getElementById("checkboxContainer"),
41 button3 : dialog.getButton("extra2"),
42 button2 : dialog.getButton("extra1"),
43 button1 : dialog.getButton("cancel"),
44 button0 : dialog.getButton("accept"),
45 focusTarget : window,
46 };
48 // limit the dialog to the screen width
49 document.getElementById("filler").maxWidth = screen.availWidth;
50 Services.obs.addObserver(softkbObserver, "softkb-change", false);
52 Dialog = new CommonDialog(args, ui);
53 Dialog.onLoad(dialog);
54 window.getAttention();
55 }
57 function commonDialogOnUnload() {
58 Services.obs.removeObserver(softkbObserver, "softkb-change");
59 // Convert args back into property bag
60 for (let propName in args)
61 propBag.setProperty(propName, args[propName]);
62 }
64 function softkbObserver(subject, topic, data) {
65 let rect = JSON.parse(data);
66 if (rect) {
67 let height = rect.bottom - rect.top;
68 let width = rect.right - rect.left;
69 let top = (rect.top + (height - window.innerHeight) / 2);
70 let left = (rect.left + (width - window.innerWidth) / 2);
71 window.moveTo(left, top);
72 }
73 }