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

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

Issue 1822: Task Manager Double Click (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 3 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 | « chrome/browser/task_manager.h ('k') | chrome/browser/task_manager_resource_providers.h » ('j') | 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/timer.h" 10 #include "base/timer.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 TaskManagerTableModel* table_model); 531 TaskManagerTableModel* table_model);
532 virtual ~TaskManagerContents(); 532 virtual ~TaskManagerContents();
533 533
534 void Init(TaskManagerTableModel* table_model); 534 void Init(TaskManagerTableModel* table_model);
535 virtual void Layout(); 535 virtual void Layout();
536 virtual void GetPreferredSize(CSize* out); 536 virtual void GetPreferredSize(CSize* out);
537 virtual void DidChangeBounds(const CRect& previous, const CRect& current); 537 virtual void DidChangeBounds(const CRect& previous, const CRect& current);
538 virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, 538 virtual void ViewHierarchyChanged(bool is_add, ChromeViews::View* parent,
539 ChromeViews::View* child); 539 ChromeViews::View* child);
540 void GetSelection(std::vector<int>* selection); 540 void GetSelection(std::vector<int>* selection);
541 void GetFocused(std::vector<int>* focused);
541 542
542 // NativeButton::Listener implementation. 543 // NativeButton::Listener implementation.
543 virtual void ButtonPressed(ChromeViews::NativeButton* sender); 544 virtual void ButtonPressed(ChromeViews::NativeButton* sender);
544 545
545 // ChromeViews::TableViewObserver implementation. 546 // ChromeViews::TableViewObserver implementation.
546 virtual void OnSelectionChanged(); 547 virtual void OnSelectionChanged();
548 virtual void OnDoubleClick();
549 virtual void OnKeyDown(unsigned short virtual_keycode);
547 550
548 // ChromeViews::LinkController implementation. 551 // ChromeViews::LinkController implementation.
549 virtual void LinkActivated(ChromeViews::Link* source, int event_flags); 552 virtual void LinkActivated(ChromeViews::Link* source, int event_flags);
550 553
551 // Called by the column picker to pick up any new stat counters that 554 // Called by the column picker to pick up any new stat counters that
552 // may have appeared since last time. 555 // may have appeared since last time.
553 void UpdateStatsCounters(); 556 void UpdateStatsCounters();
554 557
555 // Menu::Delegate 558 // Menu::Delegate
556 virtual void ShowContextMenu(ChromeViews::View* source, 559 virtual void ShowContextMenu(ChromeViews::View* source,
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 744
742 void TaskManagerContents::GetSelection(std::vector<int>* selection) { 745 void TaskManagerContents::GetSelection(std::vector<int>* selection) {
743 DCHECK(selection); 746 DCHECK(selection);
744 for (ChromeViews::TableSelectionIterator iter = tab_table_->SelectionBegin(); 747 for (ChromeViews::TableSelectionIterator iter = tab_table_->SelectionBegin();
745 iter != tab_table_->SelectionEnd(); ++iter) { 748 iter != tab_table_->SelectionEnd(); ++iter) {
746 // The TableView returns the selection starting from the end. 749 // The TableView returns the selection starting from the end.
747 selection->insert(selection->begin(), *iter); 750 selection->insert(selection->begin(), *iter);
748 } 751 }
749 } 752 }
750 753
754 void TaskManagerContents::GetFocused(std::vector<int>* focused) {
755 DCHECK(focused);
756 int row_count = tab_table_->RowCount();
757 for (int i = 0; i < row_count; ++i) {
758 // The TableView returns the selection starting from the end.
759 if (tab_table_->ItemHasTheFocus(i))
760 focused->insert(focused->begin(), i);
761 }
762 }
763
751 // NativeButton::Listener implementation. 764 // NativeButton::Listener implementation.
752 void TaskManagerContents::ButtonPressed(ChromeViews::NativeButton* sender) { 765 void TaskManagerContents::ButtonPressed(ChromeViews::NativeButton* sender) {
753 if (sender == kill_button_) 766 if (sender == kill_button_)
754 task_manager_->KillSelectedProcesses(); 767 task_manager_->KillSelectedProcesses();
755 } 768 }
756 769
757 // ChromeViews::TableViewObserver implementation. 770 // ChromeViews::TableViewObserver implementation.
758 void TaskManagerContents::OnSelectionChanged() { 771 void TaskManagerContents::OnSelectionChanged() {
759 kill_button_->SetEnabled(!task_manager_->BrowserProcessIsSelected() && 772 kill_button_->SetEnabled(!task_manager_->BrowserProcessIsSelected() &&
760 tab_table_->SelectedRowCount() > 0); 773 tab_table_->SelectedRowCount() > 0);
761 } 774 }
762 775
776 void TaskManagerContents::OnDoubleClick() {
777 task_manager_->ActivateFocusedTab();
778 }
779
780 void TaskManagerContents::OnKeyDown(unsigned short virtual_keycode) {
781 if (virtual_keycode == VK_RETURN)
782 task_manager_->ActivateFocusedTab();
783 }
784
763 // ChromeViews::LinkController implementation 785 // ChromeViews::LinkController implementation
764 void TaskManagerContents::LinkActivated(ChromeViews::Link* source, 786 void TaskManagerContents::LinkActivated(ChromeViews::Link* source,
765 int event_flags) { 787 int event_flags) {
766 DCHECK(source == about_memory_link_); 788 DCHECK(source == about_memory_link_);
767 Browser* browser = BrowserList::GetLastActive(); 789 Browser* browser = BrowserList::GetLastActive();
768 DCHECK(browser); 790 DCHECK(browser);
769 browser->OpenURL(GURL("about:memory"), NEW_FOREGROUND_TAB, 791 browser->OpenURL(GURL("about:memory"), NEW_FOREGROUND_TAB,
770 PageTransition::LINK); 792 PageTransition::LINK);
771 } 793 }
772 794
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 std::vector<int> selection; 868 std::vector<int> selection;
847 contents_->GetSelection(&selection); 869 contents_->GetSelection(&selection);
848 for (std::vector<int>::const_iterator iter = selection.begin(); 870 for (std::vector<int>::const_iterator iter = selection.begin();
849 iter != selection.end(); ++iter) { 871 iter != selection.end(); ++iter) {
850 HANDLE process = table_model_->GetProcessAt(*iter); 872 HANDLE process = table_model_->GetProcessAt(*iter);
851 DCHECK(process); 873 DCHECK(process);
852 TerminateProcess(process, 0); 874 TerminateProcess(process, 0);
853 } 875 }
854 } 876 }
855 877
878 void TaskManager::ActivateFocusedTab() {
879 std::vector<int> focused;
880 contents_->GetFocused(&focused);
881 int focused_size = static_cast<int>(focused.size());
882
883 DCHECK(focused_size == 1);
884
885 // Gracefully return if there is not exactly one item in focus.
886 if (focused_size != 1)
887 return;
888
889 // Otherwise, the one focused thing should be one the user intends to bring
890 // forth, so get see if GetTabContents returns non-null. If it does, activate
891 // those contents.
892 int index = focused[0];
893
894 // GetTabContents returns a pointer to the relevant tab contents for the
895 // resource. If the index doesn't correspond to a Tab (i.e. refers to the
896 // Browser process or a plugin), GetTabContents will return NULL.
897 TabContents* chosen_tab_contents =
898 table_model_->resources_[index]->GetTabContents();
899
900 if (!chosen_tab_contents)
901 return;
902
903 chosen_tab_contents->Activate();
904 }
905
856 void TaskManager::AddResourceProvider(ResourceProvider* provider) { 906 void TaskManager::AddResourceProvider(ResourceProvider* provider) {
857 table_model_->AddResourceProvider(provider); 907 table_model_->AddResourceProvider(provider);
858 } 908 }
859 909
860 void TaskManager::RemoveResourceProvider(ResourceProvider* provider) { 910 void TaskManager::RemoveResourceProvider(ResourceProvider* provider) {
861 table_model_->RemoveResourceProvider(provider); 911 table_model_->RemoveResourceProvider(provider);
862 } 912 }
863 913
864 void TaskManager::AddResource(Resource* resource) { 914 void TaskManager::AddResource(Resource* resource) {
865 table_model_->AddResource(resource); 915 table_model_->AddResource(resource);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 977
928 ChromeViews::View* TaskManager::GetContentsView() { 978 ChromeViews::View* TaskManager::GetContentsView() {
929 return contents_.get(); 979 return contents_.get();
930 } 980 }
931 981
932 // static 982 // static
933 TaskManager* TaskManager::GetInstance() { 983 TaskManager* TaskManager::GetInstance() {
934 return Singleton<TaskManager>::get(); 984 return Singleton<TaskManager>::get();
935 } 985 }
936 986
OLDNEW
« no previous file with comments | « chrome/browser/task_manager.h ('k') | chrome/browser/task_manager_resource_providers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698