diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 22:44:38 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-22 22:44:38 +0000 |
commit | 8f90afd7751345b1b86e15355dffb35aae76110e (patch) | |
tree | f0aac6c51753b5359c576bfc7a232b4b1849d079 /chrome/browser/task_manager.cc | |
parent | e42a3b7d1233096f25a570bc4bad7acc2f2fee0b (diff) | |
download | chromium_src-8f90afd7751345b1b86e15355dffb35aae76110e.zip chromium_src-8f90afd7751345b1b86e15355dffb35aae76110e.tar.gz chromium_src-8f90afd7751345b1b86e15355dffb35aae76110e.tar.bz2 |
Reorganize the way the task manager is constructed.
The BrowserWindow creates the task manager UI directly, which uses the TaskManager to populate itself.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/140044
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18975 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager.cc')
-rw-r--r-- | chrome/browser/task_manager.cc | 81 |
1 files changed, 14 insertions, 67 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 8f174cc..0a671e3 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -698,86 +698,34 @@ void TaskManager::RegisterPrefs(PrefService* prefs) { } TaskManager::TaskManager() - : ALLOW_THIS_IN_INITIALIZER_LIST(model_(new TaskManagerModel(this))), - view_(NULL) { + : ALLOW_THIS_IN_INITIALIZER_LIST(model_(new TaskManagerModel(this))) { } TaskManager::~TaskManager() { } -// static -void TaskManager::Open() { - TaskManager* task_manager = GetInstance(); - if (task_manager->view_) { - task_manager->view_->ActivateWindow(); - } else { - task_manager->CreateView(); - task_manager->view_->OpenWindow(); - } +bool TaskManager::IsBrowserProcess(int index) const { + // If some of the selection is out of bounds, ignore. This may happen when + // killing a process that manages several pages. + return index < model_->ResourceCount() && + model_->GetResourceProcessHandle(index) == + base::GetCurrentProcessHandle(); } -// static -void TaskManager::Close() { - TaskManager* task_manager = GetInstance(); - task_manager->view_->CloseWindow(); -} - -bool TaskManager::BrowserProcessIsSelected() { - if (!view_) - return false; - std::vector<int> selection; - view_->GetSelection(&selection); - for (std::vector<int>::const_iterator iter = selection.begin(); - iter != selection.end(); ++iter) { - // If some of the selection is out of bounds, ignore. This may happen when - // killing a process that manages several pages. - if (*iter >= model_->ResourceCount()) - continue; - if (model_->GetResourceProcessHandle(*iter) == - base::GetCurrentProcessHandle()) - return true; - } - return false; -} - -void TaskManager::KillSelectedProcesses() { - std::vector<int> selection; - view_->GetSelection(&selection); - for (std::vector<int>::const_iterator iter = selection.begin(); - iter != selection.end(); ++iter) { - base::ProcessHandle process = model_->GetResourceProcessHandle(*iter); - DCHECK(process); - if (process == base::GetCurrentProcessHandle()) - continue; +void TaskManager::KillProcess(int index) { + base::ProcessHandle process = model_->GetResourceProcessHandle(index); + DCHECK(process); + if (process != base::GetCurrentProcessHandle()) base::KillProcess(process, base::PROCESS_END_KILLED_BY_USER, false); - } } -void TaskManager::ActivateFocusedTab() { - std::vector<int> focused; - view_->GetFocused(&focused); - int focused_size = static_cast<int>(focused.size()); - - DCHECK(focused_size == 1); - - // Gracefully return if there is not exactly one item in focus. - if (focused_size != 1) - return; - - // Otherwise, the one focused thing should be one the user intends to bring - // forth, so get see if GetTabContents returns non-null. If it does, activate - // those contents. - int index = focused[0]; - +void TaskManager::ActivateProcess(int index) { // GetResourceTabContents returns a pointer to the relevant tab contents for // the resource. If the index doesn't correspond to a Tab (i.e. refers to // the Browser process or a plugin), GetTabContents will return NULL. TabContents* chosen_tab_contents = model_->GetResourceTabContents(index); - - if (!chosen_tab_contents) - return; - - chosen_tab_contents->Activate(); + if (chosen_tab_contents) + chosen_tab_contents->Activate(); } void TaskManager::AddResourceProvider(ResourceProvider* provider) { @@ -799,7 +747,6 @@ void TaskManager::RemoveResource(Resource* resource) { void TaskManager::OnWindowClosed() { model_->StopUpdating(); model_->Clear(); - view_ = NULL; } // static |