|
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/. */ |
|
4 |
|
5 const Ci = Components.interfaces; |
|
6 const Cu = Components.utils; |
|
7 |
|
8 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
9 Cu.import("resource://gre/modules/Services.jsm"); |
|
10 |
|
11 function ContentDispatchChooser() {} |
|
12 |
|
13 ContentDispatchChooser.prototype = |
|
14 { |
|
15 classID: Components.ID("5a072a22-1e66-4100-afc1-07aed8b62fc5"), |
|
16 |
|
17 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentDispatchChooser]), |
|
18 |
|
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 */ } |
|
25 |
|
26 let bundle = Services.strings.createBundle("chrome://mozapps/locale/handling/handling.properties"); |
|
27 |
|
28 let title = bundle.GetStringFromName("protocol.title"); |
|
29 let message = bundle.GetStringFromName("protocol.description"); |
|
30 |
|
31 let open = Services.prompt.confirm(window, title, message); |
|
32 if (open) |
|
33 aHandler.launchWithURI(aURI, aWindowContext); |
|
34 } |
|
35 }; |
|
36 |
|
37 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentDispatchChooser]); |
|
38 |