| OLD | NEW |
| 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_view_observer.h" | 17 #include "ui/views/controls/table/table_view_observer.h" |
| 18 #include "ui/views/window/dialog_delegate.h" | 18 #include "ui/views/window/dialog_delegate.h" |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 class LabelButton; | 21 class LabelButton; |
| 22 class Link; | 22 class Link; |
| 23 class TableView; | 23 class TableView; |
| 24 class View; | 24 class View; |
| 25 } // namespace views | 25 } // namespace views |
| 26 | 26 |
| 27 namespace task_management { | 27 namespace task_management { |
| 28 | 28 |
| 29 // A collection of data to be used in the construction of a task manager table | |
| 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 | |
| 67 // The new task manager UI container. | 29 // The new task manager UI container. |
| 68 class NewTaskManagerView | 30 class NewTaskManagerView |
| 69 : public views::ButtonListener, | 31 : public views::ButtonListener, |
| 70 public views::DialogDelegateView, | 32 public views::DialogDelegateView, |
| 71 public views::TableViewObserver, | 33 public views::TableViewObserver, |
| 72 public views::LinkListener, | 34 public views::LinkListener, |
| 73 public views::ContextMenuController, | 35 public views::ContextMenuController, |
| 74 public ui::SimpleMenuModel::Delegate { | 36 public ui::SimpleMenuModel::Delegate { |
| 75 public: | 37 public: |
| 76 ~NewTaskManagerView() override; | 38 ~NewTaskManagerView() override; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 ui::MenuSourceType source_type) override; | 78 ui::MenuSourceType source_type) override; |
| 117 | 79 |
| 118 // ui::SimpleMenuModel::Delegate: | 80 // ui::SimpleMenuModel::Delegate: |
| 119 bool IsCommandIdChecked(int id) const override; | 81 bool IsCommandIdChecked(int id) const override; |
| 120 bool IsCommandIdEnabled(int id) const override; | 82 bool IsCommandIdEnabled(int id) const override; |
| 121 bool GetAcceleratorForCommandId(int command_id, | 83 bool GetAcceleratorForCommandId(int command_id, |
| 122 ui::Accelerator* accelerator) override; | 84 ui::Accelerator* accelerator) override; |
| 123 void ExecuteCommand(int id, int event_flags) override; | 85 void ExecuteCommand(int id, int event_flags) override; |
| 124 | 86 |
| 125 private: | 87 private: |
| 126 friend class NewTaskManagerViewTest; | |
| 127 class TableModel; | 88 class TableModel; |
| 128 | 89 |
| 129 explicit NewTaskManagerView(chrome::HostDesktopType desktop_type); | 90 explicit NewTaskManagerView(chrome::HostDesktopType desktop_type); |
| 130 | 91 |
| 131 static NewTaskManagerView* GetInstanceForTests(); | |
| 132 | |
| 133 // Creates the child controls. | 92 // Creates the child controls. |
| 134 void Init(); | 93 void Init(); |
| 135 | 94 |
| 136 // Initializes the state of the always-on-top setting as the window is shown. | 95 // Initializes the state of the always-on-top setting as the window is shown. |
| 137 void InitAlwaysOnTopState(); | 96 void InitAlwaysOnTopState(); |
| 138 | 97 |
| 139 // Activates the tab associated with the focused row. | 98 // Activates the tab associated with the focused row. |
| 140 void ActivateFocusedTab(); | 99 void ActivateFocusedTab(); |
| 141 | 100 |
| 142 // Restores saved "always on top" state from a previous session. | 101 // Restores saved "always on top" state from a previous session. |
| 143 void RetriveSavedAlwaysOnTopState(); | 102 void RetriveSavedAlwaysOnTopState(); |
| 144 | 103 |
| 145 // Restores the saved columns settings from a previous session into | |
| 146 // |columns_settings_| and updates the table view. | |
| 147 void RetrieveSavedColumnsSettingsAndUpdateTable(); | |
| 148 | |
| 149 // Stores the current values in |column_settings_| to the user prefs so that | |
| 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_; | 104 scoped_ptr<NewTaskManagerView::TableModel> table_model_; |
| 156 | 105 |
| 157 scoped_ptr<views::MenuRunner> menu_runner_; | 106 scoped_ptr<views::MenuRunner> menu_runner_; |
| 158 | 107 |
| 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. | 108 // We need to own the text of the menu, the Windows API does not copy it. |
| 166 base::string16 always_on_top_menu_text_; | 109 base::string16 always_on_top_menu_text_; |
| 167 | 110 |
| 168 views::LabelButton* kill_button_; | 111 views::LabelButton* kill_button_; |
| 169 views::Link* about_memory_link_; | 112 views::Link* about_memory_link_; |
| 170 views::TableView* tab_table_; | 113 views::TableView* tab_table_; |
| 171 views::View* tab_table_parent_; | 114 views::View* tab_table_parent_; |
| 172 | 115 |
| 173 // all possible columns, not necessarily visible | 116 // all possible columns, not necessarily visible |
| 174 std::vector<ui::TableColumn> columns_; | 117 std::vector<ui::TableColumn> columns_; |
| 175 | 118 |
| 176 // The host desktop type this task manager belongs to. | 119 // The host desktop type this task manager belongs to. |
| 177 const chrome::HostDesktopType desktop_type_; | 120 const chrome::HostDesktopType desktop_type_; |
| 178 | 121 |
| 179 // True when the Task Manager window should be shown on top of other windows. | 122 // True when the Task Manager window should be shown on top of other windows. |
| 180 bool is_always_on_top_; | 123 bool is_always_on_top_; |
| 181 | 124 |
| 182 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerView); | 125 DISALLOW_COPY_AND_ASSIGN(NewTaskManagerView); |
| 183 }; | 126 }; |
| 184 | 127 |
| 185 } // namespace task_management | 128 } // namespace task_management |
| 186 | 129 |
| 187 #endif // CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_ | 130 #endif // CHROME_BROWSER_UI_VIEWS_NEW_TASK_MANAGER_VIEW_H_ |
| OLD | NEW |