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
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | |
michael@0 | 7 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 8 | Components.utils.import("resource://gre/modules/Services.jsm"); |
michael@0 | 9 | |
michael@0 | 10 | // ----------------------------------------------------------------------- |
michael@0 | 11 | // Download Manager UI |
michael@0 | 12 | // ----------------------------------------------------------------------- |
michael@0 | 13 | |
michael@0 | 14 | function DownloadManagerUI() { } |
michael@0 | 15 | |
michael@0 | 16 | DownloadManagerUI.prototype = { |
michael@0 | 17 | classID: Components.ID("{93db15b1-b408-453e-9a2b-6619e168324a}"), |
michael@0 | 18 | |
michael@0 | 19 | show: function show(aWindowContext, aID, aReason, aUsePrivateUI) { |
michael@0 | 20 | if (!aReason) |
michael@0 | 21 | aReason = Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED; |
michael@0 | 22 | |
michael@0 | 23 | let browser = Services.wm.getMostRecentWindow("navigator:browser"); |
michael@0 | 24 | if (browser) |
michael@0 | 25 | browser.showDownloadManager(aWindowContext, aID, aReason); |
michael@0 | 26 | }, |
michael@0 | 27 | |
michael@0 | 28 | get visible() { |
michael@0 | 29 | // For now there is no Download Manager UI. |
michael@0 | 30 | return false; |
michael@0 | 31 | }, |
michael@0 | 32 | |
michael@0 | 33 | getAttention: function getAttention() { |
michael@0 | 34 | if (this.visible) |
michael@0 | 35 | this.show(null, null, null); |
michael@0 | 36 | else |
michael@0 | 37 | throw Cr.NS_ERROR_UNEXPECTED; |
michael@0 | 38 | }, |
michael@0 | 39 | |
michael@0 | 40 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI]) |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DownloadManagerUI]); |