Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 | 13 |
| 14 class StatusIcon; | 14 class StatusIcon; |
| 15 | 15 |
| 16 // Provides a cross-platform interface to the system's status tray, and exposes | 16 // 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. | 17 // APIs to add/remove icons to the tray and attach context menus. |
| 18 class StatusTray { | 18 class StatusTray { |
| 19 public: | 19 public: |
| 20 // Static factory method that is implemented separately for each platform to | 20 // Static factory method that is implemented separately for each platform to |
| 21 // produce the appropriate platform-specific instance. Returns NULL if this | 21 // produce the appropriate platform-specific instance. Returns NULL if this |
| 22 // platform does not support status icons. | 22 // platform does not support status icons. |
| 23 static StatusTray* Create(); | 23 static StatusTray* Create(); |
| 24 | 24 |
| 25 virtual ~StatusTray(); | 25 virtual ~StatusTray(); |
| 26 | 26 |
| 27 // Creates a new StatusIcon. The StatusTray retains ownership of the | 27 // Creates a new StatusIcon. The StatusTray retains ownership of the |
| 28 // StatusIcon. Returns NULL if the StatusIcon could not be created. | 28 // StatusIcon. Returns NULL if the StatusIcon could not be created. |
| 29 StatusIcon* CreateStatusIcon(); | 29 StatusIcon* CreateStatusIcon(); |
| 30 | 30 |
| 31 // Removes the current status icon associated with this identifier, if any. | 31 // Removes the current status icon associated with this identifier, if any. |
|
Andrew T Wilson (Slow)
2012/04/20 19:13:09
Since we're changing RemoveStatusIcon(), we should
tfarina
2012/04/20 19:24:13
Done.
| |
| 32 void RemoveStatusIcon(StatusIcon* icon); | 32 void RemoveStatusIcon(StatusIcon* icon); |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 typedef std::vector<StatusIcon*> StatusIconList; | |
| 36 | |
| 35 StatusTray(); | 37 StatusTray(); |
| 38 | |
| 36 // Factory method for creating a status icon for this platform. | 39 // Factory method for creating a status icon for this platform. |
| 37 virtual StatusIcon* CreatePlatformStatusIcon() = 0; | 40 virtual StatusIcon* CreatePlatformStatusIcon() = 0; |
| 38 | 41 |
| 39 // Removes all StatusIcons (used by derived classes to clean up in case they | |
| 40 // track external state used by the StatusIcons). | |
| 41 void RemoveAllIcons(); | |
| 42 | |
| 43 typedef std::vector<StatusIcon*> StatusIconList; | |
| 44 // Returns the list of active status icons so subclasses can operate on them. | 42 // Returns the list of active status icons so subclasses can operate on them. |
| 45 const StatusIconList& status_icons() { return status_icons_; } | 43 const StatusIconList& status_icons() { return status_icons_; } |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 FRIEND_TEST_ALL_PREFIXES(StatusTrayTest, CreateRemove); | 46 FRIEND_TEST_ALL_PREFIXES(StatusTrayTest, CreateRemove); |
| 49 | 47 |
| 50 // List containing all active StatusIcons. | 48 // List containing all active StatusIcons. |
| 51 StatusIconList status_icons_; | 49 StatusIconList status_icons_; |
| 52 | 50 |
| 53 DISALLOW_COPY_AND_ASSIGN(StatusTray); | 51 DISALLOW_COPY_AND_ASSIGN(StatusTray); |
| 54 }; | 52 }; |
| 55 | 53 |
| 56 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ | 54 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |
| OLD | NEW |