Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: chrome/browser/resources/task_manager/main.js

Issue 7606029: WebUI TaskManager: Supports background-page mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 /** 87 /**
88 * Initializes taskmanager. 88 * Initializes taskmanager.
89 * @public 89 * @public
90 */ 90 */
91 initialize: function (dialogDom) { 91 initialize: function (dialogDom) {
92 if (!dialogDom) { 92 if (!dialogDom) {
93 console.log('ERROR: dialogDom is not defined.'); 93 console.log('ERROR: dialogDom is not defined.');
94 return; 94 return;
95 } 95 }
96 96
97 this.background_mode = (location.hash == '#bg');
xiyuan 2011/08/11 17:14:13 nit: background_mode -> backgroundMode
xiyuan 2011/08/11 17:14:13 Could we pass backgroundMode from outside instead
98
97 this.initialized_ = true; 99 this.initialized_ = true;
98 this.enableTaskManager(); 100 this.enableTaskManager();
99 101
100 this.dialogDom_ = dialogDom; 102 this.dialogDom_ = dialogDom;
101 this.document_ = dialogDom.ownerDocument; 103 this.document_ = dialogDom.ownerDocument;
102 104
103 $('close-window').addEventListener('click', this.close.bind(this)); 105 $('close-window').addEventListener('click', this.close.bind(this));
104 $('kill-process').addEventListener('click', this.killProcess.bind(this)); 106 $('kill-process').addEventListener('click', this.killProcess.bind(this));
105 $('about-memory-link').addEventListener('click', 107 $('about-memory-link').addEventListener('click',
106 this.openAboutMemory.bind(this)); 108 this.openAboutMemory.bind(this));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 if (!this.is_column_shown_[i]) 159 if (!this.is_column_shown_[i])
158 continue; 160 continue;
159 161
160 var column = DEFAULT_COLUMNS[i]; 162 var column = DEFAULT_COLUMNS[i];
161 table_columns.push(new cr.ui.table.TableColumn(column[0], 163 table_columns.push(new cr.ui.table.TableColumn(column[0],
162 this.localized_column_[i], 164 this.localized_column_[i],
163 column[2])); 165 column[2]));
164 } 166 }
165 167
166 for (var i = 0; i < table_columns.length; i++) { 168 for (var i = 0; i < table_columns.length; i++) {
167 table_columns[i].renderFunction = this.renderText_.bind(this); 169 table_columns[i].renderFunction = this.renderColumn_.bind(this);
168 } 170 }
169 171
170 this.columnModel_ = new cr.ui.table.TableColumnModel(table_columns); 172 this.columnModel_ = new cr.ui.table.TableColumnModel(table_columns);
171 }, 173 },
172 174
173 initColumnMenu_: function () { 175 initColumnMenu_: function () {
174 this.column_menu_commands_ = []; 176 this.column_menu_commands_ = [];
175 177
176 this.commandsElement_ = this.document_.createElement('commands'); 178 this.commandsElement_ = this.document_.createElement('commands');
177 this.document_.body.appendChild(this.commandsElement_); 179 this.document_.body.appendChild(this.commandsElement_);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 219
218 this.table_ = this.dialogDom_.querySelector('.detail-table'); 220 this.table_ = this.dialogDom_.querySelector('.detail-table');
219 cr.ui.Table.decorate(this.table_); 221 cr.ui.Table.decorate(this.table_);
220 222
221 this.table_.dataModel = this.dataModel_; 223 this.table_.dataModel = this.dataModel_;
222 this.table_.selectionModel = this.selectionModel_; 224 this.table_.selectionModel = this.selectionModel_;
223 this.table_.columnModel = this.columnModel_; 225 this.table_.columnModel = this.columnModel_;
224 226
225 // Expands height of row when a process has some tasks. 227 // Expands height of row when a process has some tasks.
226 this.table_.autoExpands = true; 228 this.table_.autoExpands = true;
229
230 // Sets custom row render function.
231 this.table_.setRenderFunction(this.renderRow_.bind(this));
227 }, 232 },
228 233
229 renderText_: function(entry, columnId, table) { 234 renderRow_: function(dataItem, table) {
235 var cm = this.table_.columnModel;
xiyuan 2011/08/11 17:14:13 Should we use table instread of this.table_?
236 var listItem = new cr.ui.ListItem({label: ''});
237
238 listItem.className = 'table-row';
239 if (this.background_mode && dataItem.isBackgroundResource)
240 listItem.className += ' table-background-row';
241
242 for (var i = 0; i < cm.size; i++) {
243 var cell = document.createElement('div');
244 cell.style.width = cm.getWidth(i) + '%';
245 cell.className = 'table-row-cell';
246 cell.appendChild(
247 cm.getRenderFunction(i).call(null, dataItem, cm.getId(i), table));
248
249 listItem.appendChild(cell);
250 }
251
252 return listItem;
253 },
254
255 renderColumn_: function(entry, columnId, table) {
230 var container = this.document_.createElement('div'); 256 var container = this.document_.createElement('div');
231 container.id = 'detail-container-' + columnId + '-pid' + entry.processId; 257 container.id = 'detail-container-' + columnId + '-pid' + entry.processId;
232 container.className = 'detail-container-' + columnId; 258 container.className = 'detail-container-' + columnId;
233 259
234 if (entry[columnId]) { 260 if (entry[columnId]) {
235 for (var i = 0; i < entry[columnId].length; i++) { 261 for (var i = 0; i < entry[columnId].length; i++) {
236 var label = document.createElement('div'); 262 var label = document.createElement('div');
237 if (columnId == 'title') { 263 if (columnId == 'title') {
238 var image = this.document_.createElement('img'); 264 var image = this.document_.createElement('img');
239 image.className = 'detail-title-image'; 265 image.className = 'detail-title-image';
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 taskmanager.onTaskChange(start, length, tasks); 392 taskmanager.onTaskChange(start, length, tasks);
367 } 393 }
368 394
369 function taskRemoved(start, length) { 395 function taskRemoved(start, length) {
370 // Sometimes this can get called too early. 396 // Sometimes this can get called too early.
371 if (!taskmanager) 397 if (!taskmanager)
372 return; 398 return;
373 taskmanager.onTaskRemove(start, length); 399 taskmanager.onTaskRemove(start, length);
374 } 400 }
375 401
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698