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

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

Issue 8424008: TaskManager: Added "inspect" on context-menu on the task list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/table.js ('k') | chrome/browser/ui/webui/task_manager_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f5f4b516bf39774d5dc320d0ac47b0aac8081fb1..551f469b849ae35892c4146cd0804cc6eb73e24f 100644
--- a/chrome/browser/resources/task_manager/main.js
+++ b/chrome/browser/resources/task_manager/main.js
@@ -197,6 +197,7 @@ TaskManager.prototype = {
this.initTable_();
this.initColumnMenu_();
+ this.initTableMenu_();
this.table_.redraw();
},
@@ -258,6 +259,29 @@ TaskManager.prototype = {
},
+ initTableMenu_: function () {
+ this.table_menu_commands_ = [];
+ this.tableContextMenu_ = this.document_.createElement('menu');
+
+ // Creates command element to receive event.
+ var command = this.document_.createElement('command');
+ command.id = 'tableContextMenu-inspect';
+ cr.ui.Command.decorate(command);
+ this.table_menu_commands_[command.id] = command;
+ this.commandsElement_.appendChild(command);
+
+ // Creates menuitem element.
+ var item = this.document_.createElement('menuitem');
+ item.command = command;
+ command.menuitem = item;
+ var localized_label = localStrings.getString('INSPECT');
+ item.textContent = (localized_label != "") ? localized_label : "Inspect";
+ this.tableContextMenu_.appendChild(item);
+
+ this.document_.body.appendChild(this.tableContextMenu_);
+ cr.ui.Menu.decorate(this.tableContextMenu_);
+ },
+
initTable_: function () {
if (!this.dataModel_ || !this.selectionModel_ || !this.columnModel_) {
console.log('ERROR: some models are not defined.');
@@ -274,6 +298,10 @@ TaskManager.prototype = {
// Expands height of row when a process has some tasks.
this.table_.autoExpands = true;
+ this.table_.list.addEventListener('contextmenu',
+ this.onTableContextMenuOpened_.bind(this),
+ true);
+
// Sets custom row render function.
this.table_.setRenderFunction(this.renderRow_.bind(this));
},
@@ -295,6 +323,7 @@ TaskManager.prototype = {
listItem.appendChild(cell);
}
+ listItem.data = dataItem;
return listItem;
},
@@ -316,6 +345,12 @@ TaskManager.prototype = {
text.className = 'detail-title-text';
text.textContent = entry['title'][i];
label.appendChild(text);
+
+ cr.ui.contextMenuHandler.addContextMenuProperty(label);
+ label.contextMenu = this.tableContextMenu_;
+
+ label.data = entry;
+ label.index_in_group = i;
} else {
label.textContent = entry[columnId][i];
}
@@ -371,6 +406,12 @@ TaskManager.prototype = {
if (command.id.substr(0, 18) == 'columnContextMenu-') {
console.log(command.id.substr(18));
this.onColumnContextMenu_(command.id.substr(18), command);
+ } else if (command.id == 'tableContextMenu-inspect') {
+ var contextMenuTarget = this.currentContextMenuTarget_;
+ if (contextMenuTarget) {
+ this.inspect(contextMenuTarget);
+ this.currentContextMenuTarget_ = undefined;
+ }
}
},
@@ -378,6 +419,38 @@ TaskManager.prototype = {
event.canExecute = true;
},
+ /**
+ * Store resourceIndex of target resource of context menu, because resource
+ * will be replaced when it is refleshed.
+ */
+ onTableContextMenuOpened_: function (e) {
+ var command = this.table_menu_commands_['tableContextMenu-inspect'];
+ var menuItem = command.menuitem;
+
+ // Disabled by default.
+ menuItem.disabled = true;
+ this.currentContextMenuTarget_ = undefined;
+
+ var target = e.target;
+ var classes = target.className.split(" ");
pfeldman1 2011/10/31 08:17:41 var classes = target.classList; (new HTML5 feature
+ while (target && classes.indexOf('detail-title') == -1) {
+ target = target.parentNode;
+ classes = target.className.split(" ");
+ }
+
+ if (!target)
+ return;
+
+ var index_in_group = target.index_in_group;
+
+ var canInspect = target.data['canInspect'][index_in_group];
+ if (canInspect) {
+ menuItem.disabled = false;
+ this.currentContextMenuTarget_ =
+ target.data['uniqueId'][index_in_group];
+ }
+ },
+
onColumnContextMenu_: function(id, command) {
var menuitem = command.menuitem;
var checked_item_count = 0;
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/table.js ('k') | chrome/browser/ui/webui/task_manager_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698