summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/task_manager_mac.h
blob: 46d04556f0103b818a3c58b0179ed013bb494a60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_
#define CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_

#import <Cocoa/Cocoa.h>
#include "base/scoped_nsobject.h"
#include "chrome/browser/task_manager.h"

// This class is responsible for loading the task manager window and for
// managing it.
@interface TaskManagerWindowController : NSWindowController {
 @private
  IBOutlet NSTableView* tableView_;
  TaskManagerModel* model_;  // weak
}

// Creates and shows the task manager's window.
- (id)initWithModel:(TaskManagerModel*)model;

// Refreshes all data in the task manager table.
- (void)reloadData;
@end

// This class listens to task changed events sent by chrome.
class TaskManagerMac : public TaskManagerModelObserver {
 public:
  TaskManagerMac();
  virtual ~TaskManagerMac();

  // TaskManagerModelObserver
  virtual void OnModelChanged();
  virtual void OnItemsChanged(int start, int length);
  virtual void OnItemsAdded(int start, int length);
  virtual void OnItemsRemoved(int start, int length);

  // Creates the task manager if it doesn't exist; otherwise, it activates the
  // existing task manager window.
  static void Show();

 private:
  // The task manager.
  TaskManager* task_manager_;  // weak

  // Our model.
  TaskManagerModel* model_;  // weak

  // Controller of our window.
  scoped_nsobject<TaskManagerWindowController> window_controller_;

  // An open task manager window. There can only be one open at a time. This
  // is reset to NULL when the window is closed.
  static TaskManagerMac* instance_;

  DISALLOW_COPY_AND_ASSIGN(TaskManagerMac);
};

#endif  // CHROME_BROWSER_COCOA_TASK_MANAGER_MAC_H_