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 Cr = Components.results; michael@0: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: // ----------------------------------------------------------------------- michael@0: // Download Manager UI michael@0: // ----------------------------------------------------------------------- michael@0: michael@0: function DownloadManagerUI() { } michael@0: michael@0: DownloadManagerUI.prototype = { michael@0: classID: Components.ID("{93db15b1-b408-453e-9a2b-6619e168324a}"), michael@0: michael@0: show: function show(aWindowContext, aDownload, aReason, aUsePrivateUI) { michael@0: if (!aReason) michael@0: aReason = Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED; michael@0: michael@0: this._getBrowserApp().selectOrOpenTab("about:downloads"); michael@0: }, michael@0: michael@0: get visible() { michael@0: let browserApp = this._getBrowserApp(); michael@0: let downloadsTab = browserApp.getTabWithURL("about:downloads"); michael@0: return (downloadsTab && downloadsTab == browserApp.selectedTab) ? true : false; michael@0: }, michael@0: michael@0: getAttention: function getAttention() { michael@0: if (this._getBrowserApp().getTabWithURL("about:downloads")) michael@0: return; michael@0: michael@0: throw Cr.NS_ERROR_UNEXPECTED; michael@0: }, michael@0: michael@0: _getBrowserApp: function getBrowserApp() { michael@0: try { michael@0: return Services.wm.getMostRecentWindow("navigator:browser").BrowserApp; michael@0: } catch (e) { michael@0: throw Cr.NS_ERROR_FAILURE; michael@0: } michael@0: }, michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI]) michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DownloadManagerUI]);