OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ |
6 #define CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11 matching lines...) Expand all Loading... |
22 // managing it. | 22 // managing it. |
23 @interface TaskManagerWindowController : | 23 @interface TaskManagerWindowController : |
24 NSWindowController<NSTableViewDataSource, | 24 NSWindowController<NSTableViewDataSource, |
25 NSTableViewDelegate> { | 25 NSTableViewDelegate> { |
26 @private | 26 @private |
27 IBOutlet NSTableView* tableView_; | 27 IBOutlet NSTableView* tableView_; |
28 IBOutlet NSButton* endProcessButton_; | 28 IBOutlet NSButton* endProcessButton_; |
29 TaskManagerMac* taskManagerObserver_; // weak | 29 TaskManagerMac* taskManagerObserver_; // weak |
30 TaskManager* taskManager_; // weak | 30 TaskManager* taskManager_; // weak |
31 TaskManagerModel* model_; // weak | 31 TaskManagerModel* model_; // weak |
| 32 bool highlightBackgroundResources_; |
32 | 33 |
33 scoped_nsobject<WindowSizeAutosaver> size_saver_; | 34 scoped_nsobject<WindowSizeAutosaver> size_saver_; |
34 | 35 |
35 // These contain a permutation of [0..|model_->ResourceCount() - 1|]. Used to | 36 // These contain a permutation of [0..|model_->ResourceCount() - 1|]. Used to |
36 // implement sorting. | 37 // implement sorting. |
37 std::vector<int> viewToModelMap_; | 38 std::vector<int> viewToModelMap_; |
38 std::vector<int> modelToViewMap_; | 39 std::vector<int> modelToViewMap_; |
39 | 40 |
40 // Descriptor of the current sort column. | 41 // Descriptor of the current sort column. |
41 scoped_nsobject<NSSortDescriptor> currentSortDescriptor_; | 42 scoped_nsobject<NSSortDescriptor> currentSortDescriptor_; |
| 43 |
| 44 // Color we use for background resources. |
| 45 scoped_nsobject<NSColor> backgroundResourceColor_; |
42 } | 46 } |
43 | 47 |
44 // Creates and shows the task manager's window. | 48 // Creates and shows the task manager's window. |
45 - (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver; | 49 - (id)initWithTaskManagerObserver:(TaskManagerMac*)taskManagerObserver |
| 50 highlightBackgroundResources:(bool)highlightBackgroundResources; |
46 | 51 |
47 // Refreshes all data in the task manager table. | 52 // Refreshes all data in the task manager table. |
48 - (void)reloadData; | 53 - (void)reloadData; |
49 | 54 |
50 // Callback for "Stats for nerds" link. | 55 // Callback for "Stats for nerds" link. |
51 - (IBAction)statsLinkClicked:(id)sender; | 56 - (IBAction)statsLinkClicked:(id)sender; |
52 | 57 |
53 // Callback for "End process" button. | 58 // Callback for "End process" button. |
54 - (IBAction)killSelectedProcesses:(id)sender; | 59 - (IBAction)killSelectedProcesses:(id)sender; |
55 | 60 |
56 // Callback for double clicks on the table. | 61 // Callback for double clicks on the table. |
57 - (void)selectDoubleClickedTab:(id)sender; | 62 - (void)selectDoubleClickedTab:(id)sender; |
58 @end | 63 @end |
59 | 64 |
60 @interface TaskManagerWindowController (TestingAPI) | 65 @interface TaskManagerWindowController (TestingAPI) |
61 - (NSTableView*)tableView; | 66 - (NSTableView*)tableView; |
62 @end | 67 @end |
63 | 68 |
64 // This class listens to task changed events sent by chrome. | 69 // This class listens to task changed events sent by chrome. |
65 class TaskManagerMac : public TaskManagerModelObserver, | 70 class TaskManagerMac : public TaskManagerModelObserver, |
66 public TableRowNSImageCache::Table { | 71 public TableRowNSImageCache::Table { |
67 public: | 72 public: |
68 TaskManagerMac(TaskManager* task_manager); | 73 TaskManagerMac(TaskManager* task_manager, bool highlight_background); |
69 virtual ~TaskManagerMac(); | 74 virtual ~TaskManagerMac(); |
70 | 75 |
71 // TaskManagerModelObserver | 76 // TaskManagerModelObserver |
72 virtual void OnModelChanged(); | 77 virtual void OnModelChanged(); |
73 virtual void OnItemsChanged(int start, int length); | 78 virtual void OnItemsChanged(int start, int length); |
74 virtual void OnItemsAdded(int start, int length); | 79 virtual void OnItemsAdded(int start, int length); |
75 virtual void OnItemsRemoved(int start, int length); | 80 virtual void OnItemsRemoved(int start, int length); |
76 | 81 |
77 // Called by the cocoa window controller when its window closes and the | 82 // Called by the cocoa window controller when its window closes and the |
78 // controller destroyed itself. Informs the model to stop updating. | 83 // controller destroyed itself. Informs the model to stop updating. |
79 void WindowWasClosed(); | 84 void WindowWasClosed(); |
80 | 85 |
81 // TableRowNSImageCache::Table | 86 // TableRowNSImageCache::Table |
82 virtual int RowCount() const; | 87 virtual int RowCount() const; |
83 virtual SkBitmap GetIcon(int r) const; | 88 virtual SkBitmap GetIcon(int r) const; |
84 | 89 |
85 // Creates the task manager if it doesn't exist; otherwise, it activates the | 90 // Creates the task manager if it doesn't exist; otherwise, it activates the |
86 // existing task manager window. | 91 // existing task manager window. Highlights background resources if |
87 static void Show(); | 92 // |highlight_background_resources| is true. |
| 93 static void Show(bool highlight_background_resources); |
88 | 94 |
89 // Returns the TaskManager observed by |this|. | 95 // Returns the TaskManager observed by |this|. |
90 TaskManager* task_manager() { return task_manager_; } | 96 TaskManager* task_manager() { return task_manager_; } |
91 | 97 |
92 // Lazily converts the image at the given row and caches it in |icon_cache_|. | 98 // Lazily converts the image at the given row and caches it in |icon_cache_|. |
93 NSImage* GetImageForRow(int row); | 99 NSImage* GetImageForRow(int row); |
94 | 100 |
95 // Returns the cocoa object. Used for testing. | 101 // Returns the cocoa object. Used for testing. |
96 TaskManagerWindowController* cocoa_controller() { return window_controller_; } | 102 TaskManagerWindowController* cocoa_controller() { return window_controller_; } |
| 103 |
| 104 // Returns true if the resource at this location is a background resource. |
| 105 bool IsBackgroundRow(int row) const; |
97 private: | 106 private: |
98 // The task manager. | 107 // The task manager. |
99 TaskManager* const task_manager_; // weak | 108 TaskManager* const task_manager_; // weak |
100 | 109 |
101 // Our model. | 110 // Our model. |
102 TaskManagerModel* const model_; // weak | 111 TaskManagerModel* const model_; // weak |
103 | 112 |
104 // Controller of our window, destroys itself when the task manager window | 113 // Controller of our window, destroys itself when the task manager window |
105 // is closed. | 114 // is closed. |
106 TaskManagerWindowController* window_controller_; // weak | 115 TaskManagerWindowController* window_controller_; // weak |
107 | 116 |
108 // Caches favicons for all rows. Needs to be initalized after |model_|. | 117 // Caches favicons for all rows. Needs to be initalized after |model_|. |
109 TableRowNSImageCache icon_cache_; | 118 TableRowNSImageCache icon_cache_; |
110 | 119 |
| 120 // If true, highlight background resources. |
| 121 bool highlight_background_resources_; |
| 122 |
111 // An open task manager window. There can only be one open at a time. This | 123 // An open task manager window. There can only be one open at a time. This |
112 // is reset to NULL when the window is closed. | 124 // is reset to NULL when the window is closed. |
113 static TaskManagerMac* instance_; | 125 static TaskManagerMac* instance_; |
114 | 126 |
115 DISALLOW_COPY_AND_ASSIGN(TaskManagerMac); | 127 DISALLOW_COPY_AND_ASSIGN(TaskManagerMac); |
116 }; | 128 }; |
117 | 129 |
118 #endif // CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ | 130 #endif // CHROME_BROWSER_UI_COCOA_TASK_MANAGER_MAC_H_ |
OLD | NEW |