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.
michael@0 | 1 | this.EXPORTED_SYMBOLS = [ "PromptUtils" ]; |
michael@0 | 2 | |
michael@0 | 3 | const Cc = Components.classes; |
michael@0 | 4 | const Ci = Components.interfaces; |
michael@0 | 5 | const Cr = Components.results; |
michael@0 | 6 | const Cu = Components.utils; |
michael@0 | 7 | |
michael@0 | 8 | this.PromptUtils = { |
michael@0 | 9 | // Fire a dialog open/close event. Used by tabbrowser to focus the |
michael@0 | 10 | // tab which is triggering a prompt. |
michael@0 | 11 | // For remote dialogs, we pass in a different DOM window and a separate |
michael@0 | 12 | // target. If the caller doesn't pass in the target, then we'll simply use |
michael@0 | 13 | // the passed-in DOM window. |
michael@0 | 14 | fireDialogEvent : function (domWin, eventName, maybeTarget) { |
michael@0 | 15 | let target = maybeTarget || domWin; |
michael@0 | 16 | let event = domWin.document.createEvent("Events"); |
michael@0 | 17 | event.initEvent(eventName, true, true); |
michael@0 | 18 | let winUtils = domWin.QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 19 | .getInterface(Ci.nsIDOMWindowUtils); |
michael@0 | 20 | winUtils.dispatchEventToChromeOnly(target, event); |
michael@0 | 21 | }, |
michael@0 | 22 | |
michael@0 | 23 | objectToPropBag : function (obj) { |
michael@0 | 24 | let bag = Cc["@mozilla.org/hash-property-bag;1"]. |
michael@0 | 25 | createInstance(Ci.nsIWritablePropertyBag2); |
michael@0 | 26 | bag.QueryInterface(Ci.nsIWritablePropertyBag); |
michael@0 | 27 | |
michael@0 | 28 | for (let propName in obj) |
michael@0 | 29 | bag.setProperty(propName, obj[propName]); |
michael@0 | 30 | |
michael@0 | 31 | return bag; |
michael@0 | 32 | }, |
michael@0 | 33 | |
michael@0 | 34 | propBagToObject : function (propBag, obj) { |
michael@0 | 35 | // Here we iterate over the object's original properties, not the bag |
michael@0 | 36 | // (ie, the prompt can't return more/different properties than were |
michael@0 | 37 | // passed in). This just helps ensure that the caller provides default |
michael@0 | 38 | // values, lest the prompt forget to set them. |
michael@0 | 39 | for (let propName in obj) |
michael@0 | 40 | obj[propName] = propBag.getProperty(propName); |
michael@0 | 41 | }, |
michael@0 | 42 | }; |