| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/task_manager.h" | 5 #include "chrome/browser/task_manager.h" |
| 6 | 6 |
| 7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
| 8 #include "base/stats_table.h" | 8 #include "base/stats_table.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/thread.h" | 10 #include "base/thread.h" |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 UpdateStatsCounters(); | 777 UpdateStatsCounters(); |
| 778 views::TableColumn col(kGoatsTeleportedColumn, L"Goats Teleported", | 778 views::TableColumn col(kGoatsTeleportedColumn, L"Goats Teleported", |
| 779 views::TableColumn::RIGHT, -1, 0); | 779 views::TableColumn::RIGHT, -1, 0); |
| 780 col.sortable = true; | 780 col.sortable = true; |
| 781 columns_.push_back(col); | 781 columns_.push_back(col); |
| 782 tab_table_->AddColumn(col); | 782 tab_table_->AddColumn(col); |
| 783 tab_table_->SetObserver(this); | 783 tab_table_->SetObserver(this); |
| 784 SetContextMenuController(this); | 784 SetContextMenuController(this); |
| 785 kill_button_.reset(new views::NativeButton( | 785 kill_button_.reset(new views::NativeButton( |
| 786 this, l10n_util::GetString(IDS_TASK_MANAGER_KILL))); | 786 this, l10n_util::GetString(IDS_TASK_MANAGER_KILL))); |
| 787 // TODO(hamaji): Use accelerator once the bug in FocusManager fixed. |
| 788 // http://crbug.com/11073 |
| 789 // kill_button_->AddAccelerator(views::Accelerator('E', false, false, false)); |
| 790 kill_button_->SetAccessibleKeyboardShortcut(L"E"); |
| 787 about_memory_link_.reset(new views::Link( | 791 about_memory_link_.reset(new views::Link( |
| 788 l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK))); | 792 l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK))); |
| 789 about_memory_link_->SetController(this); | 793 about_memory_link_->SetController(this); |
| 790 | 794 |
| 791 AddChildView(tab_table_); | 795 AddChildView(tab_table_); |
| 792 | 796 |
| 793 // Makes sure our state is consistent. | 797 // Makes sure our state is consistent. |
| 794 OnSelectionChanged(); | 798 OnSelectionChanged(); |
| 795 } | 799 } |
| 796 | 800 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 tab_table_->SelectedRowCount() > 0); | 913 tab_table_->SelectedRowCount() > 0); |
| 910 } | 914 } |
| 911 | 915 |
| 912 void TaskManagerContents::OnDoubleClick() { | 916 void TaskManagerContents::OnDoubleClick() { |
| 913 task_manager_->ActivateFocusedTab(); | 917 task_manager_->ActivateFocusedTab(); |
| 914 } | 918 } |
| 915 | 919 |
| 916 void TaskManagerContents::OnKeyDown(unsigned short virtual_keycode) { | 920 void TaskManagerContents::OnKeyDown(unsigned short virtual_keycode) { |
| 917 if (virtual_keycode == VK_RETURN) | 921 if (virtual_keycode == VK_RETURN) |
| 918 task_manager_->ActivateFocusedTab(); | 922 task_manager_->ActivateFocusedTab(); |
| 923 else if (virtual_keycode == 'E') |
| 924 task_manager_->KillSelectedProcesses(); |
| 919 } | 925 } |
| 920 | 926 |
| 921 // views::LinkController implementation | 927 // views::LinkController implementation |
| 922 void TaskManagerContents::LinkActivated(views::Link* source, | 928 void TaskManagerContents::LinkActivated(views::Link* source, |
| 923 int event_flags) { | 929 int event_flags) { |
| 924 DCHECK(source == about_memory_link_); | 930 DCHECK(source == about_memory_link_); |
| 925 Browser* browser = BrowserList::GetLastActive(); | 931 Browser* browser = BrowserList::GetLastActive(); |
| 926 DCHECK(browser); | 932 DCHECK(browser); |
| 927 browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB, | 933 browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB, |
| 928 PageTransition::LINK); | 934 PageTransition::LINK); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1002 return false; | 1008 return false; |
| 1003 } | 1009 } |
| 1004 | 1010 |
| 1005 void TaskManager::KillSelectedProcesses() { | 1011 void TaskManager::KillSelectedProcesses() { |
| 1006 std::vector<int> selection; | 1012 std::vector<int> selection; |
| 1007 contents_->GetSelection(&selection); | 1013 contents_->GetSelection(&selection); |
| 1008 for (std::vector<int>::const_iterator iter = selection.begin(); | 1014 for (std::vector<int>::const_iterator iter = selection.begin(); |
| 1009 iter != selection.end(); ++iter) { | 1015 iter != selection.end(); ++iter) { |
| 1010 HANDLE process = table_model_->GetProcessAt(*iter); | 1016 HANDLE process = table_model_->GetProcessAt(*iter); |
| 1011 DCHECK(process); | 1017 DCHECK(process); |
| 1018 if (process == GetCurrentProcess()) |
| 1019 continue; |
| 1012 TerminateProcess(process, 0); | 1020 TerminateProcess(process, 0); |
| 1013 } | 1021 } |
| 1014 } | 1022 } |
| 1015 | 1023 |
| 1016 void TaskManager::ActivateFocusedTab() { | 1024 void TaskManager::ActivateFocusedTab() { |
| 1017 std::vector<int> focused; | 1025 std::vector<int> focused; |
| 1018 contents_->GetFocused(&focused); | 1026 contents_->GetFocused(&focused); |
| 1019 int focused_size = static_cast<int>(focused.size()); | 1027 int focused_size = static_cast<int>(focused.size()); |
| 1020 | 1028 |
| 1021 DCHECK(focused_size == 1); | 1029 DCHECK(focused_size == 1); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 } | 1107 } |
| 1100 | 1108 |
| 1101 views::View* TaskManager::GetContentsView() { | 1109 views::View* TaskManager::GetContentsView() { |
| 1102 return contents_.get(); | 1110 return contents_.get(); |
| 1103 } | 1111 } |
| 1104 | 1112 |
| 1105 // static | 1113 // static |
| 1106 TaskManager* TaskManager::GetInstance() { | 1114 TaskManager* TaskManager::GetInstance() { |
| 1107 return Singleton<TaskManager>::get(); | 1115 return Singleton<TaskManager>::get(); |
| 1108 } | 1116 } |
| OLD | NEW |