michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function ContentDispatchChooser() {} michael@0: michael@0: ContentDispatchChooser.prototype = michael@0: { michael@0: classID: Components.ID("5a072a22-1e66-4100-afc1-07aed8b62fc5"), michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser]), michael@0: michael@0: ask: function ask(aHandler, aWindowContext, aURI, aReason) { michael@0: let window = null; michael@0: try { michael@0: if (aWindowContext) michael@0: window = aWindowContext.getInterface(Ci.nsIDOMWindow); michael@0: } catch (e) { /* it's OK to not have a window */ } michael@0: michael@0: let bundle = Services.strings.createBundle("chrome://mozapps/locale/handling/handling.properties"); michael@0: michael@0: let title = bundle.GetStringFromName("protocol.title"); michael@0: let message = bundle.GetStringFromName("protocol.description"); michael@0: michael@0: let open = Services.prompt.confirm(window, title, message); michael@0: if (open) michael@0: aHandler.launchWithURI(aURI, aWindowContext); michael@0: } michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentDispatchChooser]); michael@0: