1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/metro/components/ContentDispatchChooser.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +const Ci = Components.interfaces; 1.9 +const Cu = Components.utils; 1.10 + 1.11 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.12 +Cu.import("resource://gre/modules/Services.jsm"); 1.13 + 1.14 +function ContentDispatchChooser() {} 1.15 + 1.16 +ContentDispatchChooser.prototype = 1.17 +{ 1.18 + classID: Components.ID("5a072a22-1e66-4100-afc1-07aed8b62fc5"), 1.19 + 1.20 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser]), 1.21 + 1.22 + ask: function ask(aHandler, aWindowContext, aURI, aReason) { 1.23 + let window = null; 1.24 + try { 1.25 + if (aWindowContext) 1.26 + window = aWindowContext.getInterface(Ci.nsIDOMWindow); 1.27 + } catch (e) { /* it's OK to not have a window */ } 1.28 + 1.29 + let bundle = Services.strings.createBundle("chrome://mozapps/locale/handling/handling.properties"); 1.30 + 1.31 + let title = bundle.GetStringFromName("protocol.title"); 1.32 + let message = bundle.GetStringFromName("protocol.description"); 1.33 + 1.34 + let open = Services.prompt.confirm(window, title, message); 1.35 + if (open) 1.36 + aHandler.launchWithURI(aURI, aWindowContext); 1.37 + } 1.38 +}; 1.39 + 1.40 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentDispatchChooser]); 1.41 +