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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 const ui::Event& event) OVERRIDE; | 220 const ui::Event& event) OVERRIDE; |
221 | 221 |
222 // views::DialogDelegateView: | 222 // views::DialogDelegateView: |
223 virtual bool CanResize() const OVERRIDE; | 223 virtual bool CanResize() const OVERRIDE; |
224 virtual bool CanMaximize() const OVERRIDE; | 224 virtual bool CanMaximize() const OVERRIDE; |
225 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; | 225 virtual bool ExecuteWindowsCommand(int command_id) OVERRIDE; |
226 virtual string16 GetWindowTitle() const OVERRIDE; | 226 virtual string16 GetWindowTitle() const OVERRIDE; |
227 virtual std::string GetWindowName() const OVERRIDE; | 227 virtual std::string GetWindowName() const OVERRIDE; |
228 virtual int GetDialogButtons() const OVERRIDE; | 228 virtual int GetDialogButtons() const OVERRIDE; |
229 virtual void WindowClosing() OVERRIDE; | 229 virtual void WindowClosing() OVERRIDE; |
| 230 virtual bool UseNewStyleForThisDialog() const OVERRIDE; |
230 | 231 |
231 // views::TableViewObserver: | 232 // views::TableViewObserver: |
232 virtual void OnSelectionChanged() OVERRIDE; | 233 virtual void OnSelectionChanged() OVERRIDE; |
233 virtual void OnDoubleClick() OVERRIDE; | 234 virtual void OnDoubleClick() OVERRIDE; |
234 virtual void OnKeyDown(ui::KeyboardCode keycode) OVERRIDE; | 235 virtual void OnKeyDown(ui::KeyboardCode keycode) OVERRIDE; |
235 | 236 |
236 // views::LinkListener: | 237 // views::LinkListener: |
237 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | 238 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; |
238 | 239 |
239 // Called by the column picker to pick up any new stat counters that | 240 // Called by the column picker to pick up any new stat counters that |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } else { | 487 } else { |
487 details.parent->RemoveChildView(kill_button_); | 488 details.parent->RemoveChildView(kill_button_); |
488 if (purge_memory_button_) | 489 if (purge_memory_button_) |
489 details.parent->RemoveChildView(purge_memory_button_); | 490 details.parent->RemoveChildView(purge_memory_button_); |
490 details.parent->RemoveChildView(about_memory_link_); | 491 details.parent->RemoveChildView(about_memory_link_); |
491 } | 492 } |
492 } | 493 } |
493 } | 494 } |
494 | 495 |
495 void TaskManagerView::Layout() { | 496 void TaskManagerView::Layout() { |
496 bool new_style = views::DialogDelegate::UseNewStyle(); | |
497 gfx::Size size = kill_button_->GetPreferredSize(); | 497 gfx::Size size = kill_button_->GetPreferredSize(); |
498 gfx::Rect parent_bounds = parent()->GetContentsBounds(); | 498 gfx::Rect parent_bounds = parent()->GetContentsBounds(); |
499 const int horizontal_margin = | 499 const int horizontal_margin = views::kPanelHorizMargin; |
500 new_style ? views::kButtonHEdgeMarginNew : views::kPanelHorizMargin; | 500 const int vertical_margin = views::kButtonVEdgeMargin; |
501 const int vertical_margin = | |
502 new_style ? views::kButtonVEdgeMarginNew : views::kButtonVEdgeMargin; | |
503 int x = width() - size.width() - horizontal_margin; | 501 int x = width() - size.width() - horizontal_margin; |
504 int y_buttons = parent_bounds.bottom() - size.height() - vertical_margin; | 502 int y_buttons = parent_bounds.bottom() - size.height() - vertical_margin; |
505 kill_button_->SetBounds(x, y_buttons, size.width(), size.height()); | 503 kill_button_->SetBounds(x, y_buttons, size.width(), size.height()); |
506 | 504 |
507 if (purge_memory_button_) { | 505 if (purge_memory_button_) { |
508 size = purge_memory_button_->GetPreferredSize(); | 506 size = purge_memory_button_->GetPreferredSize(); |
509 purge_memory_button_->SetBounds( | 507 purge_memory_button_->SetBounds( |
510 kill_button_->x() - size.width() - | 508 kill_button_->x() - size.width() - |
511 views::kUnrelatedControlHorizontalSpacing, | 509 views::kUnrelatedControlHorizontalSpacing, |
512 y_buttons, size.width(), size.height()); | 510 y_buttons, size.width(), size.height()); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 | 642 |
645 void TaskManagerView::WindowClosing() { | 643 void TaskManagerView::WindowClosing() { |
646 // Now that the window is closed, we can allow a new one to be opened. | 644 // Now that the window is closed, we can allow a new one to be opened. |
647 // (WindowClosing comes in asynchronously from the call to Close() and we | 645 // (WindowClosing comes in asynchronously from the call to Close() and we |
648 // may have already opened a new instance). | 646 // may have already opened a new instance). |
649 if (instance_ == this) | 647 if (instance_ == this) |
650 instance_ = NULL; | 648 instance_ = NULL; |
651 task_manager_->OnWindowClosed(); | 649 task_manager_->OnWindowClosed(); |
652 } | 650 } |
653 | 651 |
| 652 bool TaskManagerView::UseNewStyleForThisDialog() const { |
| 653 return false; |
| 654 } |
| 655 |
654 // views::TableViewObserver implementation. | 656 // views::TableViewObserver implementation. |
655 void TaskManagerView::OnSelectionChanged() { | 657 void TaskManagerView::OnSelectionChanged() { |
656 const ui::ListSelectionModel::SelectedIndices& selection( | 658 const ui::ListSelectionModel::SelectedIndices& selection( |
657 tab_table_->selection_model().selected_indices()); | 659 tab_table_->selection_model().selected_indices()); |
658 bool selection_contains_browser_process = false; | 660 bool selection_contains_browser_process = false; |
659 for (size_t i = 0; i < selection.size(); ++i) { | 661 for (size_t i = 0; i < selection.size(); ++i) { |
660 if (task_manager_->IsBrowserProcess(selection[i])) { | 662 if (task_manager_->IsBrowserProcess(selection[i])) { |
661 selection_contains_browser_process = true; | 663 selection_contains_browser_process = true; |
662 break; | 664 break; |
663 } | 665 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 } // namespace | 775 } // namespace |
774 | 776 |
775 namespace chrome { | 777 namespace chrome { |
776 | 778 |
777 // Declared in browser_dialogs.h so others don't need to depend on our header. | 779 // Declared in browser_dialogs.h so others don't need to depend on our header. |
778 void ShowTaskManager(Browser* browser, bool highlight_background_resources) { | 780 void ShowTaskManager(Browser* browser, bool highlight_background_resources) { |
779 TaskManagerView::Show(highlight_background_resources, browser); | 781 TaskManagerView::Show(highlight_background_resources, browser); |
780 } | 782 } |
781 | 783 |
782 } // namespace chrome | 784 } // namespace chrome |
OLD | NEW |