diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/mozapps/handling/nsContentDispatchChooser.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/mozapps/handling/nsContentDispatchChooser.js')
-rw-r--r-- | toolkit/mozapps/handling/nsContentDispatchChooser.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/toolkit/mozapps/handling/nsContentDispatchChooser.js b/toolkit/mozapps/handling/nsContentDispatchChooser.js new file mode 100644 index 000000000..e02545594 --- /dev/null +++ b/toolkit/mozapps/handling/nsContentDispatchChooser.js @@ -0,0 +1,85 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + +// Constants + +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cr = Components.results; + +const CONTENT_HANDLING_URL = "chrome://mozapps/content/handling/dialog.xul"; +const STRINGBUNDLE_URL = "chrome://mozapps/locale/handling/handling.properties"; + +// nsContentDispatchChooser class + +function nsContentDispatchChooser() +{ +} + +nsContentDispatchChooser.prototype = +{ + classID: Components.ID("e35d5067-95bc-4029-8432-e8f1e431148d"), + + // nsIContentDispatchChooser + + ask: function ask(aHandler, aWindowContext, aURI, aReason) + { + var window = null; + try { + if (aWindowContext) + window = aWindowContext.getInterface(Ci.nsIDOMWindow); + } catch (e) { /* it's OK to not have a window */ } + + var sbs = Cc["@mozilla.org/intl/stringbundle;1"]. + getService(Ci.nsIStringBundleService); + var bundle = sbs.createBundle(STRINGBUNDLE_URL); + + var xai = Cc["@mozilla.org/xre/app-info;1"]. + getService(Ci.nsIXULAppInfo); + // TODO when this is hooked up for content, we will need different strings + // for most of these + var arr = [bundle.GetStringFromName("protocol.title"), + "", + bundle.GetStringFromName("protocol.description"), + bundle.GetStringFromName("protocol.choices.label"), + bundle.formatStringFromName("protocol.checkbox.label", + [aURI.scheme], 1), + bundle.GetStringFromName("protocol.checkbox.accesskey"), + bundle.formatStringFromName("protocol.checkbox.extra", + [xai.name], 1)]; + + var params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray); + let SupportsString = Components.Constructor( + "@mozilla.org/supports-string;1", + "nsISupportsString"); + for (let text of arr) { + let string = new SupportsString; + string.data = text; + params.appendElement(string, false); + } + params.appendElement(aHandler, false); + params.appendElement(aURI, false); + params.appendElement(aWindowContext, false); + + var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. + getService(Ci.nsIWindowWatcher); + ww.openWindow(window, + CONTENT_HANDLING_URL, + null, + "chrome,dialog=yes,resizable,centerscreen", + params); + }, + + // nsISupports + + QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser]) +}; + +// Module + +var components = [nsContentDispatchChooser]; + +this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components); |