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 if (!eval(expr)) | |
| 210 ary[i].hidden = true; | |
| 211 } | |
| 212 | 209 |
| 213 this.initTable_(); | 210 loadDelayedIncludes(this); |
| 211 }, | |
| 212 | |
| 213 /** | |
| 214 * Additional initialization of taskmanager. This function is called when | |
| 215 * the loading of delayed scripts finished. | |
| 216 * @public | |
| 217 */ | |
| 218 delayedInitialize: function () { | |
| 219 $('close-window').addEventListener('click', this.close.bind(this)); | |
| 220 $('kill-process').addEventListener('click', this.killProcess.bind(this)); | |
| 221 $('about-memory-link').addEventListener('click', | |
| 222 this.openAboutMemory.bind(this)); | |
| 214 this.initColumnMenu_(); | 223 this.initColumnMenu_(); |
| 215 this.initTableMenu_(); | 224 this.initTableMenu_(); |
| 216 this.table_.redraw(); | 225 |
| 226 this.isFinishedInitDelayed_ = true; | |
| 217 }, | 227 }, |
| 218 | 228 |
| 219 initColumnModel_: function () { | 229 initColumnModel_: function () { |
| 220 var table_columns = new Array(); | 230 var table_columns = new Array(); |
| 221 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 231 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
| 222 if (!this.is_column_shown_[i]) | 232 if (!this.is_column_shown_[i]) |
| 223 continue; | 233 continue; |
| 224 | 234 |
| 225 var column = DEFAULT_COLUMNS[i]; | 235 var column = DEFAULT_COLUMNS[i]; |
| 226 table_columns.push(new cr.ui.table.TableColumn(column[0], | 236 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') { | 372 if (columnId == 'title') { |
| 363 var image = this.document_.createElement('img'); | 373 var image = this.document_.createElement('img'); |
| 364 image.className = 'detail-title-image'; | 374 image.className = 'detail-title-image'; |
| 365 image.src = entry['icon'][i]; | 375 image.src = entry['icon'][i]; |
| 366 label.appendChild(image); | 376 label.appendChild(image); |
| 367 var text = this.document_.createElement('div'); | 377 var text = this.document_.createElement('div'); |
| 368 text.className = 'detail-title-text'; | 378 text.className = 'detail-title-text'; |
| 369 text.textContent = entry['title'][i]; | 379 text.textContent = entry['title'][i]; |
| 370 label.appendChild(text); | 380 label.appendChild(text); |
| 371 | 381 |
| 372 cr.ui.contextMenuHandler.addContextMenuProperty(label); | 382 if (this.isFinishedInitDelayed_) { |
|
mazda
2011/12/05 03:42:11
Is it OK to reach here when this.isFinishedInitDel
yoshiki
2011/12/05 08:38:15
It's ok. This block adds context menu handler to l
mazda
2011/12/06 09:58:18
I think it's undesirable.
How about storing the l
yoshiki
2011/12/07 16:01:09
Done.
| |
| 373 label.contextMenu = this.tableContextMenu_; | 383 cr.ui.contextMenuHandler.addContextMenuProperty(label); |
| 384 label.contextMenu = this.tableContextMenu_; | |
| 385 } | |
| 374 | 386 |
| 375 label.addEventListener('dblclick', (function(uniqueId) { | 387 label.addEventListener('dblclick', (function(uniqueId) { |
| 376 this.activatePage(uniqueId); | 388 this.activatePage(uniqueId); |
| 377 }).bind(this, entry['uniqueId'][i])); | 389 }).bind(this, entry['uniqueId'][i])); |
| 378 | 390 |
| 379 label.data = entry; | 391 label.data = entry; |
| 380 label.index_in_group = i; | 392 label.index_in_group = i; |
| 381 } else { | 393 } else { |
| 382 label.textContent = entry[columnId][i]; | 394 label.textContent = entry[columnId][i]; |
| 383 } | 395 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 taskmanager.onTaskChange(start, length, tasks); | 574 taskmanager.onTaskChange(start, length, tasks); |
| 563 } | 575 } |
| 564 | 576 |
| 565 function taskRemoved(start, length) { | 577 function taskRemoved(start, length) { |
| 566 // Sometimes this can get called too early. | 578 // Sometimes this can get called too early. |
| 567 if (!taskmanager) | 579 if (!taskmanager) |
| 568 return; | 580 return; |
| 569 taskmanager.onTaskRemove(start, length); | 581 taskmanager.onTaskRemove(start, length); |
| 570 } | 582 } |
| 571 | 583 |
| OLD | NEW |