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

Unified Diff: chrome/browser/resources/task_manager/main.js

Issue 8993007: WebUI TaskManager: Delay scripts loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/task_manager/main.js
diff --git a/chrome/browser/resources/task_manager/main.js b/chrome/browser/resources/task_manager/main.js
index 5c04529407d4988b041b23e1ded772ffee393f7a..5e78c04c76d3e7f0f552fe6935bcc79f5f20627e 100644
--- a/chrome/browser/resources/task_manager/main.js
+++ b/chrome/browser/resources/task_manager/main.js
@@ -37,7 +37,6 @@ var localStrings = new LocalStrings();
TaskManager.prototype = {
/**
* Handle window close.
- * @public
*/
onClose: function () {
if (!this.disabled_) {
@@ -50,7 +49,6 @@ TaskManager.prototype = {
* Handle selection change.
* This is also called when data of tasks are refleshed, even if selection
* has not been changed.
- * @public
*/
onSelectionChange: function () {
var sm = this.selectionModel_;
@@ -78,7 +76,6 @@ TaskManager.prototype = {
/**
* Closes taskmanager dialog.
* After this function is called, onClose() will be called.
- * @public
*/
close: function () {
window.close();
@@ -86,7 +83,6 @@ TaskManager.prototype = {
/**
* Sends commands to kill selected processes.
- * @public
*/
killSelectedProcesses: function () {
var selectedIndexes = this.selectionModel_.selectedIndexes;
@@ -103,7 +99,6 @@ TaskManager.prototype = {
/**
* Sends command to initiate resource inspection.
- * @public
*/
inspect: function (uniqueId) {
chrome.send('inspect', [uniqueId]);
@@ -111,7 +106,6 @@ TaskManager.prototype = {
/**
* Sends command to kill a process.
- * @public
*/
openAboutMemory: function () {
chrome.send('openAboutMemory');
@@ -119,7 +113,6 @@ TaskManager.prototype = {
/**
* Sends command to disable taskmanager model.
- * @public
*/
disableTaskManager: function () {
chrome.send('disableTaskManager');
@@ -127,7 +120,6 @@ TaskManager.prototype = {
/**
* Sends command to enable taskmanager model.
- * @public
*/
enableTaskManager: function () {
chrome.send('enableTaskManager');
@@ -135,7 +127,6 @@ TaskManager.prototype = {
/**
* Sends command to activate a page.
- * @public
*/
activatePage: function (uniqueId) {
chrome.send('activatePage', [uniqueId]);
@@ -143,7 +134,6 @@ TaskManager.prototype = {
/**
* Initializes taskmanager.
- * @public
*/
initialize: function (dialogDom, opt) {
if (!dialogDom) {
@@ -151,6 +141,8 @@ TaskManager.prototype = {
return;
}
+ measuretime.startInterval('Load.DOM');
+
this.opt_ = opt;
this.initialized_ = true;
@@ -159,12 +151,6 @@ TaskManager.prototype = {
this.dialogDom_ = dialogDom;
this.document_ = dialogDom.ownerDocument;
- $('close-window').addEventListener('click', this.close.bind(this));
- $('kill-process').addEventListener('click',
- this.killSelectedProcesses.bind(this));
- $('about-memory-link').addEventListener('click',
- this.openAboutMemory.bind(this));
-
this.is_column_shown_ = [];
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
this.is_column_shown_[i] = DEFAULT_COLUMNS[i][3];
@@ -181,6 +167,7 @@ TaskManager.prototype = {
this.localized_column_[i] = localized_label;
}
+ this.initElements_();
this.initColumnModel_();
this.selectionModel_ = new cr.ui.ListSelectionModel();
this.dataModel_ = new cr.ui.ArrayDataModel([]);
@@ -212,16 +199,63 @@ TaskManager.prototype = {
dm.setCompareFunction(column_id, compare_func);
}
- var ary = this.dialogDom_.querySelectorAll('[visibleif]');
- for (var i = 0; i < ary.length; i++) {
- var expr = ary[i].getAttribute('visibleif');
- if (!eval(expr))
- ary[i].hidden = true;
- }
-
this.initTable_();
+
+ // Populate the static localized strings.
+ i18nTemplate.process(this.document_, templateData);
+
+ measuretime.recordInterval('Load.DOM');
+ measuretime.recordInterval('Load.Total');
+
+ loadDelayedIncludes(this);
+ },
+
+ /**
+ * Initializes the visibilities and handlers of the elements.
+ * This method is called by initialize().
+ */
+ initElements_: function() {
+ // <if expr="pp_ifdef('chromeos')">
+ // The elements 'dialog-title' and 'close-window' exist only on ChromeOS.
+ // This <if ... /if> section is removed while flattening HTML if chrome is
+ // built as Desktop Chrome.
+ if (this.opt_['isShowTitle'])
+ $('dialog-title').style.display = 'none';
+ if (this.opt_['isShowCloseButton'])
+ $('close-window').style.display = 'none';
+ $('close-window').addEventListener('click', this.close.bind(this));
+ // </if>
+
+ $('kill-process').addEventListener('click',
+ this.killSelectedProcesses.bind(this));
+ $('about-memory-link').addEventListener('click',
+ this.openAboutMemory.bind(this));
+ },
+
+ /**
+ * Additional initialization of taskmanager. This function is called when
+ * the loading of delayed scripts finished.
+ */
+ delayedInitialize: function () {
mazda 2011/12/21 05:56:53 No space between 'function' and '('.
yoshiki 2011/12/21 06:08:48 Done.
this.initColumnMenu_();
this.initTableMenu_();
+
+ var dm = this.dataModel_;
+ for (var i = 0; i < dm.length; i++) {
+ for (var j = 0; j < DEFAULT_COLUMNS.length; j++) {
+ var columnId = DEFAULT_COLUMNS[j][0];
+ var row = dm.item(i)[columnId];
+ for (var k = 0; k < row.length; k++) {
+ var processId = dm.item(i)['processId'][0];
+ var labelId = 'detail-' + columnId + '-pid' + processId + '-' + k;
+ var label = $(labelId);
+ if (label && label.setContextMenu)
+ label.setContextMenu(this.tableContextMenu_);
+ }
+ }
+ }
+
+ this.isFinishedInitDelayed_ = true;
this.table_.redraw();
},
@@ -379,8 +413,15 @@ TaskManager.prototype = {
text.textContent = entry['title'][i];
label.appendChild(text);
- cr.ui.contextMenuHandler.addContextMenuProperty(label);
- label.contextMenu = this.tableContextMenu_;
+ label.setContextMenu = function(contextMenuElement) {
+ if (!this.contextMenu) {
+ cr.ui.contextMenuHandler.addContextMenuProperty(this);
+ this.contextMenu = contextMenuElement;
+ }
+ };
+
+ if (this.isFinishedInitDelayed_)
+ label.setContextMenu(this.tableContextMenu_);
label.addEventListener('dblclick', (function(uniqueId) {
this.activatePage(uniqueId);
@@ -477,6 +518,9 @@ TaskManager.prototype = {
* will be replaced when it is refleshed.
*/
onTableContextMenuOpened_: function (e) {
+ if (!this.isFinishedInitDelayed_)
+ return;
+
var mc = this.table_menu_commands_;
var inspect_menuitem =
mc[COMMAND_CONTEXTMENU_TABLE_PREFIX + '-inspect'].menuitem;
@@ -584,4 +628,3 @@ function taskRemoved(start, length) {
return;
taskmanager.onTaskRemove(start, length);
}
-

Powered by Google App Engine
This is Rietveld 408576698