Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 Cu = Components.utils;
8 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
9 Cu.import("resource://gre/modules/Services.jsm");
11 function ContentDispatchChooser() {}
13 ContentDispatchChooser.prototype =
14 {
15 classID: Components.ID("5a072a22-1e66-4100-afc1-07aed8b62fc5"),
17 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser]),
19 ask: function ask(aHandler, aWindowContext, aURI, aReason) {
20 let window = null;
21 try {
22 if (aWindowContext)
23 window = aWindowContext.getInterface(Ci.nsIDOMWindow);
24 } catch (e) { /* it's OK to not have a window */ }
26 let bundle = Services.strings.createBundle("chrome://mozapps/locale/handling/handling.properties");
28 let title = bundle.GetStringFromName("protocol.title");
29 let message = bundle.GetStringFromName("protocol.description");
31 let open = Services.prompt.confirm(window, title, message);
32 if (open)
33 aHandler.launchWithURI(aURI, aWindowContext);
34 }
35 };
37 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentDispatchChooser]);