OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/gtk/task_manager_gtk.h" | 5 #include "chrome/browser/ui/gtk/task_manager_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 TreeViewColumnSetVisible(treeview_, kTaskManagerWebCoreScriptsCache, false); | 663 TreeViewColumnSetVisible(treeview_, kTaskManagerWebCoreScriptsCache, false); |
664 TreeViewColumnSetVisible(treeview_, kTaskManagerWebCoreCssCache, false); | 664 TreeViewColumnSetVisible(treeview_, kTaskManagerWebCoreCssCache, false); |
665 TreeViewColumnSetVisible(treeview_, kTaskManagerVideoMemory, false); | 665 TreeViewColumnSetVisible(treeview_, kTaskManagerVideoMemory, false); |
666 TreeViewColumnSetVisible(treeview_, kTaskManagerSqliteMemoryUsed, false); | 666 TreeViewColumnSetVisible(treeview_, kTaskManagerSqliteMemoryUsed, false); |
667 TreeViewColumnSetVisible(treeview_, kTaskManagerGoatsTeleported, false); | 667 TreeViewColumnSetVisible(treeview_, kTaskManagerGoatsTeleported, false); |
668 | 668 |
669 g_object_unref(process_list_); | 669 g_object_unref(process_list_); |
670 g_object_unref(process_list_sort_); | 670 g_object_unref(process_list_sort_); |
671 } | 671 } |
672 | 672 |
673 bool IsSharedByGroup(int col_id) { | |
674 switch (col_id) { | |
675 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: | |
676 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: | |
677 case IDS_TASK_MANAGER_CPU_COLUMN: | |
678 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: | |
679 case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: | |
680 case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: | |
681 case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: | |
682 case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: | |
683 return true; | |
684 default: | |
685 return false; | |
686 } | |
687 } | |
688 | |
689 std::string TaskManagerGtk::GetModelText(int row, int col_id) { | 673 std::string TaskManagerGtk::GetModelText(int row, int col_id) { |
690 if (IsSharedByGroup(col_id) && !model_->IsResourceFirstInGroup(row)) | 674 return UTF16ToUTF8(model_->GetResourceById(row, col_id)); |
691 return std::string(); | |
692 | |
693 switch (col_id) { | |
694 case IDS_TASK_MANAGER_TASK_COLUMN: // Process | |
695 return UTF16ToUTF8(model_->GetResourceTitle(row)); | |
696 | |
697 case IDS_TASK_MANAGER_PROFILE_NAME_COLUMN: // Profile name | |
698 return UTF16ToUTF8(model_->GetResourceProfileName(row)); | |
699 | |
700 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory | |
701 return UTF16ToUTF8(model_->GetResourcePrivateMemory(row)); | |
702 | |
703 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory | |
704 return UTF16ToUTF8(model_->GetResourceSharedMemory(row)); | |
705 | |
706 case IDS_TASK_MANAGER_CPU_COLUMN: // CPU | |
707 return UTF16ToUTF8(model_->GetResourceCPUUsage(row)); | |
708 | |
709 case IDS_TASK_MANAGER_NET_COLUMN: // Net | |
710 return UTF16ToUTF8(model_->GetResourceNetworkUsage(row)); | |
711 | |
712 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: // Process ID | |
713 return UTF16ToUTF8(model_->GetResourceProcessId(row)); | |
714 | |
715 case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: | |
716 return UTF16ToUTF8(model_->GetResourceV8MemoryAllocatedSize(row)); | |
717 | |
718 case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: | |
719 return UTF16ToUTF8(model_->GetResourceWebCoreImageCacheSize(row)); | |
720 | |
721 case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: | |
722 return UTF16ToUTF8(model_->GetResourceWebCoreScriptsCacheSize(row)); | |
723 | |
724 case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: | |
725 return UTF16ToUTF8(model_->GetResourceWebCoreCSSCacheSize(row)); | |
726 | |
727 case IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN: | |
728 return UTF16ToUTF8(model_->GetResourceVideoMemory(row)); | |
729 | |
730 case IDS_TASK_MANAGER_FPS_COLUMN: | |
731 return UTF16ToUTF8(model_->GetResourceFPS(row)); | |
732 | |
733 case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN: | |
734 return UTF16ToUTF8(model_->GetResourceSqliteMemoryUsed(row)); | |
735 | |
736 case IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN: // Goats Teleported! | |
737 return UTF16ToUTF8(model_->GetResourceGoatsTeleported(row)); | |
738 | |
739 default: | |
740 NOTREACHED(); | |
741 return std::string(); | |
742 } | |
743 } | 675 } |
744 | 676 |
745 GdkPixbuf* TaskManagerGtk::GetModelIcon(int row) { | 677 GdkPixbuf* TaskManagerGtk::GetModelIcon(int row) { |
746 SkBitmap icon = *model_->GetResourceIcon(row).bitmap(); | 678 SkBitmap icon = *model_->GetResourceIcon(row).bitmap(); |
747 if (icon.pixelRef() == | 679 if (icon.pixelRef() == |
748 ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 680 ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
749 IDR_DEFAULT_FAVICON).AsBitmap().pixelRef()) { | 681 IDR_DEFAULT_FAVICON).AsBitmap().pixelRef()) { |
750 return static_cast<GdkPixbuf*>(g_object_ref( | 682 return static_cast<GdkPixbuf*>(g_object_ref( |
751 GtkThemeService::GetDefaultFavicon(true).ToGdkPixbuf())); | 683 GtkThemeService::GetDefaultFavicon(true).ToGdkPixbuf())); |
752 } | 684 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 | 790 |
859 void TaskManagerGtk::OnLinkActivated() { | 791 void TaskManagerGtk::OnLinkActivated() { |
860 task_manager_->OpenAboutMemory(chrome::HOST_DESKTOP_TYPE_NATIVE); | 792 task_manager_->OpenAboutMemory(chrome::HOST_DESKTOP_TYPE_NATIVE); |
861 } | 793 } |
862 | 794 |
863 gint TaskManagerGtk::CompareImpl(GtkTreeModel* model, GtkTreeIter* a, | 795 gint TaskManagerGtk::CompareImpl(GtkTreeModel* model, GtkTreeIter* a, |
864 GtkTreeIter* b, int id) { | 796 GtkTreeIter* b, int id) { |
865 int row1 = gtk_tree::GetRowNumForIter(model, b); | 797 int row1 = gtk_tree::GetRowNumForIter(model, b); |
866 int row2 = gtk_tree::GetRowNumForIter(model, a); | 798 int row2 = gtk_tree::GetRowNumForIter(model, a); |
867 | 799 |
868 // When sorting by non-grouped attributes (e.g., Network), just do a normal | |
869 // sort. | |
870 if (!IsSharedByGroup(id)) | |
871 return model_->CompareValues(row1, row2, id); | |
872 | |
873 // Otherwise, make sure grouped resources are shown together. | 800 // Otherwise, make sure grouped resources are shown together. |
874 TaskManagerModel::GroupRange group_range1 = | 801 TaskManagerModel::GroupRange group_range1 = |
875 model_->GetGroupRangeForResource(row1); | 802 model_->GetGroupRangeForResource(row1); |
876 TaskManagerModel::GroupRange group_range2 = | 803 TaskManagerModel::GroupRange group_range2 = |
877 model_->GetGroupRangeForResource(row2); | 804 model_->GetGroupRangeForResource(row2); |
878 | 805 |
879 if (group_range1 == group_range2) { | 806 if (group_range1 == group_range2) { |
880 // Sort within groups. | 807 // Sort within groups. |
881 // We want the first-in-group row at the top, whether we are sorting up or | 808 // We want the first-in-group row at the top, whether we are sorting up or |
882 // down. | 809 // down. |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 guint keyval, | 958 guint keyval, |
1032 GdkModifierType modifier) { | 959 GdkModifierType modifier) { |
1033 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { | 960 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { |
1034 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget | 961 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget |
1035 // is destroyed. The deleted object will receive gtk signals otherwise. | 962 // is destroyed. The deleted object will receive gtk signals otherwise. |
1036 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); | 963 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); |
1037 } | 964 } |
1038 | 965 |
1039 return TRUE; | 966 return TRUE; |
1040 } | 967 } |
OLD | NEW |