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
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_
6#define CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_
7
8#include "base/basictypes.h"
9#include "base/gtest_prod_util.h"
10#include "base/memory/scoped_vector.h"
11#include "base/strings/string16.h"
12
13namespace gfx {
14class ImageSkia;
15}
16
17class StatusIcon;
18
19// Provides a cross-platform interface to the system's status tray, and exposes
20// APIs to add/remove icons to the tray and attach context menus.
21class StatusTray {
22 public:
23  enum StatusIconType {
24    NOTIFICATION_TRAY_ICON = 0,
25    MEDIA_STREAM_CAPTURE_ICON,
26    BACKGROUND_MODE_ICON,
27    OTHER_ICON,
28    NAMED_STATUS_ICON_COUNT
29  };
30
31  // Static factory method that is implemented separately for each platform to
32  // produce the appropriate platform-specific instance. Returns NULL if this
33  // platform does not support status icons.
34  static StatusTray* Create();
35
36  virtual ~StatusTray();
37
38  // Creates a new StatusIcon. The StatusTray retains ownership of the
39  // StatusIcon. Returns NULL if the StatusIcon could not be created.
40  StatusIcon* CreateStatusIcon(StatusIconType type,
41                               const gfx::ImageSkia& image,
42                               const base::string16& tool_tip);
43
44  // Removes |icon| from this status tray.
45  void RemoveStatusIcon(StatusIcon* icon);
46
47 protected:
48  typedef ScopedVector<StatusIcon> StatusIcons;
49
50  StatusTray();
51
52  // Factory method for creating a status icon for this platform.
53  virtual StatusIcon* CreatePlatformStatusIcon(
54      StatusIconType type,
55      const gfx::ImageSkia& image,
56      const base::string16& tool_tip) = 0;
57
58  // Returns the list of active status icons so subclasses can operate on them.
59  const StatusIcons& status_icons() const { return status_icons_; }
60
61 private:
62  // List containing all active StatusIcons. The icons are owned by this
63  // StatusTray.
64  StatusIcons status_icons_;
65
66  DISALLOW_COPY_AND_ASSIGN(StatusTray);
67};
68
69#endif  // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_
70