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

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: 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..f72f8657d054692ee38e4cbeaca3a19b4fb04ff2 100644
--- a/chrome/browser/resources/task_manager/main.js
+++ b/chrome/browser/resources/task_manager/main.js
@@ -151,6 +151,8 @@ TaskManager.prototype = {
return;
}
+ metrics.startInterval('Load.DOM');
+
this.opt_ = opt;
this.initialized_ = true;
@@ -159,11 +161,12 @@ 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));
+ var ary = this.dialogDom_.querySelectorAll('[visibleif]');
+ for (var i = 0; i < ary.length; i++) {
+ var expr = ary[i].getAttribute('visibleif');
+ if (!eval(expr))
arv (Not doing code reviews) 2011/12/19 22:57:14 eval should be prevented if possible. What is its
yoshiki 2011/12/20 15:18:25 Done.
+ ary[i].hidden = true;
+ }
this.is_column_shown_ = [];
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
@@ -212,16 +215,37 @@ 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);
+
+ metrics.recordInterval('Load.DOM');
+ metrics.recordInterval('Load.Total');
+
+ loadDelayedIncludes(this);
+ },
+
+ /**
+ * Additional initialization of taskmanager. This function is called when
+ * the loading of delayed scripts finished.
+ * @public
James Hawkins 2011/12/19 18:35:56 In general we don't specify @public since it's imp
yoshiki 2011/12/20 15:18:25 Done.
+ */
+ delayedInitialize: function () {
+ $('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.initColumnMenu_();
this.initTableMenu_();
+
+ if (this.delayedInitLabels_) {
+ while (this.delayedInitLabels_.length > 0)
+ this.delayedInitLabels_.pop().call();
+ }
+
+ this.isFinishedInitDelayed_ = true;
this.table_.redraw();
},
@@ -361,6 +385,8 @@ TaskManager.prototype = {
},
renderColumn_: function(entry, columnId, table) {
+ this.delayedInitLabels_ = [];
+
var container = this.document_.createElement('div');
container.className = 'detail-container-' + columnId;
@@ -379,8 +405,15 @@ TaskManager.prototype = {
text.textContent = entry['title'][i];
label.appendChild(text);
- cr.ui.contextMenuHandler.addContextMenuProperty(label);
- label.contextMenu = this.tableContextMenu_;
+ var addContextMenu = function() {
arv (Not doing code reviews) 2011/12/19 22:57:14 This will not work correctly. label changes as you
yoshiki 2011/12/20 15:18:25 Done.
+ cr.ui.contextMenuHandler.addContextMenuProperty(label);
+ label.contextMenu = this.tableContextMenu_;
+ };
+
+ if (this.isFinishedInitDelayed_)
+ addContextMenu.call(this);
+ else
+ this.delayedInitLabels_.push(addContextMenu.bind(this));
label.addEventListener('dblclick', (function(uniqueId) {
this.activatePage(uniqueId);
@@ -477,6 +510,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;

Powered by Google App Engine
This is Rietveld 408576698