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

Side by Side Diff: chrome/browser/ui/views/new_task_manager_view.h

Issue 1367673003: Expose all reusable task manager view code so it can be used by Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_VIEWS_NEW_TASK_MANAGER_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/ui/host_desktop.h" 10 #include "chrome/browser/ui/host_desktop.h"
11 #include "ui/base/models/simple_menu_model.h" 11 #include "ui/base/models/simple_menu_model.h"
12 #include "ui/base/models/table_model.h" 12 #include "ui/base/models/table_model.h"
13 #include "ui/views/context_menu_controller.h" 13 #include "ui/views/context_menu_controller.h"
14 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/controls/button/label_button.h"
15 #include "ui/views/controls/link_listener.h" 15 #include "ui/views/controls/link_listener.h"
16 #include "ui/views/controls/menu/menu_runner.h" 16 #include "ui/views/controls/menu/menu_runner.h"
17 #include "ui/views/controls/table/table_grouper.h"
17 #include "ui/views/controls/table/table_view_observer.h" 18 #include "ui/views/controls/table/table_view_observer.h"
18 #include "ui/views/window/dialog_delegate.h" 19 #include "ui/views/window/dialog_delegate.h"
19 20
20 namespace views { 21 namespace views {
21 class LabelButton; 22 class LabelButton;
22 class Link; 23 class Link;
23 class TableView; 24 class TableView;
24 class View; 25 class View;
25 } // namespace views 26 } // namespace views
26 27
27 namespace task_management { 28 namespace task_management {
28 29
29 // A collection of data to be used in the construction of a task manager table 30 class TaskManagerTableModel;
30 // column.
31 struct TableColumnData {
32 // The generated ID of the column. These can change from one build to another.
33 // Their values are controlled by the generation from generated_resources.grd.
34 int id;
35
36 // The alignment of the text displayed in this column.
37 ui::TableColumn::Alignment align;
38
39 // |width| and |percent| used to define the size of the column. See
40 // ui::TableColumn::width and ui::TableColumn::percent for details.
41 int width;
42 float percent;
43
44 // Is the column sortable.
45 bool sortable;
46
47 // Is the initial sort order ascending?
48 bool initial_sort_is_ascending;
49
50 // The default visibility of this column at startup of the table if no
51 // visibility is stored for it in the prefs.
52 bool default_visibility;
53 };
54
55 // The task manager table columns and their properties.
56 extern const TableColumnData kColumns[];
57 extern const size_t kColumnsSize;
58
59 // Session Restore Keys.
60 extern const char kSortColumnIdKey[];
61 extern const char kSortIsAscendingKey[];
62
63 // Returns the |column_id| as a string value to be used as keys in the user
64 // preferences.
65 std::string GetColumnIdAsString(int column_id);
66 31
67 // The new task manager UI container. 32 // The new task manager UI container.
68 class NewTaskManagerView 33 class NewTaskManagerView
69 : public views::ButtonListener, 34 : public views::ButtonListener,
70 public views::DialogDelegateView, 35 public views::DialogDelegateView,
36 public views::TableGrouper,
71 public views::TableViewObserver, 37 public views::TableViewObserver,
72 public views::LinkListener, 38 public views::LinkListener,
73 public views::ContextMenuController, 39 public views::ContextMenuController,
74 public ui::SimpleMenuModel::Delegate { 40 public ui::SimpleMenuModel::Delegate {
75 public: 41 public:
76 ~NewTaskManagerView() override; 42 ~NewTaskManagerView() override;
77 43
78 // Shows the Task Manager window, or re-activates an existing one. 44 // Shows the Task Manager window, or re-activates an existing one.
79 static void Show(Browser* browser); 45 static void Show(Browser* browser);
80 46
(...skipping 14 matching lines...) Expand all
95 bool CanResize() const override; 61 bool CanResize() const override;
96 bool CanMaximize() const override; 62 bool CanMaximize() const override;
97 bool CanMinimize() const override; 63 bool CanMinimize() const override;
98 bool ExecuteWindowsCommand(int command_id) override; 64 bool ExecuteWindowsCommand(int command_id) override;
99 base::string16 GetWindowTitle() const override; 65 base::string16 GetWindowTitle() const override;
100 std::string GetWindowName() const override; 66 std::string GetWindowName() const override;
101 int GetDialogButtons() const override; 67 int GetDialogButtons() const override;
102 void WindowClosing() override; 68 void WindowClosing() override;
103 bool UseNewStyleForThisDialog() const override; 69 bool UseNewStyleForThisDialog() const override;
104 70
71 // views::TableGrouper:
72 void GetGroupRange(int model_index, views::GroupRange* range) override;
73
105 // views::TableViewObserver: 74 // views::TableViewObserver:
106 void OnSelectionChanged() override; 75 void OnSelectionChanged() override;
107 void OnDoubleClick() override; 76 void OnDoubleClick() override;
108 void OnKeyDown(ui::KeyboardCode keycode) override; 77 void OnKeyDown(ui::KeyboardCode keycode) override;
109 78
110 // views::LinkListener: 79 // views::LinkListener:
111 void LinkClicked(views::Link* source, int event_flags) override; 80 void LinkClicked(views::Link* source, int event_flags) override;
112 81
113 // views::ContextMenuController: 82 // views::ContextMenuController:
114 void ShowContextMenuForView(views::View* source, 83 void ShowContextMenuForView(views::View* source,
115 const gfx::Point& point, 84 const gfx::Point& point,
116 ui::MenuSourceType source_type) override; 85 ui::MenuSourceType source_type) override;
117 86
118 // ui::SimpleMenuModel::Delegate: 87 // ui::SimpleMenuModel::Delegate:
119 bool IsCommandIdChecked(int id) const override; 88 bool IsCommandIdChecked(int id) const override;
120 bool IsCommandIdEnabled(int id) const override; 89 bool IsCommandIdEnabled(int id) const override;
121 bool GetAcceleratorForCommandId(int command_id, 90 bool GetAcceleratorForCommandId(int command_id,
122 ui::Accelerator* accelerator) override; 91 ui::Accelerator* accelerator) override;
123 void ExecuteCommand(int id, int event_flags) override; 92 void ExecuteCommand(int id, int event_flags) override;
124 93
125 private: 94 private:
95 class ViewsTableDelegate;
126 friend class NewTaskManagerViewTest; 96 friend class NewTaskManagerViewTest;
127 class TableModel;
128 97
129 explicit NewTaskManagerView(chrome::HostDesktopType desktop_type); 98 explicit NewTaskManagerView(chrome::HostDesktopType desktop_type);
130 99
131 static NewTaskManagerView* GetInstanceForTests(); 100 static NewTaskManagerView* GetInstanceForTests();
132 101
133 // Creates the child controls. 102 // Creates the child controls.
134 void Init(); 103 void Init();
135 104
136 // Initializes the state of the always-on-top setting as the window is shown. 105 // Initializes the state of the always-on-top setting as the window is shown.
137 void InitAlwaysOnTopState(); 106 void InitAlwaysOnTopState();
138 107
139 // Activates the tab associated with the focused row. 108 // Activates the tab associated with the focused row.
140 void ActivateFocusedTab(); 109 void ActivateFocusedTab();
141 110
142 // Restores saved "always on top" state from a previous session. 111 // Restores saved "always on top" state from a previous session.
143 void RetriveSavedAlwaysOnTopState(); 112 void RetriveSavedAlwaysOnTopState();
144 113
145 // Restores the saved columns settings from a previous session into 114 scoped_ptr<ViewsTableDelegate> table_delegate_;
146 // |columns_settings_| and updates the table view.
147 void RetrieveSavedColumnsSettingsAndUpdateTable();
148 115
149 // Stores the current values in |column_settings_| to the user prefs so that 116 scoped_ptr<TaskManagerTableModel> table_model_;
150 // it can be restored later next time the task manager view is opened.
151 void StoreColumnsSettings();
152
153 void ToggleColumnVisibility(int column_id);
154
155 scoped_ptr<NewTaskManagerView::TableModel> table_model_;
156 117
157 scoped_ptr<views::MenuRunner> menu_runner_; 118 scoped_ptr<views::MenuRunner> menu_runner_;
158 119
159 // Contains either the column settings retrieved from user preferences if it
160 // exists, or the default column settings.
161 // The columns settings are the visible columns and the last sorted column
162 // and the direction of the sort.
163 scoped_ptr<base::DictionaryValue> columns_settings_;
164
165 // We need to own the text of the menu, the Windows API does not copy it. 120 // We need to own the text of the menu, the Windows API does not copy it.
166 base::string16 always_on_top_menu_text_; 121 base::string16 always_on_top_menu_text_;
167 122
168 views::LabelButton* kill_button_; 123 views::LabelButton* kill_button_;
169 views::Link* about_memory_link_; 124 views::Link* about_memory_link_;
170 views::TableView* tab_table_; 125 views::TableView* tab_table_;
171 views::View* tab_table_parent_; 126 views::View* tab_table_parent_;
172 127
173 // all possible columns, not necessarily visible 128 // all possible columns, not necessarily visible
174 std::vector<ui::TableColumn> columns_; 129 std::vector<ui::TableColumn> columns_;
175 130
176 // The host desktop type this task manager belongs to. 131 // The host desktop type this task manager belongs to.
177 const chrome::HostDesktopType desktop_type_; 132 const chrome::HostDesktopType desktop_type_;
178 133
179 // True when the Task Manager window should be shown on top of other windows. 134 // True when the Task Manager window should be shown on top of other windows.
180 bool is_always_on_top_; 135 bool is_always_on_top_;
181 136
182 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerView); 137 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerView);
183 }; 138 };
184 139
185 } // namespace task_management 140 } // namespace task_management
186 141
187 #endif // CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_ 142 #endif // CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698