Bumping manifests a=b2g-bump
[gecko.git] / webapprt / DownloadView.jsm
blob8c140f933730f97c94eabffc95766c83911ad523
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 file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 this.EXPORTED_SYMBOLS = ["DownloadView"];
9 const Cu = Components.utils;
11 Cu.import("resource://gre/modules/Services.jsm");
12 Cu.import("resource://gre/modules/Downloads.jsm");
14 this.DownloadView = {
15   init: function() {
16     Downloads.getList(Downloads.ALL)
17              .then(list => list.addView(this))
18              .catch(Cu.reportError);
19   },
21   onDownloadAdded: function(aDownload) {
22     let dmWindow = Services.wm.getMostRecentWindow("Download:Manager");
23     if (dmWindow) {
24       dmWindow.focus();
25     } else {
26       Services.ww.openWindow(null,
27                              "chrome://webapprt/content/downloads/downloads.xul",
28                              "Download:Manager",
29                              "chrome,dialog=no,resizable",
30                              null);
31     }
32   },
35 DownloadView.init();