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

Side by Side Diff: chrome/browser/task_manager.cc

Issue 93135: Allow users to kill tasks by keystroke 'E'. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 UpdateStatsCounters(); 773 UpdateStatsCounters();
774 views::TableColumn col(kGoatsTeleportedColumn, L"Goats Teleported", 774 views::TableColumn col(kGoatsTeleportedColumn, L"Goats Teleported",
775 views::TableColumn::RIGHT, -1, 0); 775 views::TableColumn::RIGHT, -1, 0);
776 col.sortable = true; 776 col.sortable = true;
777 columns_.push_back(col); 777 columns_.push_back(col);
778 tab_table_->AddColumn(col); 778 tab_table_->AddColumn(col);
779 tab_table_->SetObserver(this); 779 tab_table_->SetObserver(this);
780 SetContextMenuController(this); 780 SetContextMenuController(this);
781 kill_button_.reset(new views::NativeButton( 781 kill_button_.reset(new views::NativeButton(
782 this, l10n_util::GetString(IDS_TASK_MANAGER_KILL))); 782 this, l10n_util::GetString(IDS_TASK_MANAGER_KILL)));
783 // TODO(hamaji): Use accelerator once the bug in FocusManager fixed.
784 // http://crbug.com/11073
785 // kill_button_->AddAccelerator(views::Accelerator('E', false, false, false));
786 kill_button_->SetAccessibleKeyboardShortcut(L"E");
783 about_memory_link_.reset(new views::Link( 787 about_memory_link_.reset(new views::Link(
784 l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK))); 788 l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK)));
785 about_memory_link_->SetController(this); 789 about_memory_link_->SetController(this);
786 790
787 AddChildView(tab_table_); 791 AddChildView(tab_table_);
788 792
789 // Makes sure our state is consistent. 793 // Makes sure our state is consistent.
790 OnSelectionChanged(); 794 OnSelectionChanged();
791 } 795 }
792 796
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 tab_table_->SelectedRowCount() > 0); 909 tab_table_->SelectedRowCount() > 0);
906 } 910 }
907 911
908 void TaskManagerContents::OnDoubleClick() { 912 void TaskManagerContents::OnDoubleClick() {
909 task_manager_->ActivateFocusedTab(); 913 task_manager_->ActivateFocusedTab();
910 } 914 }
911 915
912 void TaskManagerContents::OnKeyDown(unsigned short virtual_keycode) { 916 void TaskManagerContents::OnKeyDown(unsigned short virtual_keycode) {
913 if (virtual_keycode == VK_RETURN) 917 if (virtual_keycode == VK_RETURN)
914 task_manager_->ActivateFocusedTab(); 918 task_manager_->ActivateFocusedTab();
919 else if (virtual_keycode == 'E')
920 task_manager_->KillSelectedProcesses();
915 } 921 }
916 922
917 // views::LinkController implementation 923 // views::LinkController implementation
918 void TaskManagerContents::LinkActivated(views::Link* source, 924 void TaskManagerContents::LinkActivated(views::Link* source,
919 int event_flags) { 925 int event_flags) {
920 DCHECK(source == about_memory_link_); 926 DCHECK(source == about_memory_link_);
921 Browser* browser = BrowserList::GetLastActive(); 927 Browser* browser = BrowserList::GetLastActive();
922 DCHECK(browser); 928 DCHECK(browser);
923 browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB, 929 browser->OpenURL(GURL("about:memory"), GURL(), NEW_FOREGROUND_TAB,
924 PageTransition::LINK); 930 PageTransition::LINK);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 return false; 1004 return false;
999 } 1005 }
1000 1006
1001 void TaskManager::KillSelectedProcesses() { 1007 void TaskManager::KillSelectedProcesses() {
1002 std::vector<int> selection; 1008 std::vector<int> selection;
1003 contents_->GetSelection(&selection); 1009 contents_->GetSelection(&selection);
1004 for (std::vector<int>::const_iterator iter = selection.begin(); 1010 for (std::vector<int>::const_iterator iter = selection.begin();
1005 iter != selection.end(); ++iter) { 1011 iter != selection.end(); ++iter) {
1006 HANDLE process = table_model_->GetProcessAt(*iter); 1012 HANDLE process = table_model_->GetProcessAt(*iter);
1007 DCHECK(process); 1013 DCHECK(process);
1014 if (process == GetCurrentProcess())
1015 continue;
1008 TerminateProcess(process, 0); 1016 TerminateProcess(process, 0);
1009 } 1017 }
1010 } 1018 }
1011 1019
1012 void TaskManager::ActivateFocusedTab() { 1020 void TaskManager::ActivateFocusedTab() {
1013 std::vector<int> focused; 1021 std::vector<int> focused;
1014 contents_->GetFocused(&focused); 1022 contents_->GetFocused(&focused);
1015 int focused_size = static_cast<int>(focused.size()); 1023 int focused_size = static_cast<int>(focused.size());
1016 1024
1017 DCHECK(focused_size == 1); 1025 DCHECK(focused_size == 1);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 } 1103 }
1096 1104
1097 views::View* TaskManager::GetContentsView() { 1105 views::View* TaskManager::GetContentsView() {
1098 return contents_.get(); 1106 return contents_.get();
1099 } 1107 }
1100 1108
1101 // static 1109 // static
1102 TaskManager* TaskManager::GetInstance() { 1110 TaskManager* TaskManager::GetInstance() {
1103 return Singleton<TaskManager>::get(); 1111 return Singleton<TaskManager>::get();
1104 } 1112 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698