Commit a44d2ea8 authored by thestig@chromium.org's avatar thestig@chromium.org

Delete the WebUI implementation of the task manager.

It is no longer used.

BUG=

Review URL: https://codereview.chromium.org/101013004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243834 0039d316-1c4b-4281-b951-d872f2087c98
parent d86263dc
...@@ -282,18 +282,6 @@ ...@@ -282,18 +282,6 @@
<include name="IDR_WEBRTC_LOGS_JS" file="resources\media\webrtc_logs.js" type="BINDATA" /> <include name="IDR_WEBRTC_LOGS_JS" file="resources\media\webrtc_logs.js" type="BINDATA" />
</if> </if>
<include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" /> <include name="IDR_WEBSTORE_MANIFEST" file="resources\webstore_app\manifest.json" type="BINDATA" />
<if expr="pp_ifdef('use_ash')">
<include name="IDR_TASK_MANAGER_HTML" file="resources\task_manager\main.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_TASK_MANAGER_COMMANDS_JS" file="resources\task_manager\commands.js" type="BINDATA" />
<!-- The following defines.js uses flattenhtml feature to remove the platform-dependent code at compile-time. -->
<include name="IDR_TASK_MANAGER_DEFINES_JS" file="resources\task_manager\defines.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_TASK_MANAGER_INCLUDES_JS" file="resources\task_manager\includes.js" type="BINDATA" />
<include name="IDR_TASK_MANAGER_PRELOAD_JS" file="resources\task_manager\preload.js" type="BINDATA" />
<!-- The following main.js uses flattenhtml feature to remove the platform-dependent code at complie-time. -->
<include name="IDR_TASK_MANAGER_JS" file="resources\task_manager\main.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_TASK_MANAGER_MEASURE_TIME_JS" file="resources\task_manager\measure_time.js" type="BINDATA" />
<include name="IDR_TASK_MANAGER_MEASURE_TIME_END_JS" file="resources\task_manager\measure_time_end.js" type="BINDATA" />
</if>
<include name="IDR_GAIA_AUTH_MANIFEST" file="resources\gaia_auth\manifest.json" type="BINDATA" /> <include name="IDR_GAIA_AUTH_MANIFEST" file="resources\gaia_auth\manifest.json" type="BINDATA" />
<include name="IDR_GAIA_AUTH_KEYBOARD_MANIFEST" file="resources\gaia_auth\manifest_keyboard.json" type="BINDATA" /> <include name="IDR_GAIA_AUTH_KEYBOARD_MANIFEST" file="resources\gaia_auth\manifest_keyboard.json" type="BINDATA" />
<include name="IDR_GAIA_AUTH_SAML_MANIFEST" file="resources\gaia_auth\manifest_saml.json" type="BINDATA" /> <include name="IDR_GAIA_AUTH_SAML_MANIFEST" file="resources\gaia_auth\manifest_saml.json" type="BINDATA" />
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
TaskManagerCommands = {
/**
* Sends commands to kill selected processes.
*/
killSelectedProcesses: function(uniqueIds) {
chrome.send('killProcesses', uniqueIds);
},
/**
* Sends command to initiate resource inspection.
*/
inspect: function(uniqueId) {
chrome.send('inspect', [uniqueId]);
},
/**
* Sends command to open about memory tab.
*/
openAboutMemory: function() {
chrome.send('openAboutMemory');
},
/**
* Sends command to disable taskmanager model.
*/
disableTaskManager: function() {
chrome.send('disableTaskManager');
},
/**
* Sends command to enable taskmanager model.
*/
enableTaskManager: function() {
chrome.send('enableTaskManager');
},
/**
* Sends command to activate a page.
*/
activatePage: function(uniqueId) {
chrome.send('activatePage', [uniqueId]);
},
/**
* Sends command to enable or disable the given columns to update the data.
*/
setUpdateColumn: function(columnId, isEnabled) {
chrome.send('setUpdateColumn', [columnId, isEnabled]);
// The 'title' column contains the icon.
if (columnId == 'title')
chrome.send('setUpdateColumn', ['icon', isEnabled]);
}
};
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* Whether task manager shows 'Private Memory' instead of 'Phsical Memory'.
* @const
*/
var USE_PRIVATE_MEM = false;
// <if expr="(is_linux or pp_ifdef('chromeos'))">
// On Linux and ChromeOS, this is true because calculating Phsical Memory is
// slow.
USE_PRIVATE_MEM = true;
// </if>
/*
* Default columns (column_id, label_id, width, is_default)
* @const
*/
var DEFAULT_COLUMNS = [
['title', 'taskColumn', 300, true],
['profileName', 'profileNameColumn', 120, false],
['physicalMemory', 'physicalMemColumn', 80, !USE_PRIVATE_MEM],
['sharedMemory', 'sharedMemColumn', 80, false],
['privateMemory', 'privateMemColumn', 80, USE_PRIVATE_MEM],
['cpuUsage', 'cpuColumn', 80, true],
['networkUsage', 'netColumn', 85, true],
['processId', 'processIDColumn', 100, false],
['webCoreImageCacheSize', 'webcoreImageCacheColumn', 120, false],
['webCoreScriptsCacheSize', 'webcoreScriptsCacheColumn', 120, false],
['webCoreCSSCacheSize', 'webcoreCSSCacheColumn', 120, false],
['fps', 'fpsColumn', 50, true],
['videoMemory', 'videoMemoryColumn', 80, false],
['sqliteMemoryUsed', 'sqliteMemoryUsedColumn', 80, false],
['goatsTeleported', 'goatsTeleportedColumn', 80, false],
['v8MemoryAllocatedSize', 'javascriptMemoryAllocatedColumn', 120, false],
];
/*
* Height of each tasks. It is 20px, which is also defined in CSS.
* @const
*/
var HEIGHT_OF_TASK = 20;
var COMMAND_CONTEXTMENU_COLUMN_PREFIX = 'columnContextMenu';
var COMMAND_CONTEXTMENU_TABLE_PREFIX = 'tableContextMenu';
var ENABLED_COLUMNS_KEY = 'enabledColumns';
var DEFAULT_SORT_COLUMN = 'cpuUsage';
var DEFAULT_SORT_DIRECTION = 'desc';
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This script includes additional resources via document.write(). Hence, it
// must be a separate script file loaded before other scripts which would
// reference the resources.
var css = [
'chrome_shared.css',
'list.css',
'table.css',
'menu.css',
];
var script = [
'load_time_data.js',
'i18n_template_no_process.js',
'event_tracker.js',
'util.js',
'cr.js',
'cr/ui.js',
'cr/event_target.js',
'cr/ui/array_data_model.js',
'cr/ui/list_item.js',
'cr/ui/list_selection_model.js',
'cr/ui/list_single_selection_model.js',
'cr/ui/list_selection_controller.js',
'cr/ui/list.js',
'cr/ui/splitter.js',
'cr/ui/table/table_splitter.js',
'cr/ui/touch_handler.js',
'cr/ui/table/table_column.js',
'cr/ui/table/table_column_model.js',
'cr/ui/table/table_header.js',
'cr/ui/table/table_list.js',
'cr/ui/table.js',
'cr/ui/grid.js',
];
var scriptDelayed = [
'cr/ui/command.js',
'cr/ui/position_util.js',
'cr/ui/menu_item.js',
'cr/ui/menu.js',
'cr/ui/context_menu_handler.js',
];
var loadDelayedIncludes;
(function() {
// Switch to 'test harness' mode when loading from a file url.
var isHarness = document.location.protocol == 'file:';
// In test harness mode we load resources from relative dirs.
var prefix = isHarness ? './shared/' : 'chrome://resources/';
for (var i = 0; i < css.length; i++) {
document.write('<link href="' + prefix + 'css/' + css[i] +
'" rel="stylesheet"></link>');
}
for (var i = 0; i < script.length; i++) {
document.write('<script src="' + prefix + 'js/' + script[i] +
'"><\/script>');
}
/**
* Loads delayed scripts.
* This function is called by TaskManager::initalize() in main.js.
*/
loadDelayedIncludes = function(taskmanager) {
// Number of remaining scripts to load.
var remain = scriptDelayed.length;
// Waits for initialization of task manager.
for (var i = 0; i < scriptDelayed.length; i++) {
var s = document.createElement('script');
s.onload = function(e) {
if (!--remain)
taskmanager.delayedInitialize();
};
s.src = prefix + 'js/' + scriptDelayed[i];
document.head.appendChild(s);
}
};
})();
<!DOCTYPE HTML>
<!--
-- Copyright (c) 2012 The Chromium Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style license that can be
-- found in the LICENSE file.
-->
<html i18n-values="dir:textdirection;">
<head>
<meta charset="utf-8">
<title i18n-content="title"></title>
<script src="measure_time.js"></script>
<script src="commands.js"></script>
<script src="defines.js"></script>
<script src="preload.js"></script>
<script src="includes.js"></script>
<script src="main.js"></script>
<script src="chrome://tasks/strings.js"></script>
<!-- For accurate load performance tracking
place all scripts above this line -->
<script src="measure_time_end.js"></script>
<link rel="stylesheet" href="task_manager.css">
</head>
<body>
<div class="dialog-body">
<div class="list-container">
<div class="detail-table"></div>
</div>
</div>
<div class="dialog-footer">
<div class="footer-left-container">
<a href="#" id="about-memory-link" i18n-content="aboutMemoryLink"></a>
</div>
<div class="footer-right-container">
<button id="kill-process" i18n-content="killButton" disabled></button>
<if expr="pp_ifdef('chromeos')">
<button id="close-window" i18n-content="closeWindow"></button>
</if>
</div>
</div>
</body>
</html>
This diff is collapsed.
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview Utility methods for measuring loading times.
*
* To be included as a first script in main.html
*/
/**
* measureTime class
* @constructor
*/
var measureTime = {
isEnabled: localStorage.measureTimeEnabled,
startInterval: function(name) {
if (this.isEnabled)
console.time(name);
},
recordInterval: function(name) {
if (this.isEnabled)
console.timeEnd(name);
},
};
measureTime.startInterval('Load.Total');
measureTime.startInterval('Load.Script');
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
measureTime.recordInterval('Load.Script');
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Defines global variables.
var commands = TaskManagerCommands;
var taskmanager = undefined; // This will be instantiated in main.js.
/**
* Invoked when a range of items has changed.
* @param {Integer} start The start position of tasks to be changed
* @param {Integer} length The length of tasks to be changed
* @param {Array of task} tasks The array of updated task
*/
function taskChanged(start, length, tasks) {
var task = {type: 'change', start: start, length: length, tasks: tasks};
if (taskmanager) taskmanager.processTaskChange(task);
}
// Cached list of enabled columns to prevent frequent access to localStorage.
var cachedEnabledColumns;
/**
* @return {Dictionary} the dictionary which contains the list of columns and
* whether each column is enabled or not.
*/
function getEnabledColumns() {
// Use the cache after the second time since access to localStorage is slow.
if (cachedEnabledColumns)
return cachedEnabledColumns;
var json = window.localStorage.getItem(ENABLED_COLUMNS_KEY);
try {
cachedEnabledColumns = JSON.parse(json) || {};
} catch (e) {
cachedEnabledColumns = {};
}
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
if (typeof(cachedEnabledColumns[DEFAULT_COLUMNS[i][0]]) == 'undefined')
cachedEnabledColumns[DEFAULT_COLUMNS[i][0]] = DEFAULT_COLUMNS[i][3];
}
return cachedEnabledColumns;
}
/**
* @return {boolean} the given column (at |columnId|) is enabled or not.
* @param {string} columnId The ID of the collumn to be checked.
*/
function isColumnEnabled(columnId) {
return (getEnabledColumns())[columnId];
}
/**
* Sets the given column either enabled or disabled.
* @param {string} columnId The ID of the collumn to be set.
* @param {boolean} newChecked True, to set the column enable. False otherwise.
*/
function setColumnEnabled(columnId, newChecked) {
commands.setUpdateColumn(columnId, newChecked);
cachedEnabledColumns[columnId] = newChecked;
var json = JSON.stringify(cachedEnabledColumns);
window.localStorage.setItem(ENABLED_COLUMNS_KEY, json);
}
// Enable the taskmanager model before the loading of scripts.
(function() {
for (var i = 0; i < DEFAULT_COLUMNS.length; i++) {
var columnId = DEFAULT_COLUMNS[i][0];
if (isColumnEnabled(columnId))
commands.setUpdateColumn(columnId, true);
}
commands.enableTaskManager();
commands.setUpdateColumn('canInspect', true);
commands.setUpdateColumn('canActivate', true);
})();
/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
html {
overflow: hidden;
}
/* Outer frame of the dialog. */
body {
-webkit-box-orient: vertical;
-webkit-user-select: none;
display: -webkit-box;
font-family: segoe ui, arial, helvetica, sans-serif;
font-size: 12px;
height: 100%;
min-height: 150px;
position: absolute;
width: 100%;
}
/* Container for the detail list views. */
.dialog-body {
-webkit-box-flex: 1;
border: 1px #aaa solid;
border-radius: 3px;
display: -webkit-box;
margin: 12px 12px 6px;
}
/* Column text containers. */
.list-container {
-webkit-box-flex: 1;
display: -webkit-box;
}
/* Table splitter element */
.table-header-splitter {
-webkit-border-start: 1px #aaa solid;
background-color: inherit;
height: 20px;
margin-top: 4px;
}
/* Container for a table header. */
.table-header {
-webkit-box-sizing: border-box;
background-image: -webkit-linear-gradient(top, #f9f9f9, #e8e8e8);
border-bottom: 1px #aaa solid;
height: 28px;
}
/* Text label in a table header. */
.table-header-label {
cursor: default;
margin-top: 6px;
}
/* Task list in table. */
.list {
-webkit-box-flex: 1;
}
/* Title Column text containers. */
.detail-title {
display: -webkit-box;
height: 20px;
}
/* Bullets on the left of row. */
.table-row > .table-row-cell:first-child::before {
-webkit-border-radius: 3px;
background: #ccc;
content: '';
display: block;
margin: 7px 4px 7px 7px;
width: 6px;
}
/* Cells in table. */
.table-row-cell {
-webkit-box-orient: horizontal;
display: -webkit-box;
}
/* Containers of titles of tasks on the process. */
.detail-container-title {
-webkit-box-flex: 1;
-webkit-box-orient: vertical;
display: -webkit-box;
margin-left: 3px;
}
.detail-title-image {
height: 16px;
padding: 2px;
width: 16px;
}
.detail-title-text {
height: 20px;
padding-left: 1px;
}
/* Entire Table (including column header). */
.detail-table {
-webkit-box-flex: 1;
-webkit-box-orient: vertical;
border: 0;
display: -webkit-box;
}
/* cr.ui.Table has a black focus border by default, which we don't want. */
.detail-table:focus {
border: 0;
}
/* Container for footer area. */
.dialog-footer {
display: -webkit-box;
margin: 6px 12px 12px;
}
/* Container for the ok/cancel buttons. */
.footer-left-container {
-webkit-box-align: center;
-webkit-box-flex: 1;
display: -webkit-box;
text-align: left;
}
#about-memory-link {
color: rgb(17, 85, 204);
padding-left: 2px;
}
/* Container for the ok/cancel buttons. */
.footer-right-container {
-webkit-box-flex: 1;
text-align: right;
}
button {
margin: 2px 0 2px 8px;
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/task_manager/task_manager_dialog.h"
#include <algorithm>
#include <string>
#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "grit/google_chrome_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/size.h"
#include "ui/web_dialogs/web_dialog_delegate.h"
#if defined(OS_CHROMEOS)
#include "ui/views/widget/widget.h"
#endif
namespace {
// The minimum size of task manager window in px.
const int kMinimumTaskManagerWidth = 640;
const int kMinimumTaskManagerHeight = 480;
} // namespace
using content::BrowserThread;
using content::WebContents;
using content::WebUIMessageHandler;
using ui::WebDialogDelegate;
class TaskManagerDialogImpl : public WebDialogDelegate {
public:
TaskManagerDialogImpl();
static void Show(bool is_background_page_mode);
static TaskManagerDialogImpl* GetInstance();
protected:
friend struct DefaultSingletonTraits<TaskManagerDialogImpl>;
virtual ~TaskManagerDialogImpl();
void OnCloseDialog();
// Overridden from WebDialogDelegate:
virtual ui::ModalType GetDialogModalType() const OVERRIDE {
return ui::MODAL_TYPE_NONE;
}
virtual base::string16 GetDialogTitle() const OVERRIDE {
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_TITLE);
}
virtual std::string GetDialogName() const OVERRIDE {
return prefs::kTaskManagerWindowPlacement;
}
virtual GURL GetDialogContentURL() const OVERRIDE {
std::string url_string(chrome::kChromeUITaskManagerURL);
url_string += "?";
if (browser_defaults::kShowCancelButtonInTaskManager)
url_string += "showclose=1&";
if (is_background_page_mode_)
url_string += "background=1";
return GURL(url_string);
}
virtual void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE {
}
virtual void GetDialogSize(gfx::Size* size) const OVERRIDE {
#if !defined(TOOLKIT_VIEWS)
// If dialog's bounds are previously saved, use them.
if (g_browser_process->local_state()) {
const base::DictionaryValue* placement_pref =
g_browser_process->local_state()->GetDictionary(
prefs::kTaskManagerWindowPlacement);
int width, height;
if (placement_pref &&
placement_pref->GetInteger("width", &width) &&
placement_pref->GetInteger("height", &height)) {
size->SetSize(std::max(1, width), std::max(1, height));
return;
}
}
// Otherwise set default size.
size->SetSize(kMinimumTaskManagerWidth, kMinimumTaskManagerHeight);
#endif
}
virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE {
size->SetSize(kMinimumTaskManagerWidth, kMinimumTaskManagerHeight);
}
virtual std::string GetDialogArgs() const OVERRIDE {
return std::string();
}
virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE {
OnCloseDialog();
}
virtual void OnCloseContents(WebContents* source, bool* out_close_dialog)
OVERRIDE {
*out_close_dialog = true;
}
virtual bool ShouldShowDialogTitle() const OVERRIDE {
return true;
}
virtual bool HandleContextMenu(
const content::ContextMenuParams& params) OVERRIDE {
return true;
}
#if !defined(TOOLKIT_VIEWS)
virtual void StoreDialogSize(const gfx::Size& dialog_size) OVERRIDE {
// Store the dialog's bounds so that it can be restored with the same bounds
// the next time it's opened.
if (g_browser_process->local_state()) {
DictionaryPrefUpdate update(g_browser_process->local_state(),
prefs::kTaskManagerWindowPlacement);
base::DictionaryValue* placement_pref = update.Get();
placement_pref->SetInteger("width", dialog_size.width());
placement_pref->SetInteger("height", dialog_size.height());
}
}
#endif
private:
void ShowDialog(bool is_background_page_mode);
void OpenWebDialog();
int show_count_;
gfx::NativeWindow window_;
bool is_background_page_mode_;
DISALLOW_COPY_AND_ASSIGN(TaskManagerDialogImpl);
};
// ****************************************************
// static
TaskManagerDialogImpl* TaskManagerDialogImpl::GetInstance() {
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::IO));
DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE));
return Singleton<TaskManagerDialogImpl>::get();
}
TaskManagerDialogImpl::TaskManagerDialogImpl()
: show_count_(0),
window_(NULL),
is_background_page_mode_(false) {
}
TaskManagerDialogImpl::~TaskManagerDialogImpl() {
}
// static
void TaskManagerDialogImpl::Show(bool is_background_page_mode) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
TaskManagerDialogImpl* dialog = TaskManagerDialogImpl::GetInstance();
dialog->ShowDialog(is_background_page_mode);
}
void TaskManagerDialogImpl::ShowDialog(bool is_background_page_mode) {
if (show_count_ > 0) {
#if defined(OS_CHROMEOS)
// Closes current TaskManager and Opens new one.
views::Widget::GetWidgetForNativeWindow(window_)->Close();
#else
// TODO(yoshiki): Supports the other platforms.
platform_util::ActivateWindow(window_);
return;
#endif
}
is_background_page_mode_ = is_background_page_mode;
OpenWebDialog();
++show_count_;
}
void TaskManagerDialogImpl::OnCloseDialog() {
if (show_count_ > 0)
--show_count_;
}
void TaskManagerDialogImpl::OpenWebDialog() {
window_ = chrome::ShowWebDialog(NULL,
ProfileManager::GetLastUsedProfile(),
this);
}
// static
void TaskManagerDialog::Show() {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&TaskManagerDialogImpl::Show, false));
}
// static
void TaskManagerDialog::ShowBackgroundPages() {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&TaskManagerDialogImpl::Show, true));
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_DIALOG_H_
#define CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_DIALOG_H_
class TaskManagerDialog {
public:
static void Show();
static void ShowBackgroundPages();
};
#endif // CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_DIALOG_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_HANDLER_H_
#include <set>
#include <string>
#include <vector>
#include "content/public/browser/web_ui_message_handler.h"
#include "chrome/browser/task_manager/task_manager.h"
namespace base {
class ListValue;
class Value;
}
class TaskManagerHandler : public content::WebUIMessageHandler,
public TaskManagerModelObserver {
public:
explicit TaskManagerHandler(TaskManager* tm);
virtual ~TaskManagerHandler();
// TaskManagerModelObserver implementation.
// Invoked when the model has been completely changed.
virtual void OnModelChanged() OVERRIDE;
// Invoked when a range of items has changed.
virtual void OnItemsChanged(int start, int length) OVERRIDE;
// Invoked when new items are added.
virtual void OnItemsAdded(int start, int length) OVERRIDE;
// Invoked when a range of items has been removed.
virtual void OnItemsRemoved(int start, int length) OVERRIDE;
// Invoked when the initialization of the model has been finished and
// periodic updates is started.
virtual void OnReadyPeriodicalUpdate() OVERRIDE;
// WebUIMessageHandler implementation.
virtual void RegisterMessages() OVERRIDE;
// Callback for the "killProcesses" message.
void HandleKillProcesses(const base::ListValue* indexes);
// Callback for the "activatePage" message.
void HandleActivatePage(const base::ListValue* resource_index);
// Callback for the "inspect" message.
void HandleInspect(const base::ListValue* resource_index);
void EnableTaskManager(const base::ListValue* indexes);
void DisableTaskManager(const base::ListValue* indexes);
void OpenAboutMemory(const base::ListValue* indexes);
// Callback for the "setUpdateColumn" message.
void HandleSetUpdateColumn(const base::ListValue* args);
private:
bool is_alive();
// Models
TaskManager* task_manager_;
TaskManagerModel* model_;
bool is_enabled_;
// Set to store the enabled columns.
std::set<std::string> enabled_columns_;
// Invoked when group(s) are added/changed/removed.
// These method are called from OnItemAdded/-Changed/-Removed internally.
void OnGroupAdded(int start, int length);
void OnGroupChanged(int start, int length);
void OnGroupRemoved(int start, int length);
// Creates or updates information for a single task group. A task group is a
// group of tasks associated with a single process ID. |group_index| is the
// integer index of the target process within the data model.
base::DictionaryValue* CreateTaskGroupValue(int group_index);
// Creates a list of values to display within a single column of the task
// manager for a single task group. |columnn_name| is the name of the column.
// |index| is the index of the resources associated with a process group.
// |length| is the number of values associated with the group, and is either
// 1 if all tasks within the group share a common value or equal to the
// number of tasks within the group.
void CreateGroupColumnList(const std::string& column_name,
const int index,
const int length,
base::DictionaryValue* val);
// Retrieves the value of a property for a single task. |column_name| is the
// name of the property, which is associated with a column within the task
// manager or "about memory" page. |i| is the index of the task. Tasks are
// grouped by process ID, and the index of the task is the sum of the group
// offset and the index of the task within the group.
base::Value* CreateColumnValue(const std::string& column_name,
const int i);
DISALLOW_COPY_AND_ASSIGN(TaskManagerHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_HANDLER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/webui/task_manager/task_manager_ui.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/browser/ui/webui/task_manager/task_manager_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
#include "grit/chromium_strings.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
using content::WebContents;
namespace {
content::WebUIDataSource* CreateTaskManagerUIHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUITaskManagerHost);
source->SetUseJsonJSFormatV2();
source->AddLocalizedString("closeWindow", IDS_CLOSE);
source->AddLocalizedString("title", IDS_TASK_MANAGER_TITLE);
source->AddLocalizedString("aboutMemoryLink",
IDS_TASK_MANAGER_ABOUT_MEMORY_LINK);
source->AddLocalizedString("killButton", IDS_TASK_MANAGER_KILL);
source->AddLocalizedString("processIDColumn",
IDS_TASK_MANAGER_PROCESS_ID_COLUMN);
source->AddLocalizedString("taskColumn", IDS_TASK_MANAGER_TASK_COLUMN);
source->AddLocalizedString("profileNameColumn",
IDS_TASK_MANAGER_PROFILE_NAME_COLUMN);
source->AddLocalizedString("netColumn", IDS_TASK_MANAGER_NET_COLUMN);
source->AddLocalizedString("cpuColumn", IDS_TASK_MANAGER_CPU_COLUMN);
source->AddLocalizedString("physicalMemColumn",
IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN);
source->AddLocalizedString("sharedMemColumn",
IDS_TASK_MANAGER_SHARED_MEM_COLUMN);
source->AddLocalizedString("privateMemColumn",
IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN);
source->AddLocalizedString("goatsTeleportedColumn",
IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN);
source->AddLocalizedString("webcoreImageCacheColumn",
IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN);
source->AddLocalizedString("webcoreScriptsCacheColumn",
IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN);
source->AddLocalizedString("webcoreCSSCacheColumn",
IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN);
source->AddLocalizedString("videoMemoryColumn",
IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN);
source->AddLocalizedString("fpsColumn", IDS_TASK_MANAGER_FPS_COLUMN);
source->AddLocalizedString("sqliteMemoryUsedColumn",
IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN);
source->AddLocalizedString(
"javascriptMemoryAllocatedColumn",
IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN);
source->AddLocalizedString("inspect", IDS_TASK_MANAGER_INSPECT);
source->AddLocalizedString("activate", IDS_TASK_MANAGER_ACTIVATE);
source->SetJsonPath("strings.js");
source->AddResourcePath("main.js", IDR_TASK_MANAGER_JS);
source->AddResourcePath("commands.js", IDR_TASK_MANAGER_COMMANDS_JS);
source->AddResourcePath("defines.js", IDR_TASK_MANAGER_DEFINES_JS);
source->AddResourcePath("includes.js", IDR_TASK_MANAGER_INCLUDES_JS);
source->AddResourcePath("preload.js", IDR_TASK_MANAGER_PRELOAD_JS);
source->AddResourcePath("measure_time.js", IDR_TASK_MANAGER_MEASURE_TIME_JS);
source->AddResourcePath("measure_time_end.js",
IDR_TASK_MANAGER_MEASURE_TIME_END_JS);
source->SetDefaultResource(IDR_TASK_MANAGER_HTML);
return source;
}
} // namespace
///////////////////////////////////////////////////////////////////////////////
//
// TaskManagerUI
//
///////////////////////////////////////////////////////////////////////////////
TaskManagerUI::TaskManagerUI(content::WebUI* web_ui) : WebUIController(web_ui) {
web_ui->AddMessageHandler(new TaskManagerHandler(TaskManager::GetInstance()));
// Set up the chrome://taskmanager/ source.
content::WebUIDataSource* html_source = CreateTaskManagerUIHTMLSource();
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_UI_H_
#define CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_UI_H_
#include "content/public/browser/web_ui_controller.h"
class TaskManagerUI : public content::WebUIController {
public:
explicit TaskManagerUI(content::WebUI* web_ui);
private:
DISALLOW_COPY_AND_ASSIGN(TaskManagerUI);
};
#endif // CHROME_BROWSER_UI_WEBUI_TASK_MANAGER_TASK_MANAGER_UI_H_
...@@ -2588,12 +2588,6 @@ ...@@ -2588,12 +2588,6 @@
'browser/ui/webui/sync_setup_handler.h', 'browser/ui/webui/sync_setup_handler.h',
'browser/ui/webui/system_info_ui.cc', 'browser/ui/webui/system_info_ui.cc',
'browser/ui/webui/system_info_ui.h', 'browser/ui/webui/system_info_ui.h',
'browser/ui/webui/task_manager/task_manager_dialog.cc',
'browser/ui/webui/task_manager/task_manager_dialog.h',
'browser/ui/webui/task_manager/task_manager_handler.cc',
'browser/ui/webui/task_manager/task_manager_handler.h',
'browser/ui/webui/task_manager/task_manager_ui.cc',
'browser/ui/webui/task_manager/task_manager_ui.h',
'browser/ui/webui/theme_handler.cc', 'browser/ui/webui/theme_handler.cc',
'browser/ui/webui/theme_handler.h', 'browser/ui/webui/theme_handler.h',
'browser/ui/webui/theme_source.cc', 'browser/ui/webui/theme_source.cc',
...@@ -2715,7 +2709,6 @@ ...@@ -2715,7 +2709,6 @@
}], }],
['enable_task_manager==0', { ['enable_task_manager==0', {
'sources/': [ 'sources/': [
['exclude', '^browser/ui/webui/task_manager/'],
['exclude', '^browser/ui/views/task_manager_view.cc'], ['exclude', '^browser/ui/views/task_manager_view.cc'],
['exclude', '^browser/ui/cocoa/task_manager_mac.h'], ['exclude', '^browser/ui/cocoa/task_manager_mac.h'],
['exclude', '^browser/ui/cocoa/task_manager_mac.mm'], ['exclude', '^browser/ui/cocoa/task_manager_mac.mm'],
...@@ -2906,7 +2899,6 @@ ...@@ -2906,7 +2899,6 @@
['exclude', '^browser/ui/views/user_data_dir_dialog_view.cc'], ['exclude', '^browser/ui/views/user_data_dir_dialog_view.cc'],
['exclude', '^browser/ui/views/tab_contents/web_drag_bookmark_handler_win.cc'], ['exclude', '^browser/ui/views/tab_contents/web_drag_bookmark_handler_win.cc'],
['exclude', '^browser/ui/views/tab_contents/web_drag_bookmark_handler_win.h'], ['exclude', '^browser/ui/views/tab_contents/web_drag_bookmark_handler_win.h'],
['exclude', '^browser/ui/webui/task_manager/'],
['exclude', '^browser/ui/window_sizer/window_sizer_win.cc'], ['exclude', '^browser/ui/window_sizer/window_sizer_win.cc'],
# TODO: (stevenjb/beng): Find a home for these. # TODO: (stevenjb/beng): Find a home for these.
['include', '^browser/ui/views/simple_message_box_views.cc'], ['include', '^browser/ui/views/simple_message_box_views.cc'],
...@@ -2957,7 +2949,6 @@ ...@@ -2957,7 +2949,6 @@
['exclude', '^browser/ui/webui/gesture_config_ui.h'], ['exclude', '^browser/ui/webui/gesture_config_ui.h'],
['exclude', '^browser/ui/webui/salsa_ui.cc'], ['exclude', '^browser/ui/webui/salsa_ui.cc'],
['exclude', '^browser/ui/webui/salsa_ui.h'], ['exclude', '^browser/ui/webui/salsa_ui.h'],
['exclude', '^browser/ui/webui/task_manager/'],
], ],
}], }],
['ui_compositor_image_transport==1', { ['ui_compositor_image_transport==1', {
......
...@@ -2179,7 +2179,6 @@ ...@@ -2179,7 +2179,6 @@
['enable_task_manager==0', { ['enable_task_manager==0', {
'sources/': [ 'sources/': [
['exclude', '^browser/task_manager/'], ['exclude', '^browser/task_manager/'],
['exclude', '^browser/ui/webui/task_manager/'],
], ],
}], }],
['file_manager_extension==0', { ['file_manager_extension==0', {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment