| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/metrics/stats_table.h" | 9 #include "base/metrics/stats_table.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 public views::Menu::Delegate { | 270 public views::Menu::Delegate { |
| 271 public: | 271 public: |
| 272 explicit TaskManagerView(bool highlight_background_resources); | 272 explicit TaskManagerView(bool highlight_background_resources); |
| 273 virtual ~TaskManagerView(); | 273 virtual ~TaskManagerView(); |
| 274 | 274 |
| 275 // Shows the Task manager window, or re-activates an existing one. If | 275 // Shows the Task manager window, or re-activates an existing one. If |
| 276 // |highlight_background_resources| is true, highlights the background | 276 // |highlight_background_resources| is true, highlights the background |
| 277 // resources in the resource display. | 277 // resources in the resource display. |
| 278 static void Show(bool highlight_background_resources); | 278 static void Show(bool highlight_background_resources); |
| 279 | 279 |
| 280 // views::View | 280 // views::View: |
| 281 virtual void Layout() OVERRIDE; | 281 virtual void Layout() OVERRIDE; |
| 282 virtual gfx::Size GetPreferredSize() OVERRIDE; | 282 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 283 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | 283 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, |
| 284 views::View* child) OVERRIDE; | 284 views::View* child) OVERRIDE; |
| 285 | 285 |
| 286 // ButtonListener implementation. | 286 // views::ButtonListener: |
| 287 virtual void ButtonPressed(views::Button* sender, | 287 virtual void ButtonPressed(views::Button* sender, |
| 288 const views::Event& event) OVERRIDE; | 288 const views::Event& event) OVERRIDE; |
| 289 | 289 |
| 290 // views::DialogDelegate | 290 // views::DialogDelegateView: |
| 291 virtual bool CanResize() const OVERRIDE; | 291 virtual bool CanResize() const OVERRIDE; |
| 292 virtual bool CanMaximize() const OVERRIDE; | 292 virtual bool CanMaximize() const OVERRIDE; |
| 293 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; | 293 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; |
| 294 virtual string16 GetWindowTitle() const OVERRIDE; | 294 virtual string16 GetWindowTitle() const OVERRIDE; |
| 295 virtual std::string GetWindowName() const OVERRIDE; | 295 virtual std::string GetWindowName() const OVERRIDE; |
| 296 virtual int GetDialogButtons() const OVERRIDE; | 296 virtual int GetDialogButtons() const OVERRIDE; |
| 297 virtual void WindowClosing() OVERRIDE; | 297 virtual void WindowClosing() OVERRIDE; |
| 298 virtual views::View* GetContentsView() OVERRIDE; | 298 virtual views::View* GetContentsView() OVERRIDE; |
| 299 | 299 |
| 300 // views::TableViewObserver implementation. | 300 // views::TableViewObserver: |
| 301 virtual void OnSelectionChanged() OVERRIDE; | 301 virtual void OnSelectionChanged() OVERRIDE; |
| 302 virtual void OnDoubleClick() OVERRIDE; | 302 virtual void OnDoubleClick() OVERRIDE; |
| 303 virtual void OnKeyDown(ui::KeyboardCode keycode) OVERRIDE; | 303 virtual void OnKeyDown(ui::KeyboardCode keycode) OVERRIDE; |
| 304 | 304 |
| 305 // views::LinkListener implementation. | 305 // views::LinkListener: |
| 306 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 306 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
| 307 | 307 |
| 308 // Called by the column picker to pick up any new stat counters that | 308 // Called by the column picker to pick up any new stat counters that |
| 309 // may have appeared since last time. | 309 // may have appeared since last time. |
| 310 void UpdateStatsCounters(); | 310 void UpdateStatsCounters(); |
| 311 | 311 |
| 312 // views::ContextMenuController | 312 // views::ContextMenuController: |
| 313 virtual void ShowContextMenuForView(views::View* source, | 313 virtual void ShowContextMenuForView(views::View* source, |
| 314 const gfx::Point& p, | 314 const gfx::Point& point) OVERRIDE; |
| 315 bool is_mouse_gesture) OVERRIDE; | |
| 316 | 315 |
| 317 // views::Menu::Delegate | 316 // views::Menu::Delegate: |
| 318 virtual bool IsItemChecked(int id) const OVERRIDE; | 317 virtual bool IsItemChecked(int id) const OVERRIDE; |
| 319 virtual void ExecuteCommand(int id) OVERRIDE; | 318 virtual void ExecuteCommand(int id) OVERRIDE; |
| 320 | 319 |
| 321 private: | 320 private: |
| 322 // Creates the child controls. | 321 // Creates the child controls. |
| 323 void Init(); | 322 void Init(); |
| 324 | 323 |
| 325 // Initializes the state of the always-on-top setting as the window is shown. | 324 // Initializes the state of the always-on-top setting as the window is shown. |
| 326 void InitAlwaysOnTopState(); | 325 void InitAlwaysOnTopState(); |
| 327 | 326 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 if (keycode == ui::VKEY_RETURN) | 700 if (keycode == ui::VKEY_RETURN) |
| 702 ActivateFocusedTab(); | 701 ActivateFocusedTab(); |
| 703 } | 702 } |
| 704 | 703 |
| 705 void TaskManagerView::LinkClicked(views::Link* source, int event_flags) { | 704 void TaskManagerView::LinkClicked(views::Link* source, int event_flags) { |
| 706 DCHECK(source == about_memory_link_); | 705 DCHECK(source == about_memory_link_); |
| 707 task_manager_->OpenAboutMemory(); | 706 task_manager_->OpenAboutMemory(); |
| 708 } | 707 } |
| 709 | 708 |
| 710 void TaskManagerView::ShowContextMenuForView(views::View* source, | 709 void TaskManagerView::ShowContextMenuForView(views::View* source, |
| 711 const gfx::Point& p, | 710 const gfx::Point& point) { |
| 712 bool is_mouse_gesture) { | |
| 713 UpdateStatsCounters(); | 711 UpdateStatsCounters(); |
| 714 scoped_ptr<views::Menu> menu(views::Menu::Create( | 712 scoped_ptr<views::Menu> menu(views::Menu::Create( |
| 715 this, views::Menu::TOPLEFT, source->GetWidget()->GetNativeView())); | 713 this, views::Menu::TOPLEFT, source->GetWidget()->GetNativeView())); |
| 716 for (std::vector<ui::TableColumn>::iterator i = | 714 for (std::vector<ui::TableColumn>::iterator i = |
| 717 columns_.begin(); i != columns_.end(); ++i) { | 715 columns_.begin(); i != columns_.end(); ++i) { |
| 718 menu->AppendMenuItem(i->id, l10n_util::GetStringUTF16(i->id), | 716 menu->AppendMenuItem(i->id, l10n_util::GetStringUTF16(i->id), |
| 719 views::Menu::CHECKBOX); | 717 views::Menu::CHECKBOX); |
| 720 } | 718 } |
| 721 menu->RunMenuAt(p.x(), p.y()); | 719 menu->RunMenuAt(point.x(), point.y()); |
| 722 } | 720 } |
| 723 | 721 |
| 724 bool TaskManagerView::IsItemChecked(int id) const { | 722 bool TaskManagerView::IsItemChecked(int id) const { |
| 725 return tab_table_->IsColumnVisible(id); | 723 return tab_table_->IsColumnVisible(id); |
| 726 } | 724 } |
| 727 | 725 |
| 728 void TaskManagerView::ExecuteCommand(int id) { | 726 void TaskManagerView::ExecuteCommand(int id) { |
| 729 tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id)); | 727 tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id)); |
| 730 } | 728 } |
| 731 | 729 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 // Declared in browser_dialogs.h so others don't need to depend on our header. | 795 // Declared in browser_dialogs.h so others don't need to depend on our header. |
| 798 void ShowTaskManager() { | 796 void ShowTaskManager() { |
| 799 TaskManagerView::Show(false); | 797 TaskManagerView::Show(false); |
| 800 } | 798 } |
| 801 | 799 |
| 802 void ShowBackgroundPages() { | 800 void ShowBackgroundPages() { |
| 803 TaskManagerView::Show(true); | 801 TaskManagerView::Show(true); |
| 804 } | 802 } |
| 805 | 803 |
| 806 } // namespace browser | 804 } // namespace browser |
| OLD | NEW |