Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** @constructor */ | 5 /** @constructor */ |
| 6 function TaskManager() { } | 6 function TaskManager() { } |
| 7 | 7 |
| 8 cr.addSingletonGetter(TaskManager); | 8 cr.addSingletonGetter(TaskManager); |
| 9 | 9 |
| 10 /* | 10 /* |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 * @public | 138 * @public |
| 139 */ | 139 */ |
| 140 initialize: function (dialogDom, opt) { | 140 initialize: function (dialogDom, opt) { |
| 141 if (!dialogDom) { | 141 if (!dialogDom) { |
| 142 console.log('ERROR: dialogDom is not defined.'); | 142 console.log('ERROR: dialogDom is not defined.'); |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 | 145 |
| 146 this.opt_ = opt; | 146 this.opt_ = opt; |
| 147 | 147 |
| 148 this.initialized_ = true; | |
| 149 this.enableTaskManager(); | 148 this.enableTaskManager(); |
| 150 | 149 |
| 151 this.dialogDom_ = dialogDom; | 150 this.dialogDom_ = dialogDom; |
| 152 this.document_ = dialogDom.ownerDocument; | 151 this.document_ = dialogDom.ownerDocument; |
| 153 | 152 |
| 154 $('close-window').addEventListener('click', this.close.bind(this)); | 153 var ary = this.dialogDom_.querySelectorAll('[visibleif]'); |
| 155 $('kill-process').addEventListener('click', this.killProcess.bind(this)); | 154 for (var i = 0; i < ary.length; i++) { |
| 156 $('about-memory-link').addEventListener('click', | 155 var expr = ary[i].getAttribute('visibleif'); |
| 157 this.openAboutMemory.bind(this)); | 156 if (!eval(expr)) |
| 157 ary[i].hidden = true; | |
| 158 } | |
| 158 | 159 |
| 159 this.is_column_shown_ = []; | 160 this.is_column_shown_ = []; |
| 160 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 161 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
| 161 this.is_column_shown_[i] = DEFAULT_COLUMNS[i][3]; | 162 this.is_column_shown_[i] = DEFAULT_COLUMNS[i][3]; |
| 162 } | 163 } |
| 163 | 164 |
| 164 this.localized_column_ = []; | 165 this.localized_column_ = []; |
| 165 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 166 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
| 166 var column_label_id = DEFAULT_COLUMNS[i][1]; | 167 var column_label_id = DEFAULT_COLUMNS[i][1]; |
| 167 var localized_label = localStrings.getString(column_label_id); | 168 var localized_label = localStrings.getString(column_label_id); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 196 var aValues = a[value_id]; | 197 var aValues = a[value_id]; |
| 197 var bValues = b[value_id]; | 198 var bValues = b[value_id]; |
| 198 var aValue = aValues && aValues[0] || 0; | 199 var aValue = aValues && aValues[0] || 0; |
| 199 var bvalue = bValues && bValues[0] || 0; | 200 var bvalue = bValues && bValues[0] || 0; |
| 200 return dm.defaultValuesCompareFunction(aValue, bvalue); | 201 return dm.defaultValuesCompareFunction(aValue, bvalue); |
| 201 }; | 202 }; |
| 202 }(); | 203 }(); |
| 203 dm.setCompareFunction(column_id, compare_func); | 204 dm.setCompareFunction(column_id, compare_func); |
| 204 } | 205 } |
| 205 | 206 |
| 206 var ary = this.dialogDom_.querySelectorAll('[visibleif]'); | 207 this.initTable_(); |
| 207 for (var i = 0; i < ary.length; i++) { | 208 this.initialized_ = true; |
| 208 var expr = ary[i].getAttribute('visibleif'); | 209 }, |
| 209 if (!eval(expr)) | |
| 210 ary[i].hidden = true; | |
| 211 } | |
| 212 | 210 |
| 213 this.initTable_(); | 211 /** |
| 212 * Additional initialization of taskmanager. This function is called when | |
| 213 * the loading of delayed scripts finished. | |
| 214 * @public | |
| 215 */ | |
| 216 delayedInitialize: function () { | |
| 217 $('close-window').addEventListener('click', this.close.bind(this)); | |
| 218 $('kill-process').addEventListener('click', this.killProcess.bind(this)); | |
| 219 $('about-memory-link').addEventListener('click', | |
| 220 this.openAboutMemory.bind(this)); | |
| 214 this.initColumnMenu_(); | 221 this.initColumnMenu_(); |
| 215 this.initTableMenu_(); | 222 this.initTableMenu_(); |
| 216 this.table_.redraw(); | 223 |
| 224 this.isFinishedInitDelayed_ = true; | |
| 217 }, | 225 }, |
| 218 | 226 |
| 219 initColumnModel_: function () { | 227 initColumnModel_: function () { |
| 220 var table_columns = new Array(); | 228 var table_columns = new Array(); |
| 221 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 229 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
| 222 if (!this.is_column_shown_[i]) | 230 if (!this.is_column_shown_[i]) |
| 223 continue; | 231 continue; |
| 224 | 232 |
| 225 var column = DEFAULT_COLUMNS[i]; | 233 var column = DEFAULT_COLUMNS[i]; |
| 226 table_columns.push(new cr.ui.table.TableColumn(column[0], | 234 table_columns.push(new cr.ui.table.TableColumn(column[0], |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 if (columnId == 'title') { | 370 if (columnId == 'title') { |
| 363 var image = this.document_.createElement('img'); | 371 var image = this.document_.createElement('img'); |
| 364 image.className = 'detail-title-image'; | 372 image.className = 'detail-title-image'; |
| 365 image.src = entry['icon'][i]; | 373 image.src = entry['icon'][i]; |
| 366 label.appendChild(image); | 374 label.appendChild(image); |
| 367 var text = this.document_.createElement('div'); | 375 var text = this.document_.createElement('div'); |
| 368 text.className = 'detail-title-text'; | 376 text.className = 'detail-title-text'; |
| 369 text.textContent = entry['title'][i]; | 377 text.textContent = entry['title'][i]; |
| 370 label.appendChild(text); | 378 label.appendChild(text); |
| 371 | 379 |
| 372 cr.ui.contextMenuHandler.addContextMenuProperty(label); | 380 if (this.isFinishedInitDelayed_) { |
|
mazda
2011/11/30 12:05:54
Is it possible to reach here without this.isFinish
yoshiki
2011/12/01 16:18:25
Delayed scripts are loaded with 'defer' property,
| |
| 373 label.contextMenu = this.tableContextMenu_; | 381 cr.ui.contextMenuHandler.addContextMenuProperty(label); |
| 382 label.contextMenu = this.tableContextMenu_; | |
| 383 } | |
| 374 | 384 |
| 375 label.addEventListener('dblclick', (function(uniqueId) { | 385 label.addEventListener('dblclick', (function(uniqueId) { |
| 376 this.activatePage(uniqueId); | 386 this.activatePage(uniqueId); |
| 377 }).bind(this, entry['uniqueId'][i])); | 387 }).bind(this, entry['uniqueId'][i])); |
| 378 | 388 |
| 379 label.data = entry; | 389 label.data = entry; |
| 380 label.index_in_group = i; | 390 label.index_in_group = i; |
| 381 } else { | 391 } else { |
| 382 label.textContent = entry[columnId][i]; | 392 label.textContent = entry[columnId][i]; |
| 383 } | 393 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 taskmanager.onTaskChange(start, length, tasks); | 572 taskmanager.onTaskChange(start, length, tasks); |
| 563 } | 573 } |
| 564 | 574 |
| 565 function taskRemoved(start, length) { | 575 function taskRemoved(start, length) { |
| 566 // Sometimes this can get called too early. | 576 // Sometimes this can get called too early. |
| 567 if (!taskmanager) | 577 if (!taskmanager) |
| 568 return; | 578 return; |
| 569 taskmanager.onTaskRemove(start, length); | 579 taskmanager.onTaskRemove(start, length); |
| 570 } | 580 } |
| 571 | 581 |
| OLD | NEW |