diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-06 22:02:04 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-06 22:02:04 +0000 |
commit | ccb55cf5b25fd67078e51b924cf6e694d7374376 (patch) | |
tree | b04cd09754ea2cdc2ee6d333166de81688a97c8e /chrome/browser/status_icons/status_tray.h | |
parent | 42695f09883e29aa167b79ad75263e3d611dce2d (diff) | |
download | chromium_src-ccb55cf5b25fd67078e51b924cf6e694d7374376.zip chromium_src-ccb55cf5b25fd67078e51b924cf6e694d7374376.tar.gz chromium_src-ccb55cf5b25fd67078e51b924cf6e694d7374376.tar.bz2 |
Initial implementation of status tray functionality (mac-only, currently).
Added Mac implementation of StatusIcon, and added a simple click callback that
displays the "extensions" tab when clicked on, to allow us to dogfood long-lived
extensions.
BUG=37375
Review URL: http://codereview.chromium.org/661454
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40847 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 | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/chrome/browser/status_icons/status_tray.h b/chrome/browser/status_icons/status_tray.h new file mode 100644 index 0000000..663bfa8 --- /dev/null +++ b/chrome/browser/status_icons/status_tray.h @@ -0,0 +1,47 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ +#define CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ + +#include "base/hash_tables.h" +#include "base/scoped_ptr.h" + +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(); + + // Gets the current status icon associated with this identifier, or creates + // a new one if none exists. The StatusTray retains ownership of the + // StatusIcon. Returns NULL if the status tray icon could not be created. + StatusIcon* GetStatusIcon(const string16& identifier); + + // Removes the current status icon associated with this identifier, if any. + void RemoveStatusIcon(const string16& identifier); + + private: + typedef base::hash_map<string16, StatusIcon*> StatusIconMap; + // 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_; +}; + +#endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ |