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 /** @constructor */ | 5 /** @constructor */ |
6 function TaskManager() { } | 6 function TaskManager() { } |
7 | 7 |
8 cr.addSingletonGetter(TaskManager); | 8 cr.addSingletonGetter(TaskManager); |
9 | 9 |
10 var localStrings = new LocalStrings(); | 10 var localStrings = new LocalStrings(); |
11 | 11 |
12 TaskManager.prototype = { | 12 TaskManager.prototype = { |
13 /** | 13 /** |
14 * Handle window close. | 14 * Handle window close. |
| 15 * @this |
15 */ | 16 */ |
16 onClose: function () { | 17 onClose: function() { |
17 if (!this.disabled_) { | 18 if (!this.disabled_) { |
18 this.disabled_ = true; | 19 this.disabled_ = true; |
19 commands.disableTaskManager(); | 20 commands.disableTaskManager(); |
20 } | 21 } |
21 }, | 22 }, |
22 | 23 |
23 /** | 24 /** |
24 * Handles selection changes. | 25 * Handles selection changes. |
25 * This is also called when data of tasks are refreshed, even if selection | 26 * This is also called when data of tasks are refreshed, even if selection |
26 * has not been changed. | 27 * has not been changed. |
| 28 * @this |
27 */ | 29 */ |
28 onSelectionChange: function () { | 30 onSelectionChange: function() { |
29 var sm = this.selectionModel_; | 31 var sm = this.selectionModel_; |
30 var dm = this.dataModel_; | 32 var dm = this.dataModel_; |
31 var selectedIndexes = sm.selectedIndexes; | 33 var selectedIndexes = sm.selectedIndexes; |
32 var is_end_process_enabled = true; | 34 var is_end_process_enabled = true; |
33 if (selectedIndexes.length == 0) | 35 if (selectedIndexes.length == 0) |
34 is_end_process_enabled = false; | 36 is_end_process_enabled = false; |
35 for (var i = 0; i < selectedIndexes.length; i++) { | 37 for (var i = 0; i < selectedIndexes.length; i++) { |
36 var index = selectedIndexes[i]; | 38 var index = selectedIndexes[i]; |
37 var task = dm.item(index); | 39 var task = dm.item(index); |
38 if (task['type'] == 'BROWSER') | 40 if (task['type'] == 'BROWSER') |
39 is_end_process_enabled = false; | 41 is_end_process_enabled = false; |
40 } | 42 } |
41 if (this.is_end_process_enabled_ != is_end_process_enabled) { | 43 if (this.is_end_process_enabled_ != is_end_process_enabled) { |
42 if (is_end_process_enabled) | 44 if (is_end_process_enabled) |
43 $('kill-process').removeAttribute("disabled"); | 45 $('kill-process').removeAttribute('disabled'); |
44 else | 46 else |
45 $('kill-process').setAttribute("disabled", "true"); | 47 $('kill-process').setAttribute('disabled', 'true'); |
46 | 48 |
47 this.is_end_process_enabled_ = is_end_process_enabled; | 49 this.is_end_process_enabled_ = is_end_process_enabled; |
48 } | 50 } |
49 }, | 51 }, |
50 | 52 |
51 /** | 53 /** |
52 * Closes taskmanager dialog. | 54 * Closes taskmanager dialog. |
53 * After this function is called, onClose() will be called. | 55 * After this function is called, onClose() will be called. |
| 56 * @this |
54 */ | 57 */ |
55 close: function () { | 58 close: function() { |
56 window.close(); | 59 window.close(); |
57 }, | 60 }, |
58 | 61 |
59 /** | 62 /** |
60 * Sends commands to kill selected processes. | 63 * Sends commands to kill selected processes. |
| 64 * @this |
61 */ | 65 */ |
62 killSelectedProcesses: function () { | 66 killSelectedProcesses: function() { |
63 var selectedIndexes = this.selectionModel_.selectedIndexes; | 67 var selectedIndexes = this.selectionModel_.selectedIndexes; |
64 var dm = this.dataModel_; | 68 var dm = this.dataModel_; |
65 var uniqueIds = []; | 69 var uniqueIds = []; |
66 for (var i = 0; i < selectedIndexes.length; i++) { | 70 for (var i = 0; i < selectedIndexes.length; i++) { |
67 var index = selectedIndexes[i]; | 71 var index = selectedIndexes[i]; |
68 var task = dm.item(index); | 72 var task = dm.item(index); |
69 uniqueIds.push(task['uniqueId'][0]); | 73 uniqueIds.push(task['uniqueId'][0]); |
70 } | 74 } |
71 | 75 |
72 commands.killSelectedProcesses(uniqueIds); | 76 commands.killSelectedProcesses(uniqueIds); |
73 }, | 77 }, |
74 | 78 |
75 /** | 79 /** |
76 * Initializes taskmanager. | 80 * Initializes taskmanager. |
| 81 * @this |
77 */ | 82 */ |
78 initialize: function (dialogDom, opt) { | 83 initialize: function(dialogDom, opt) { |
79 if (!dialogDom) { | 84 if (!dialogDom) { |
80 console.log('ERROR: dialogDom is not defined.'); | 85 console.log('ERROR: dialogDom is not defined.'); |
81 return; | 86 return; |
82 } | 87 } |
83 | 88 |
84 measureTime.startInterval('Load.DOM'); | 89 measureTime.startInterval('Load.DOM'); |
85 | 90 |
86 this.opt_ = opt; | 91 this.opt_ = opt; |
87 | 92 |
88 this.initialized_ = true; | 93 this.initialized_ = true; |
89 | 94 |
90 this.elementsCache_ = {}; | 95 this.elementsCache_ = {}; |
91 this.dialogDom_ = dialogDom; | 96 this.dialogDom_ = dialogDom; |
92 this.document_ = dialogDom.ownerDocument; | 97 this.document_ = dialogDom.ownerDocument; |
93 | 98 |
94 this.localized_column_ = []; | 99 this.localized_column_ = []; |
95 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 100 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
96 var column_label_id = DEFAULT_COLUMNS[i][1]; | 101 var column_label_id = DEFAULT_COLUMNS[i][1]; |
97 var localized_label = localStrings.getString(column_label_id); | 102 var localized_label = localStrings.getString(column_label_id); |
98 // Falls back to raw column_label_id if localized string is not defined. | 103 // Falls back to raw column_label_id if localized string is not defined. |
99 if (localized_label == "") | 104 if (localized_label == '') |
100 localized_label = column_label_id; | 105 localized_label = column_label_id; |
101 | 106 |
102 this.localized_column_[i] = localized_label; | 107 this.localized_column_[i] = localized_label; |
103 } | 108 } |
104 | 109 |
105 this.initElements_(); | 110 this.initElements_(); |
106 this.initColumnModel_(); | 111 this.initColumnModel_(); |
107 this.selectionModel_ = new cr.ui.ListSelectionModel(); | 112 this.selectionModel_ = new cr.ui.ListSelectionModel(); |
108 this.dataModel_ = new cr.ui.ArrayDataModel([]); | 113 this.dataModel_ = new cr.ui.ArrayDataModel([]); |
109 | 114 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 measureTime.recordInterval('Load.DOM'); | 153 measureTime.recordInterval('Load.DOM'); |
149 measureTime.recordInterval('Load.Total'); | 154 measureTime.recordInterval('Load.Total'); |
150 | 155 |
151 loadDelayedIncludes(this); | 156 loadDelayedIncludes(this); |
152 }, | 157 }, |
153 | 158 |
154 /** | 159 /** |
155 * Initializes the visibilities and handlers of the elements. | 160 * Initializes the visibilities and handlers of the elements. |
156 * This method is called by initialize(). | 161 * This method is called by initialize(). |
157 * @private | 162 * @private |
| 163 * @this |
158 */ | 164 */ |
159 initElements_: function() { | 165 initElements_: function() { |
160 // <if expr="pp_ifdef('chromeos')"> | 166 // <if expr="pp_ifdef('chromeos')"> |
161 // The 'close-window' element exists only on ChromeOS. | 167 // The 'close-window' element exists only on ChromeOS. |
162 // This <if ... /if> section is removed while flattening HTML if chrome is | 168 // This <if ... /if> section is removed while flattening HTML if chrome is |
163 // built as Desktop Chrome. | 169 // built as Desktop Chrome. |
164 if (!this.opt_['isShowCloseButton']) | 170 if (!this.opt_['isShowCloseButton']) |
165 $('close-window').style.display = 'none'; | 171 $('close-window').style.display = 'none'; |
166 $('close-window').addEventListener('click', this.close.bind(this)); | 172 $('close-window').addEventListener('click', this.close.bind(this)); |
167 // </if> | 173 // </if> |
168 | 174 |
169 $('kill-process').addEventListener('click', | 175 $('kill-process').addEventListener('click', |
170 this.killSelectedProcesses.bind(this)); | 176 this.killSelectedProcesses.bind(this)); |
171 $('about-memory-link').addEventListener('click', commands.openAboutMemory); | 177 $('about-memory-link').addEventListener('click', commands.openAboutMemory); |
172 }, | 178 }, |
173 | 179 |
174 /** | 180 /** |
175 * Additional initialization of taskmanager. This function is called when | 181 * Additional initialization of taskmanager. This function is called when |
176 * the loading of delayed scripts finished. | 182 * the loading of delayed scripts finished. |
| 183 * @this |
177 */ | 184 */ |
178 delayedInitialize: function() { | 185 delayedInitialize: function() { |
179 this.initColumnMenu_(); | 186 this.initColumnMenu_(); |
180 this.initTableMenu_(); | 187 this.initTableMenu_(); |
181 | 188 |
182 var dm = this.dataModel_; | 189 var dm = this.dataModel_; |
183 for (var i = 0; i < dm.length; i++) { | 190 for (var i = 0; i < dm.length; i++) { |
184 var processId = dm.item(i)['processId'][0]; | 191 var processId = dm.item(i)['processId'][0]; |
185 for (var j = 0; j < DEFAULT_COLUMNS.length; j++) { | 192 for (var j = 0; j < DEFAULT_COLUMNS.length; j++) { |
186 var columnId = DEFAULT_COLUMNS[j][0]; | 193 var columnId = DEFAULT_COLUMNS[j][0]; |
(...skipping 12 matching lines...) Expand all Loading... |
199 cr.ui.contextMenuHandler.setContextMenu(label, | 206 cr.ui.contextMenuHandler.setContextMenu(label, |
200 this.tableContextMenu_); | 207 this.tableContextMenu_); |
201 } | 208 } |
202 } | 209 } |
203 } | 210 } |
204 | 211 |
205 this.isFinishedInitDelayed_ = true; | 212 this.isFinishedInitDelayed_ = true; |
206 this.table_.redraw(); | 213 this.table_.redraw(); |
207 }, | 214 }, |
208 | 215 |
209 initColumnModel_: function () { | 216 initColumnModel_: function() { |
210 var table_columns = new Array(); | 217 var table_columns = new Array(); |
211 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 218 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
212 var column = DEFAULT_COLUMNS[i]; | 219 var column = DEFAULT_COLUMNS[i]; |
213 var columnId = column[0]; | 220 var columnId = column[0]; |
214 if (!isColumnEnabled(columnId)) | 221 if (!isColumnEnabled(columnId)) |
215 continue; | 222 continue; |
216 | 223 |
217 table_columns.push(new cr.ui.table.TableColumn(columnId, | 224 table_columns.push(new cr.ui.table.TableColumn(columnId, |
218 this.localized_column_[i], | 225 this.localized_column_[i], |
219 column[2])); | 226 column[2])); |
220 } | 227 } |
221 | 228 |
222 for (var i = 0; i < table_columns.length; i++) { | 229 for (var i = 0; i < table_columns.length; i++) { |
223 table_columns[i].renderFunction = this.renderColumn_.bind(this); | 230 table_columns[i].renderFunction = this.renderColumn_.bind(this); |
224 } | 231 } |
225 | 232 |
226 this.columnModel_ = new cr.ui.table.TableColumnModel(table_columns); | 233 this.columnModel_ = new cr.ui.table.TableColumnModel(table_columns); |
227 }, | 234 }, |
228 | 235 |
229 initColumnMenu_: function () { | 236 initColumnMenu_: function() { |
230 this.column_menu_commands_ = []; | 237 this.column_menu_commands_ = []; |
231 | 238 |
232 this.commandsElement_ = this.document_.createElement('commands'); | 239 this.commandsElement_ = this.document_.createElement('commands'); |
233 this.document_.body.appendChild(this.commandsElement_); | 240 this.document_.body.appendChild(this.commandsElement_); |
234 | 241 |
235 this.columnSelectContextMenu_ = this.document_.createElement('menu'); | 242 this.columnSelectContextMenu_ = this.document_.createElement('menu'); |
236 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { | 243 for (var i = 0; i < DEFAULT_COLUMNS.length; i++) { |
237 var column = DEFAULT_COLUMNS[i]; | 244 var column = DEFAULT_COLUMNS[i]; |
238 | 245 |
239 // Creates command element to receive event. | 246 // Creates command element to receive event. |
240 var command = this.document_.createElement('command'); | 247 var command = this.document_.createElement('command'); |
241 command.id = COMMAND_CONTEXTMENU_COLUMN_PREFIX + '-' + column[0]; | 248 command.id = COMMAND_CONTEXTMENU_COLUMN_PREFIX + '-' + column[0]; |
242 cr.ui.Command.decorate(command); | 249 cr.ui.Command.decorate(command); |
243 this.column_menu_commands_[command.id] = command; | 250 this.column_menu_commands_[command.id] = command; |
244 this.commandsElement_.appendChild(command); | 251 this.commandsElement_.appendChild(command); |
245 | 252 |
246 // Creates menuitem element. | 253 // Creates menuitem element. |
247 var item = this.document_.createElement('menuitem'); | 254 var item = this.document_.createElement('menuitem'); |
248 item.command = command; | 255 item.command = command; |
249 command.menuitem = item; | 256 command.menuitem = item; |
250 item.textContent = this.localized_column_[i]; | 257 item.textContent = this.localized_column_[i]; |
251 if (isColumnEnabled(column[0])) | 258 if (isColumnEnabled(column[0])) |
252 item.setAttributeNode(this.document_.createAttribute("checked")); | 259 item.setAttributeNode(this.document_.createAttribute('checked')); |
253 this.columnSelectContextMenu_.appendChild(item); | 260 this.columnSelectContextMenu_.appendChild(item); |
254 } | 261 } |
255 | 262 |
256 this.document_.body.appendChild(this.columnSelectContextMenu_); | 263 this.document_.body.appendChild(this.columnSelectContextMenu_); |
257 cr.ui.Menu.decorate(this.columnSelectContextMenu_); | 264 cr.ui.Menu.decorate(this.columnSelectContextMenu_); |
258 | 265 |
259 cr.ui.contextMenuHandler.setContextMenu(this.table_.header, | 266 cr.ui.contextMenuHandler.setContextMenu(this.table_.header, |
260 this.columnSelectContextMenu_); | 267 this.columnSelectContextMenu_); |
261 cr.ui.contextMenuHandler.setContextMenu(this.table_.list, | 268 cr.ui.contextMenuHandler.setContextMenu(this.table_.list, |
262 this.columnSelectContextMenu_); | 269 this.columnSelectContextMenu_); |
263 | 270 |
264 this.document_.addEventListener('command', this.onCommand_.bind(this)); | 271 this.document_.addEventListener('command', this.onCommand_.bind(this)); |
265 this.document_.addEventListener('canExecute', | 272 this.document_.addEventListener('canExecute', |
266 this.onCommandCanExecute_.bind(this)); | 273 this.onCommandCanExecute_.bind(this)); |
267 }, | 274 }, |
268 | 275 |
269 initTableMenu_: function () { | 276 initTableMenu_: function() { |
270 this.table_menu_commands_ = []; | 277 this.table_menu_commands_ = []; |
271 this.tableContextMenu_ = this.document_.createElement('menu'); | 278 this.tableContextMenu_ = this.document_.createElement('menu'); |
272 | 279 |
273 var addMenuItem = function (tm, command_id, string_id, default_label) { | 280 var addMenuItem = function(tm, command_id, string_id, default_label) { |
274 // Creates command element to receive event. | 281 // Creates command element to receive event. |
275 var command = tm.document_.createElement('command'); | 282 var command = tm.document_.createElement('command'); |
276 command.id = COMMAND_CONTEXTMENU_TABLE_PREFIX + '-' + command_id; | 283 command.id = COMMAND_CONTEXTMENU_TABLE_PREFIX + '-' + command_id; |
277 cr.ui.Command.decorate(command); | 284 cr.ui.Command.decorate(command); |
278 tm.table_menu_commands_[command.id] = command; | 285 tm.table_menu_commands_[command.id] = command; |
279 tm.commandsElement_.appendChild(command); | 286 tm.commandsElement_.appendChild(command); |
280 | 287 |
281 // Creates menuitem element. | 288 // Creates menuitem element. |
282 var item = tm.document_.createElement('menuitem'); | 289 var item = tm.document_.createElement('menuitem'); |
283 item.command = command; | 290 item.command = command; |
284 command.menuitem = item; | 291 command.menuitem = item; |
285 var localized_label = localStrings.getString(string_id); | 292 var localized_label = localStrings.getString(string_id); |
286 item.textContent = localized_label || default_label; | 293 item.textContent = localized_label || default_label; |
287 tm.tableContextMenu_.appendChild(item); | 294 tm.tableContextMenu_.appendChild(item); |
288 }; | 295 }; |
289 | 296 |
290 addMenuItem(this, 'inspect', 'inspect', "Inspect"); | 297 addMenuItem(this, 'inspect', 'inspect', 'Inspect'); |
291 addMenuItem(this, 'activate', 'activate', "Activate"); | 298 addMenuItem(this, 'activate', 'activate', 'Activate'); |
292 | 299 |
293 this.document_.body.appendChild(this.tableContextMenu_); | 300 this.document_.body.appendChild(this.tableContextMenu_); |
294 cr.ui.Menu.decorate(this.tableContextMenu_); | 301 cr.ui.Menu.decorate(this.tableContextMenu_); |
295 }, | 302 }, |
296 | 303 |
297 initTable_: function () { | 304 initTable_: function() { |
298 if (!this.dataModel_ || !this.selectionModel_ || !this.columnModel_) { | 305 if (!this.dataModel_ || !this.selectionModel_ || !this.columnModel_) { |
299 console.log('ERROR: some models are not defined.'); | 306 console.log('ERROR: some models are not defined.'); |
300 return; | 307 return; |
301 } | 308 } |
302 | 309 |
303 this.table_ = this.dialogDom_.querySelector('.detail-table'); | 310 this.table_ = this.dialogDom_.querySelector('.detail-table'); |
304 cr.ui.Table.decorate(this.table_); | 311 cr.ui.Table.decorate(this.table_); |
305 | 312 |
306 this.table_.dataModel = this.dataModel_; | 313 this.table_.dataModel = this.dataModel_; |
307 this.table_.selectionModel = this.selectionModel_; | 314 this.table_.selectionModel = this.selectionModel_; |
308 this.table_.columnModel = this.columnModel_; | 315 this.table_.columnModel = this.columnModel_; |
309 | 316 |
310 // Expands height of row when a process has some tasks. | 317 // Expands height of row when a process has some tasks. |
311 this.table_.fixedHeight = false; | 318 this.table_.fixedHeight = false; |
312 | 319 |
313 this.table_.list.addEventListener('contextmenu', | 320 this.table_.list.addEventListener('contextmenu', |
314 this.onTableContextMenuOpened_.bind(this), | 321 this.onTableContextMenuOpened_.bind(this), |
315 true); | 322 true); |
316 | 323 |
317 // Sets custom row render function. | 324 // Sets custom row render function. |
318 this.table_.setRenderFunction(this.getRow_.bind(this)); | 325 this.table_.setRenderFunction(this.getRow_.bind(this)); |
319 }, | 326 }, |
320 | 327 |
321 /** | 328 /** |
322 * Returns a list item element of the list. This method trys to reuse the | 329 * Returns a list item element of the list. This method trys to reuse the |
323 * cached element, or creates a new element. | 330 * cached element, or creates a new element. |
| 331 * @return {cr.ui.ListItem} list item element which contains the given data. |
324 * @private | 332 * @private |
| 333 * @this |
325 */ | 334 */ |
326 getRow_: function(data, table) { | 335 getRow_: function(data, table) { |
327 // Trys to reuse the cached row; | 336 // Trys to reuse the cached row; |
328 var listItemElement = this.renderRowFromCache_(data, table); | 337 var listItemElement = this.renderRowFromCache_(data, table); |
329 if (listItemElement) | 338 if (listItemElement) |
330 return listItemElement; | 339 return listItemElement; |
331 | 340 |
332 // Initializes the cache. | 341 // Initializes the cache. |
333 var pid = data['processId'][0]; | 342 var pid = data['processId'][0]; |
334 this.elementsCache_[pid] = { | 343 this.elementsCache_[pid] = { |
335 listItem:null, | 344 listItem: null, |
336 cell:[], | 345 cell: [], |
337 icon:[], | 346 icon: [], |
338 columns:{} | 347 columns: {} |
339 }; | 348 }; |
340 | 349 |
341 // Create new row. | 350 // Create new row. |
342 return this.renderRow_(data, table); | 351 return this.renderRow_(data, table); |
343 }, | 352 }, |
344 | 353 |
345 /** | 354 /** |
346 * Returns a list item element with re-using the previous cached element, or | 355 * Returns a list item element with re-using the previous cached element, or |
347 * returns null if failed. | 356 * returns null if failed. |
| 357 * @return {cr.ui.ListItem} cached un-used element to be reused. |
348 * @private | 358 * @private |
| 359 * @this |
349 */ | 360 */ |
350 renderRowFromCache_: function(data, table) { | 361 renderRowFromCache_: function(data, table) { |
351 var pid = data['processId'][0]; | 362 var pid = data['processId'][0]; |
352 | 363 |
353 // Checks whether the cache exists or not. | 364 // Checks whether the cache exists or not. |
354 var cache = this.elementsCache_[pid]; | 365 var cache = this.elementsCache_[pid]; |
355 if (!cache) | 366 if (!cache) |
356 return null; | 367 return null; |
357 | 368 |
358 var listItemElement = cache.listItem; | 369 var listItemElement = cache.listItem; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 listItemElement.data = data; | 414 listItemElement.data = data; |
404 | 415 |
405 // Removes 'selected' and 'lead' attributes. | 416 // Removes 'selected' and 'lead' attributes. |
406 listItemElement.removeAttribute('selected'); | 417 listItemElement.removeAttribute('selected'); |
407 listItemElement.removeAttribute('lead'); | 418 listItemElement.removeAttribute('lead'); |
408 | 419 |
409 return listItemElement; | 420 return listItemElement; |
410 }, | 421 }, |
411 | 422 |
412 /** | 423 /** |
413 * Create a new list item element and returns it. | 424 * Create a new list item element. |
| 425 * @return {cr.ui.ListItem} created new list item element. |
414 * @private | 426 * @private |
| 427 * @this |
415 */ | 428 */ |
416 renderRow_: function(data, table) { | 429 renderRow_: function(data, table) { |
417 var pid = data['processId'][0]; | 430 var pid = data['processId'][0]; |
418 var cm = table.columnModel; | 431 var cm = table.columnModel; |
419 var listItem = new cr.ui.ListItem({label: ''}); | 432 var listItem = new cr.ui.ListItem({label: ''}); |
420 | 433 |
421 listItem.className = 'table-row'; | 434 listItem.className = 'table-row'; |
422 if (this.opt_.isBackgroundMode && data.isBackgroundResource) | 435 if (this.opt_.isBackgroundMode && data.isBackgroundResource) |
423 listItem.className += ' table-background-row'; | 436 listItem.className += ' table-background-row'; |
424 | 437 |
(...skipping 21 matching lines...) Expand all Loading... |
446 // childlen. | 459 // childlen. |
447 this.elementsCache_[pid].listItem = listItem; | 460 this.elementsCache_[pid].listItem = listItem; |
448 this.elementsCache_[pid].cachedColumnSize = cm.size; | 461 this.elementsCache_[pid].cachedColumnSize = cm.size; |
449 this.elementsCache_[pid].cachedChildSize = data['uniqueId'].length; | 462 this.elementsCache_[pid].cachedChildSize = data['uniqueId'].length; |
450 | 463 |
451 return listItem; | 464 return listItem; |
452 }, | 465 }, |
453 | 466 |
454 /** | 467 /** |
455 * Create a new element of the cell. | 468 * Create a new element of the cell. |
| 469 * @return {HTMLDIVElement} created cell |
456 * @private | 470 * @private |
| 471 * @this |
457 */ | 472 */ |
458 renderColumn_: function(entry, columnId, table) { | 473 renderColumn_: function(entry, columnId, table) { |
459 var container = this.document_.createElement('div'); | 474 var container = this.document_.createElement('div'); |
460 container.className = 'detail-container-' + columnId; | 475 container.className = 'detail-container-' + columnId; |
461 var pid = entry['processId'][0]; | 476 var pid = entry['processId'][0]; |
462 | 477 |
463 var cache = []; | 478 var cache = []; |
464 var cacheIcon = []; | 479 var cacheIcon = []; |
465 | 480 |
466 if (entry && entry[columnId]) { | 481 if (entry && entry[columnId]) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 this.elementsCache_[pid].columns[columnId] = cache; | 526 this.elementsCache_[pid].columns[columnId] = cache; |
512 if (columnId == 'title') | 527 if (columnId == 'title') |
513 this.elementsCache_[pid].icon = cacheIcon; | 528 this.elementsCache_[pid].icon = cacheIcon; |
514 } | 529 } |
515 return container; | 530 return container; |
516 }, | 531 }, |
517 | 532 |
518 /** | 533 /** |
519 * Updates the task list with the supplied task. | 534 * Updates the task list with the supplied task. |
520 * @private | 535 * @private |
| 536 * @this |
521 */ | 537 */ |
522 processTaskChange: function(task) { | 538 processTaskChange: function(task) { |
523 var dm = this.dataModel_; | 539 var dm = this.dataModel_; |
524 var sm = this.selectionModel_; | 540 var sm = this.selectionModel_; |
525 if (!dm || !sm) return; | 541 if (!dm || !sm) return; |
526 | 542 |
527 this.table_.list.startBatchUpdates(); | 543 this.table_.list.startBatchUpdates(); |
528 sm.beginChange(); | 544 sm.beginChange(); |
529 | 545 |
530 var type = task.type; | 546 var type = task.type; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 if (pids.indexOf(pid) == -1) | 583 if (pids.indexOf(pid) == -1) |
568 delete this.elementsCache_[pid]; | 584 delete this.elementsCache_[pid]; |
569 } | 585 } |
570 | 586 |
571 sm.endChange(); | 587 sm.endChange(); |
572 this.table_.list.endBatchUpdates(); | 588 this.table_.list.endBatchUpdates(); |
573 }, | 589 }, |
574 | 590 |
575 /** | 591 /** |
576 * Respond to a command being executed. | 592 * Respond to a command being executed. |
| 593 * @this |
577 */ | 594 */ |
578 onCommand_: function(event) { | 595 onCommand_: function(event) { |
579 var command = event.command; | 596 var command = event.command; |
580 var command_id = command.id.split('-', 2); | 597 var command_id = command.id.split('-', 2); |
581 | 598 |
582 var main_command = command_id[0]; | 599 var main_command = command_id[0]; |
583 var sub_command = command_id[1]; | 600 var sub_command = command_id[1]; |
584 | 601 |
585 if (main_command == COMMAND_CONTEXTMENU_COLUMN_PREFIX) { | 602 if (main_command == COMMAND_CONTEXTMENU_COLUMN_PREFIX) { |
586 this.onColumnContextMenu_(sub_command, command); | 603 this.onColumnContextMenu_(sub_command, command); |
(...skipping 12 matching lines...) Expand all Loading... |
599 } | 616 } |
600 }, | 617 }, |
601 | 618 |
602 onCommandCanExecute_: function(event) { | 619 onCommandCanExecute_: function(event) { |
603 event.canExecute = true; | 620 event.canExecute = true; |
604 }, | 621 }, |
605 | 622 |
606 /** | 623 /** |
607 * Store resourceIndex of target resource of context menu, because resource | 624 * Store resourceIndex of target resource of context menu, because resource |
608 * will be replaced when it is refreshed. | 625 * will be replaced when it is refreshed. |
| 626 * @this |
609 */ | 627 */ |
610 onTableContextMenuOpened_: function (e) { | 628 onTableContextMenuOpened_: function(e) { |
611 if (!this.isFinishedInitDelayed_) | 629 if (!this.isFinishedInitDelayed_) |
612 return; | 630 return; |
613 | 631 |
614 var mc = this.table_menu_commands_; | 632 var mc = this.table_menu_commands_; |
615 var inspect_menuitem = | 633 var inspect_menuitem = |
616 mc[COMMAND_CONTEXTMENU_TABLE_PREFIX + '-inspect'].menuitem; | 634 mc[COMMAND_CONTEXTMENU_TABLE_PREFIX + '-inspect'].menuitem; |
617 var activate_menuitem = | 635 var activate_menuitem = |
618 mc[COMMAND_CONTEXTMENU_TABLE_PREFIX + '-activate'].menuitem; | 636 mc[COMMAND_CONTEXTMENU_TABLE_PREFIX + '-activate'].menuitem; |
619 | 637 |
620 // Disabled by default. | 638 // Disabled by default. |
621 inspect_menuitem.disabled = true; | 639 inspect_menuitem.disabled = true; |
622 activate_menuitem.disabled = true; | 640 activate_menuitem.disabled = true; |
623 | 641 |
624 var target = e.target; | 642 var target = e.target; |
625 for (; ; target = target.parentNode) { | 643 for (;; target = target.parentNode) { |
626 if (!target) return; | 644 if (!target) return; |
627 var classes = target.classList; | 645 var classes = target.classList; |
628 if (classes && | 646 if (classes && |
629 Array.prototype.indexOf.call(classes, 'detail-title') != -1) break; | 647 Array.prototype.indexOf.call(classes, 'detail-title') != -1) break; |
630 } | 648 } |
631 | 649 |
632 var index_in_group = target.index_in_group; | 650 var index_in_group = target.index_in_group; |
633 | 651 |
634 // Sets the uniqueId for current target page under the mouse corsor. | 652 // Sets the uniqueId for current target page under the mouse corsor. |
635 this.currentContextMenuTarget_ = target.data['uniqueId'][index_in_group]; | 653 this.currentContextMenuTarget_ = target.data['uniqueId'][index_in_group]; |
(...skipping 20 matching lines...) Expand all Loading... |
656 checkedItemCount++; | 674 checkedItemCount++; |
657 } | 675 } |
658 if (checkedItemCount == 1 && checked) | 676 if (checkedItemCount == 1 && checked) |
659 return; | 677 return; |
660 | 678 |
661 // Toggles the visibility of the column. | 679 // Toggles the visibility of the column. |
662 var newChecked = !checked; | 680 var newChecked = !checked; |
663 menuitem.checked = newChecked; | 681 menuitem.checked = newChecked; |
664 setColumnEnabled(columnId, newChecked); | 682 setColumnEnabled(columnId, newChecked); |
665 | 683 |
666 this.initColumnModel_() | 684 this.initColumnModel_(); |
667 this.table_.columnModel = this.columnModel_; | 685 this.table_.columnModel = this.columnModel_; |
668 this.table_.redraw(); | 686 this.table_.redraw(); |
669 }, | 687 }, |
670 }; | 688 }; |
671 | 689 |
672 // |taskmanager| has been declared in preload.js. | 690 // |taskmanager| has been declared in preload.js. |
673 taskmanager = TaskManager.getInstance(); | 691 taskmanager = TaskManager.getInstance(); |
674 | 692 |
675 function init() { | 693 function init() { |
676 var params = parseQueryParams(window.location); | 694 var params = parseQueryParams(window.location); |
677 var opt = {}; | 695 var opt = {}; |
678 opt['isBackgroundMode'] = params.background; | 696 opt['isBackgroundMode'] = params.background; |
679 opt['isShowCloseButton'] = params.showclose; | 697 opt['isShowCloseButton'] = params.showclose; |
680 taskmanager.initialize(document.body, opt); | 698 taskmanager.initialize(document.body, opt); |
681 } | 699 } |
682 | 700 |
683 document.addEventListener('DOMContentLoaded', init); | 701 document.addEventListener('DOMContentLoaded', init); |
684 document.addEventListener('Close', taskmanager.onClose.bind(taskmanager)); | 702 document.addEventListener('Close', taskmanager.onClose.bind(taskmanager)); |
OLD | NEW |