OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TODO(jhawkins): Use hidden instead of showInline* and display:none. | 5 // TODO(jhawkins): Use hidden instead of showInline* and display:none. |
6 // TODO(hcarmona): This file is big: it may be good to split it up. | 6 // TODO(hcarmona): This file is big: it may be good to split it up. |
7 | 7 |
8 /** | 8 /** |
9 * The type of the download object. The definition is based on | 9 * The type of the download object. The definition is based on |
10 * chrome/browser/ui/webui/downloads_dom_handler.cc:CreateDownloadItemValue() | 10 * chrome/browser/ui/webui/downloads_dom_handler.cc:CreateDownloadItemValue() |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 }; | 175 }; |
176 | 176 |
177 /////////////////////////////////////////////////////////////////////////////// | 177 /////////////////////////////////////////////////////////////////////////////// |
178 // Downloads | 178 // Downloads |
179 /** | 179 /** |
180 * Class to hold all the information about the visible downloads. | 180 * Class to hold all the information about the visible downloads. |
181 * @constructor | 181 * @constructor |
182 */ | 182 */ |
183 function Downloads() { | 183 function Downloads() { |
184 /** | 184 /** |
185 * @type {!Object.<string, Download>} | 185 * @type {!Object<string, Download>} |
186 * @private | 186 * @private |
187 */ | 187 */ |
188 this.downloads_ = {}; | 188 this.downloads_ = {}; |
189 this.node_ = $('downloads-display'); | 189 this.node_ = $('downloads-display'); |
190 this.summary_ = $('downloads-summary-text'); | 190 this.summary_ = $('downloads-summary-text'); |
191 this.searchText_ = ''; | 191 this.searchText_ = ''; |
192 this.focusGrid_ = new cr.ui.FocusGrid(); | 192 this.focusGrid_ = new cr.ui.FocusGrid(); |
193 | 193 |
194 // Keep track of the dates of the newest and oldest downloads so that we | 194 // Keep track of the dates of the newest and oldest downloads so that we |
195 // know where to insert them. | 195 // know where to insert them. |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 downloads.clear(); | 1053 downloads.clear(); |
1054 downloads.setSearchText(''); | 1054 downloads.setSearchText(''); |
1055 chrome.send('clearAll'); | 1055 chrome.send('clearAll'); |
1056 } | 1056 } |
1057 | 1057 |
1058 /////////////////////////////////////////////////////////////////////////////// | 1058 /////////////////////////////////////////////////////////////////////////////// |
1059 // Chrome callbacks: | 1059 // Chrome callbacks: |
1060 /** | 1060 /** |
1061 * Our history system calls this function with results from searches or when | 1061 * Our history system calls this function with results from searches or when |
1062 * downloads are added or removed. | 1062 * downloads are added or removed. |
1063 * @param {Array.<Object>} results List of updates. | 1063 * @param {Array<Object>} results List of updates. |
1064 */ | 1064 */ |
1065 function downloadsList(results) { | 1065 function downloadsList(results) { |
1066 if (downloads && downloads.isUpdateNeeded(results)) { | 1066 if (downloads && downloads.isUpdateNeeded(results)) { |
1067 if (resultsTimeout) | 1067 if (resultsTimeout) |
1068 clearTimeout(resultsTimeout); | 1068 clearTimeout(resultsTimeout); |
1069 fifoResults.length = 0; | 1069 fifoResults.length = 0; |
1070 downloads.clear(); | 1070 downloads.clear(); |
1071 downloadUpdated(results); | 1071 downloadUpdated(results); |
1072 } | 1072 } |
1073 downloads.updateResults(); | 1073 downloads.updateResults(); |
1074 downloads.updateSummary(); | 1074 downloads.updateSummary(); |
1075 } | 1075 } |
1076 | 1076 |
1077 /** | 1077 /** |
1078 * When a download is updated (progress, state change), this is called. | 1078 * When a download is updated (progress, state change), this is called. |
1079 * @param {Array.<Object>} results List of updates for the download process. | 1079 * @param {Array<Object>} results List of updates for the download process. |
1080 */ | 1080 */ |
1081 function downloadUpdated(results) { | 1081 function downloadUpdated(results) { |
1082 // Sometimes this can get called too early. | 1082 // Sometimes this can get called too early. |
1083 if (!downloads) | 1083 if (!downloads) |
1084 return; | 1084 return; |
1085 | 1085 |
1086 fifoResults = fifoResults.concat(results); | 1086 fifoResults = fifoResults.concat(results); |
1087 tryDownloadUpdatedPeriodically(); | 1087 tryDownloadUpdatedPeriodically(); |
1088 } | 1088 } |
1089 | 1089 |
(...skipping 10 matching lines...) Expand all Loading... |
1100 if (Date.now() - start > 50) { | 1100 if (Date.now() - start > 50) { |
1101 clearTimeout(resultsTimeout); | 1101 clearTimeout(resultsTimeout); |
1102 resultsTimeout = setTimeout(tryDownloadUpdatedPeriodically, 5); | 1102 resultsTimeout = setTimeout(tryDownloadUpdatedPeriodically, 5); |
1103 break; | 1103 break; |
1104 } | 1104 } |
1105 } | 1105 } |
1106 } | 1106 } |
1107 | 1107 |
1108 // Add handlers to HTML elements. | 1108 // Add handlers to HTML elements. |
1109 window.addEventListener('DOMContentLoaded', load); | 1109 window.addEventListener('DOMContentLoaded', load); |
OLD | NEW |