diff options
author | atwilson@google.com <atwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 21:29:05 +0000 |
---|---|---|
committer | atwilson@google.com <atwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-24 21:29:05 +0000 |
commit | a24642a800c1712eeaa791f0fb0ed1527885c6fb (patch) | |
tree | 925671bf6414abcc8da68cd48a6085fa0007dd6b /chrome/browser/status_icons/status_tray.h | |
parent | 45e9bcaa8bd6ff0eb2bf61d7100b1faacd2ccef4 (diff) | |
download | chromium_src-a24642a800c1712eeaa791f0fb0ed1527885c6fb.zip chromium_src-a24642a800c1712eeaa791f0fb0ed1527885c6fb.tar.gz chromium_src-a24642a800c1712eeaa791f0fb0ed1527885c6fb.tar.bz2 |
Implement status icons on windows.
Refactor existing status icon code to allow platform-specific StatusTray implementation to
track common state for all status icons.
BUG=37375
TEST=new unit tests
Review URL: http://codereview.chromium.org/1136005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42538 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/status_icons/status_tray.h')
-rw-r--r-- | chrome/browser/status_icons/status_tray.h | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/chrome/browser/status_icons/status_tray.h b/chrome/browser/status_icons/status_tray.h index 663bfa8..30a60aa 100644 --- a/chrome/browser/status_icons/status_tray.h +++ b/chrome/browser/status_icons/status_tray.h @@ -10,20 +10,15 @@ class StatusIcon; -// Factory interface for creating icons to improve testability. -class StatusIconFactory { - public: - virtual StatusIcon* CreateIcon() = 0; - virtual ~StatusIconFactory() { } -}; - // Provides a cross-platform interface to the system's status tray, and exposes // APIs to add/remove icons to the tray and attach context menus. class StatusTray { public: - // Takes ownership of |factory|. - explicit StatusTray(StatusIconFactory* factory); - ~StatusTray(); + // Static factory method that is implemented separately for each platform to + // produce the appropriate platform-specific instance. + static StatusTray* Create(); + + virtual ~StatusTray(); // Gets the current status icon associated with this identifier, or creates // a new one if none exists. The StatusTray retains ownership of the @@ -33,15 +28,27 @@ class StatusTray { // Removes the current status icon associated with this identifier, if any. void RemoveStatusIcon(const string16& identifier); - private: + protected: + StatusTray(); + // Factory method for creating a status icon. + virtual StatusIcon* CreateStatusIcon() = 0; + + // Removes all StatusIcons (used by derived classes to clean up in case they + // track external state used by the StatusIcons). + void RemoveAllIcons(); + typedef base::hash_map<string16, StatusIcon*> StatusIconMap; + // Returns the list of active status icons so subclasses can operate on them. + const StatusIconMap& status_icons() { return status_icons_; } + + private: // Map containing all active StatusIcons. // Key: String identifiers (passed in to GetStatusIcon) // Value: The StatusIcon associated with that identifier (strong pointer - // StatusIcons are freed when the StatusTray destructor is called). StatusIconMap status_icons_; - scoped_ptr<StatusIconFactory> factory_; + DISALLOW_COPY_AND_ASSIGN(StatusTray); }; #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |