| 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/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/metrics/stats_table.h" | 8 #include "base/metrics/stats_table.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 : public ui::TableModel, | 61 : public ui::TableModel, |
| 62 public views::TableGrouper, | 62 public views::TableGrouper, |
| 63 public TaskManagerModelObserver { | 63 public TaskManagerModelObserver { |
| 64 public: | 64 public: |
| 65 explicit TaskManagerTableModel(TaskManagerModel* model) | 65 explicit TaskManagerTableModel(TaskManagerModel* model) |
| 66 : model_(model), | 66 : model_(model), |
| 67 observer_(NULL) { | 67 observer_(NULL) { |
| 68 model_->AddObserver(this); | 68 model_->AddObserver(this); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual ~TaskManagerTableModel() { | 71 ~TaskManagerTableModel() override { model_->RemoveObserver(this); } |
| 72 model_->RemoveObserver(this); | |
| 73 } | |
| 74 | 72 |
| 75 // TableModel overrides: | 73 // TableModel overrides: |
| 76 virtual int RowCount() override; | 74 int RowCount() override; |
| 77 virtual base::string16 GetText(int row, int column) override; | 75 base::string16 GetText(int row, int column) override; |
| 78 virtual gfx::ImageSkia GetIcon(int row) override; | 76 gfx::ImageSkia GetIcon(int row) override; |
| 79 virtual void SetObserver(ui::TableModelObserver* observer) override; | 77 void SetObserver(ui::TableModelObserver* observer) override; |
| 80 virtual int CompareValues(int row1, int row2, int column_id) override; | 78 int CompareValues(int row1, int row2, int column_id) override; |
| 81 | 79 |
| 82 // TableGrouper overrides: | 80 // TableGrouper overrides: |
| 83 virtual void GetGroupRange(int model_index, | 81 void GetGroupRange(int model_index, views::GroupRange* range) override; |
| 84 views::GroupRange* range) override; | |
| 85 | 82 |
| 86 // TaskManagerModelObserver overrides: | 83 // TaskManagerModelObserver overrides: |
| 87 virtual void OnModelChanged() override; | 84 void OnModelChanged() override; |
| 88 virtual void OnItemsChanged(int start, int length) override; | 85 void OnItemsChanged(int start, int length) override; |
| 89 virtual void OnItemsAdded(int start, int length) override; | 86 void OnItemsAdded(int start, int length) override; |
| 90 virtual void OnItemsRemoved(int start, int length) override; | 87 void OnItemsRemoved(int start, int length) override; |
| 91 | 88 |
| 92 private: | 89 private: |
| 93 TaskManagerModel* model_; | 90 TaskManagerModel* model_; |
| 94 ui::TableModelObserver* observer_; | 91 ui::TableModelObserver* observer_; |
| 95 | 92 |
| 96 DISALLOW_COPY_AND_ASSIGN(TaskManagerTableModel); | 93 DISALLOW_COPY_AND_ASSIGN(TaskManagerTableModel); |
| 97 }; | 94 }; |
| 98 | 95 |
| 99 int TaskManagerTableModel::RowCount() { | 96 int TaskManagerTableModel::RowCount() { |
| 100 return model_->ResourceCount(); | 97 return model_->ResourceCount(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 143 |
| 147 // The Task Manager UI container. | 144 // The Task Manager UI container. |
| 148 class TaskManagerView : public views::ButtonListener, | 145 class TaskManagerView : public views::ButtonListener, |
| 149 public views::DialogDelegateView, | 146 public views::DialogDelegateView, |
| 150 public views::TableViewObserver, | 147 public views::TableViewObserver, |
| 151 public views::LinkListener, | 148 public views::LinkListener, |
| 152 public views::ContextMenuController, | 149 public views::ContextMenuController, |
| 153 public ui::SimpleMenuModel::Delegate { | 150 public ui::SimpleMenuModel::Delegate { |
| 154 public: | 151 public: |
| 155 explicit TaskManagerView(chrome::HostDesktopType desktop_type); | 152 explicit TaskManagerView(chrome::HostDesktopType desktop_type); |
| 156 virtual ~TaskManagerView(); | 153 ~TaskManagerView() override; |
| 157 | 154 |
| 158 // Shows the Task Manager window, or re-activates an existing one. | 155 // Shows the Task Manager window, or re-activates an existing one. |
| 159 static void Show(Browser* browser); | 156 static void Show(Browser* browser); |
| 160 | 157 |
| 161 // Hides the Task Manager if it is showing. | 158 // Hides the Task Manager if it is showing. |
| 162 static void Hide(); | 159 static void Hide(); |
| 163 | 160 |
| 164 // views::View: | 161 // views::View: |
| 165 virtual void Layout() override; | 162 void Layout() override; |
| 166 virtual gfx::Size GetPreferredSize() const override; | 163 gfx::Size GetPreferredSize() const override; |
| 167 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 164 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 168 virtual void ViewHierarchyChanged( | 165 void ViewHierarchyChanged( |
| 169 const ViewHierarchyChangedDetails& details) override; | 166 const ViewHierarchyChangedDetails& details) override; |
| 170 | 167 |
| 171 // views::ButtonListener: | 168 // views::ButtonListener: |
| 172 virtual void ButtonPressed(views::Button* sender, | 169 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 173 const ui::Event& event) override; | |
| 174 | 170 |
| 175 // views::DialogDelegateView: | 171 // views::DialogDelegateView: |
| 176 virtual bool CanResize() const override; | 172 bool CanResize() const override; |
| 177 virtual bool CanMaximize() const override; | 173 bool CanMaximize() const override; |
| 178 virtual bool CanMinimize() const override; | 174 bool CanMinimize() const override; |
| 179 virtual bool ExecuteWindowsCommand(int command_id) override; | 175 bool ExecuteWindowsCommand(int command_id) override; |
| 180 virtual base::string16 GetWindowTitle() const override; | 176 base::string16 GetWindowTitle() const override; |
| 181 virtual std::string GetWindowName() const override; | 177 std::string GetWindowName() const override; |
| 182 virtual int GetDialogButtons() const override; | 178 int GetDialogButtons() const override; |
| 183 virtual void WindowClosing() override; | 179 void WindowClosing() override; |
| 184 virtual bool UseNewStyleForThisDialog() const override; | 180 bool UseNewStyleForThisDialog() const override; |
| 185 | 181 |
| 186 // views::TableViewObserver: | 182 // views::TableViewObserver: |
| 187 virtual void OnSelectionChanged() override; | 183 void OnSelectionChanged() override; |
| 188 virtual void OnDoubleClick() override; | 184 void OnDoubleClick() override; |
| 189 virtual void OnKeyDown(ui::KeyboardCode keycode) override; | 185 void OnKeyDown(ui::KeyboardCode keycode) override; |
| 190 | 186 |
| 191 // views::LinkListener: | 187 // views::LinkListener: |
| 192 virtual void LinkClicked(views::Link* source, int event_flags) override; | 188 void LinkClicked(views::Link* source, int event_flags) override; |
| 193 | 189 |
| 194 // Called by the column picker to pick up any new stat counters that | 190 // Called by the column picker to pick up any new stat counters that |
| 195 // may have appeared since last time. | 191 // may have appeared since last time. |
| 196 void UpdateStatsCounters(); | 192 void UpdateStatsCounters(); |
| 197 | 193 |
| 198 // views::ContextMenuController: | 194 // views::ContextMenuController: |
| 199 virtual void ShowContextMenuForView(views::View* source, | 195 void ShowContextMenuForView(views::View* source, |
| 200 const gfx::Point& point, | 196 const gfx::Point& point, |
| 201 ui::MenuSourceType source_type) override; | 197 ui::MenuSourceType source_type) override; |
| 202 | 198 |
| 203 // ui::SimpleMenuModel::Delegate: | 199 // ui::SimpleMenuModel::Delegate: |
| 204 virtual bool IsCommandIdChecked(int id) const override; | 200 bool IsCommandIdChecked(int id) const override; |
| 205 virtual bool IsCommandIdEnabled(int id) const override; | 201 bool IsCommandIdEnabled(int id) const override; |
| 206 virtual bool GetAcceleratorForCommandId( | 202 bool GetAcceleratorForCommandId(int command_id, |
| 207 int command_id, | 203 ui::Accelerator* accelerator) override; |
| 208 ui::Accelerator* accelerator) override; | 204 void ExecuteCommand(int id, int event_flags) override; |
| 209 virtual void ExecuteCommand(int id, int event_flags) override; | |
| 210 | 205 |
| 211 private: | 206 private: |
| 212 // Creates the child controls. | 207 // Creates the child controls. |
| 213 void Init(); | 208 void Init(); |
| 214 | 209 |
| 215 // Initializes the state of the always-on-top setting as the window is shown. | 210 // Initializes the state of the always-on-top setting as the window is shown. |
| 216 void InitAlwaysOnTopState(); | 211 void InitAlwaysOnTopState(); |
| 217 | 212 |
| 218 // Activates the tab associated with the focused row. | 213 // Activates the tab associated with the focused row. |
| 219 void ActivateFocusedTab(); | 214 void ActivateFocusedTab(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // Declared in browser_dialogs.h so others don't need to depend on our header. | 664 // Declared in browser_dialogs.h so others don't need to depend on our header. |
| 670 void ShowTaskManager(Browser* browser) { | 665 void ShowTaskManager(Browser* browser) { |
| 671 TaskManagerView::Show(browser); | 666 TaskManagerView::Show(browser); |
| 672 } | 667 } |
| 673 | 668 |
| 674 void HideTaskManager() { | 669 void HideTaskManager() { |
| 675 TaskManagerView::Hide(); | 670 TaskManagerView::Hide(); |
| 676 } | 671 } |
| 677 | 672 |
| 678 } // namespace chrome | 673 } // namespace chrome |
| OLD | NEW |