toolkit/components/prompts/content/selectDialog.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 const Ci = Components.interfaces;
michael@0 6 const Cr = Components.results;
michael@0 7 const Cc = Components.classes;
michael@0 8 const Cu = Components.utils;
michael@0 9
michael@0 10 let gArgs, listBox;
michael@0 11
michael@0 12 function dialogOnLoad() {
michael@0 13 gArgs = window.arguments[0].QueryInterface(Ci.nsIWritablePropertyBag2)
michael@0 14 .QueryInterface(Ci.nsIWritablePropertyBag);
michael@0 15
michael@0 16 let promptType = gArgs.getProperty("promptType");
michael@0 17 if (promptType != "select") {
michael@0 18 Cu.reportError("selectDialog opened for unknown type: " + promptType);
michael@0 19 window.close();
michael@0 20 }
michael@0 21
michael@0 22 // Default to canceled.
michael@0 23 gArgs.setProperty("ok", false);
michael@0 24
michael@0 25 document.title = gArgs.getProperty("title");
michael@0 26
michael@0 27 let text = gArgs.getProperty("text");
michael@0 28 document.getElementById("info.txt").setAttribute("value", text);
michael@0 29
michael@0 30 let items = gArgs.getProperty("list");
michael@0 31 listBox = document.getElementById("list");
michael@0 32
michael@0 33 for (let i = 0; i < items.length; i++) {
michael@0 34 let str = items[i];
michael@0 35 if (str == "")
michael@0 36 str = "<>";
michael@0 37 listBox.appendItem(str);
michael@0 38 listBox.getItemAtIndex(i).addEventListener("dblclick", dialogDoubleClick, false);
michael@0 39 }
michael@0 40 listBox.selectedIndex = 0;
michael@0 41 listBox.focus();
michael@0 42
michael@0 43 // resize the window to the content
michael@0 44 window.sizeToContent();
michael@0 45
michael@0 46 // Move to the right location
michael@0 47 moveToAlertPosition();
michael@0 48 centerWindowOnScreen();
michael@0 49
michael@0 50 // play sound
michael@0 51 try {
michael@0 52 Cc["@mozilla.org/sound;1"].
michael@0 53 createInstance(Ci.nsISound).
michael@0 54 playEventSound(Ci.nsISound.EVENT_SELECT_DIALOG_OPEN);
michael@0 55 } catch (e) { }
michael@0 56 }
michael@0 57
michael@0 58 function dialogOK() {
michael@0 59 let selected = listBox.selectedIndex;
michael@0 60 gArgs.setProperty("selected", listBox.selectedIndex);
michael@0 61 gArgs.setProperty("ok", true);
michael@0 62 return true;
michael@0 63 }
michael@0 64
michael@0 65 function dialogDoubleClick() {
michael@0 66 dialogOK();
michael@0 67 window.close();
michael@0 68 }

mercurial