toolkit/mozapps/handling/nsContentDispatchChooser.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 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 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 6
michael@0 7 ////////////////////////////////////////////////////////////////////////////////
michael@0 8 //// Constants
michael@0 9
michael@0 10 const Cc = Components.classes;
michael@0 11 const Ci = Components.interfaces;
michael@0 12 const Cr = Components.results;
michael@0 13
michael@0 14 const CONTENT_HANDLING_URL = "chrome://mozapps/content/handling/dialog.xul";
michael@0 15 const STRINGBUNDLE_URL = "chrome://mozapps/locale/handling/handling.properties";
michael@0 16
michael@0 17 ////////////////////////////////////////////////////////////////////////////////
michael@0 18 //// nsContentDispatchChooser class
michael@0 19
michael@0 20 function nsContentDispatchChooser()
michael@0 21 {
michael@0 22 }
michael@0 23
michael@0 24 nsContentDispatchChooser.prototype =
michael@0 25 {
michael@0 26 classID: Components.ID("e35d5067-95bc-4029-8432-e8f1e431148d"),
michael@0 27
michael@0 28 //////////////////////////////////////////////////////////////////////////////
michael@0 29 //// nsIContentDispatchChooser
michael@0 30
michael@0 31 ask: function ask(aHandler, aWindowContext, aURI, aReason)
michael@0 32 {
michael@0 33 var window = null;
michael@0 34 try {
michael@0 35 if (aWindowContext)
michael@0 36 window = aWindowContext.getInterface(Ci.nsIDOMWindow);
michael@0 37 } catch (e) { /* it's OK to not have a window */ }
michael@0 38
michael@0 39 var sbs = Cc["@mozilla.org/intl/stringbundle;1"].
michael@0 40 getService(Ci.nsIStringBundleService);
michael@0 41 var bundle = sbs.createBundle(STRINGBUNDLE_URL);
michael@0 42
michael@0 43 var xai = Cc["@mozilla.org/xre/app-info;1"].
michael@0 44 getService(Ci.nsIXULAppInfo);
michael@0 45 // TODO when this is hooked up for content, we will need different strings
michael@0 46 // for most of these
michael@0 47 var arr = [bundle.GetStringFromName("protocol.title"),
michael@0 48 "",
michael@0 49 bundle.GetStringFromName("protocol.description"),
michael@0 50 bundle.GetStringFromName("protocol.choices.label"),
michael@0 51 bundle.formatStringFromName("protocol.checkbox.label",
michael@0 52 [aURI.scheme], 1),
michael@0 53 bundle.GetStringFromName("protocol.checkbox.accesskey"),
michael@0 54 bundle.formatStringFromName("protocol.checkbox.extra",
michael@0 55 [xai.name], 1)];
michael@0 56
michael@0 57 var params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
michael@0 58 let SupportsString = Components.Constructor(
michael@0 59 "@mozilla.org/supports-string;1",
michael@0 60 "nsISupportsString");
michael@0 61 for each (let text in arr) {
michael@0 62 let string = new SupportsString;
michael@0 63 string.data = text;
michael@0 64 params.appendElement(string, false);
michael@0 65 }
michael@0 66 params.appendElement(aHandler, false);
michael@0 67 params.appendElement(aURI, false);
michael@0 68 params.appendElement(aWindowContext, false);
michael@0 69
michael@0 70 var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
michael@0 71 getService(Ci.nsIWindowWatcher);
michael@0 72 ww.openWindow(window,
michael@0 73 CONTENT_HANDLING_URL,
michael@0 74 null,
michael@0 75 "chrome,dialog=yes,resizable,centerscreen",
michael@0 76 params);
michael@0 77 },
michael@0 78
michael@0 79 //////////////////////////////////////////////////////////////////////////////
michael@0 80 //// nsISupports
michael@0 81
michael@0 82 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser])
michael@0 83 };
michael@0 84
michael@0 85 ////////////////////////////////////////////////////////////////////////////////
michael@0 86 //// Module
michael@0 87
michael@0 88 let components = [nsContentDispatchChooser];
michael@0 89
michael@0 90 this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);

mercurial