OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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/hash_tables.h" |
| 9 #include "base/scoped_ptr.h" |
| 10 |
| 11 class StatusIcon; |
| 12 |
| 13 // Factory interface for creating icons to improve testability. |
| 14 class StatusIconFactory { |
| 15 public: |
| 16 virtual StatusIcon* CreateIcon() = 0; |
| 17 virtual ~StatusIconFactory() { } |
| 18 }; |
| 19 |
| 20 // Provides a cross-platform interface to the system's status tray, and exposes |
| 21 // APIs to add/remove icons to the tray and attach context menus. |
| 22 class StatusTray { |
| 23 public: |
| 24 // Takes ownership of |factory|. |
| 25 explicit StatusTray(StatusIconFactory* factory); |
| 26 ~StatusTray(); |
| 27 |
| 28 // Gets the current status icon associated with this identifier, or creates |
| 29 // a new one if none exists. The StatusTray retains ownership of the |
| 30 // StatusIcon. Returns NULL if the status tray icon could not be created. |
| 31 StatusIcon* GetStatusIcon(const string16& identifier); |
| 32 |
| 33 // Removes the current status icon associated with this identifier, if any. |
| 34 void RemoveStatusIcon(const string16& identifier); |
| 35 |
| 36 private: |
| 37 typedef base::hash_map<string16, StatusIcon*> StatusIconMap; |
| 38 // Map containing all active StatusIcons. |
| 39 // Key: String identifiers (passed in to GetStatusIcon) |
| 40 // Value: The StatusIcon associated with that identifier (strong pointer - |
| 41 // StatusIcons are freed when the StatusTray destructor is called). |
| 42 StatusIconMap status_icons_; |
| 43 |
| 44 scoped_ptr<StatusIconFactory> factory_; |
| 45 }; |
| 46 |
| 47 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |
OLD | NEW |