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 #ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ | 5 #ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |
6 #define CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ | 6 #define CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/memory/scoped_vector.h" |
13 | 12 |
14 class StatusIcon; | 13 class StatusIcon; |
15 | 14 |
16 // Provides a cross-platform interface to the system's status tray, and exposes | 15 // Provides a cross-platform interface to the system's status tray, and exposes |
17 // APIs to add/remove icons to the tray and attach context menus. | 16 // APIs to add/remove icons to the tray and attach context menus. |
18 class StatusTray { | 17 class StatusTray { |
19 public: | 18 public: |
20 // Static factory method that is implemented separately for each platform to | 19 // Static factory method that is implemented separately for each platform to |
21 // produce the appropriate platform-specific instance. Returns NULL if this | 20 // produce the appropriate platform-specific instance. Returns NULL if this |
22 // platform does not support status icons. | 21 // platform does not support status icons. |
23 static StatusTray* Create(); | 22 static StatusTray* Create(); |
24 | 23 |
25 virtual ~StatusTray(); | 24 virtual ~StatusTray(); |
26 | 25 |
27 // Creates a new StatusIcon. The StatusTray retains ownership of the | 26 // Creates a new StatusIcon. The StatusTray retains ownership of the |
28 // StatusIcon. Returns NULL if the StatusIcon could not be created. | 27 // StatusIcon. Returns NULL if the StatusIcon could not be created. |
29 StatusIcon* CreateStatusIcon(); | 28 StatusIcon* CreateStatusIcon(); |
30 | 29 |
31 // Removes |icon| from this status tray. | 30 // Removes |icon| from this status tray. |
32 void RemoveStatusIcon(StatusIcon* icon); | 31 void RemoveStatusIcon(StatusIcon* icon); |
33 | 32 |
34 protected: | 33 protected: |
35 typedef std::vector<StatusIcon*> StatusIconList; | 34 typedef ScopedVector<StatusIcon> StatusIcons; |
36 | 35 |
37 StatusTray(); | 36 StatusTray(); |
38 | 37 |
39 // Factory method for creating a status icon for this platform. | 38 // Factory method for creating a status icon for this platform. |
40 virtual StatusIcon* CreatePlatformStatusIcon() = 0; | 39 virtual StatusIcon* CreatePlatformStatusIcon() = 0; |
41 | 40 |
42 // Returns the list of active status icons so subclasses can operate on them. | 41 // Returns the list of active status icons so subclasses can operate on them. |
43 const StatusIconList& status_icons() { return status_icons_; } | 42 const StatusIcons& status_icons() const { return status_icons_; } |
44 | 43 |
45 private: | 44 private: |
46 FRIEND_TEST_ALL_PREFIXES(StatusTrayTest, CreateRemove); | 45 FRIEND_TEST_ALL_PREFIXES(StatusTrayTest, CreateRemove); |
47 | 46 |
48 // List containing all active StatusIcons. | 47 // List containing all active StatusIcons. The icons are owned by this |
49 StatusIconList status_icons_; | 48 // StatusTray. |
| 49 StatusIcons status_icons_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(StatusTray); | 51 DISALLOW_COPY_AND_ASSIGN(StatusTray); |
52 }; | 52 }; |
53 | 53 |
54 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ | 54 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |
OLD | NEW |