| 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/ui/cocoa/task_manager_mac.h" | 5 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #import "chrome/browser/ui/cocoa/window_size_autosaver.h" | 14 #import "chrome/browser/ui/cocoa/window_size_autosaver.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 17 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 18 #include "ui/base/l10n/l10n_util_mac.h" | 18 #include "ui/base/l10n/l10n_util_mac.h" |
| 19 #include "ui/gfx/image/image_skia.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // Width of "a" and most other letters/digits in "small" table views. | 23 // Width of "a" and most other letters/digits in "small" table views. |
| 23 const int kCharWidth = 6; | 24 const int kCharWidth = 6; |
| 24 | 25 |
| 25 // Some of the strings below have spaces at the end or are missing letters, to | 26 // Some of the strings below have spaces at the end or are missing letters, to |
| 26 // make the columns look nicer, and to take potentially longer localized strings | 27 // make the columns look nicer, and to take potentially longer localized strings |
| 27 // into account. | 28 // into account. |
| 28 const struct ColumnWidth { | 29 const struct ColumnWidth { |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 618 |
| 618 void TaskManagerMac::WindowWasClosed() { | 619 void TaskManagerMac::WindowWasClosed() { |
| 619 delete this; | 620 delete this; |
| 620 instance_ = NULL; | 621 instance_ = NULL; |
| 621 } | 622 } |
| 622 | 623 |
| 623 int TaskManagerMac::RowCount() const { | 624 int TaskManagerMac::RowCount() const { |
| 624 return model_->ResourceCount(); | 625 return model_->ResourceCount(); |
| 625 } | 626 } |
| 626 | 627 |
| 627 SkBitmap TaskManagerMac::GetIcon(int r) const { | 628 gfx::ImageSkia TaskManagerMac::GetIcon(int r) const { |
| 628 return model_->GetResourceIcon(r); | 629 return model_->GetResourceIcon(r); |
| 629 } | 630 } |
| 630 | 631 |
| 631 bool TaskManagerMac::IsBackgroundRow(int row) const { | 632 bool TaskManagerMac::IsBackgroundRow(int row) const { |
| 632 return model_->IsBackgroundResource(row); | 633 return model_->IsBackgroundResource(row); |
| 633 } | 634 } |
| 634 | 635 |
| 635 // static | 636 // static |
| 636 void TaskManagerMac::Show(bool highlight_background_resources) { | 637 void TaskManagerMac::Show(bool highlight_background_resources) { |
| 637 if (instance_) { | 638 if (instance_) { |
| 638 if (instance_->highlight_background_resources_ == | 639 if (instance_->highlight_background_resources_ == |
| 639 highlight_background_resources) { | 640 highlight_background_resources) { |
| 640 // There's a Task manager window open already, so just activate it. | 641 // There's a Task manager window open already, so just activate it. |
| 641 [[instance_->window_controller_ window] | 642 [[instance_->window_controller_ window] |
| 642 makeKeyAndOrderFront:instance_->window_controller_]; | 643 makeKeyAndOrderFront:instance_->window_controller_]; |
| 643 return; | 644 return; |
| 644 } else { | 645 } else { |
| 645 // The user is switching between "View Background Pages" and | 646 // The user is switching between "View Background Pages" and |
| 646 // "Task Manager" so close the existing window and fall through to | 647 // "Task Manager" so close the existing window and fall through to |
| 647 // open a new one. | 648 // open a new one. |
| 648 [[instance_->window_controller_ window] close]; | 649 [[instance_->window_controller_ window] close]; |
| 649 } | 650 } |
| 650 } | 651 } |
| 651 // Create a new instance. | 652 // Create a new instance. |
| 652 instance_ = new TaskManagerMac(TaskManager::GetInstance(), | 653 instance_ = new TaskManagerMac(TaskManager::GetInstance(), |
| 653 highlight_background_resources); | 654 highlight_background_resources); |
| 654 instance_->model_->StartUpdating(); | 655 instance_->model_->StartUpdating(); |
| 655 } | 656 } |
| OLD | NEW |