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 #pragma once 8 9 #include <vector> 10 11 #include "base/basictypes.h" 12 #include "base/gtest_prod_util.h" 13 14 class StatusIcon; 15 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. 18 class StatusTray { 19 public: 20 // Static factory method that is implemented separately for each platform to 21 // produce the appropriate platform-specific instance. Returns NULL if this 22 // platform does not support status icons. 23 static StatusTray* Create(); 24 25 virtual ~StatusTray(); 26 27 // Creates a new StatusIcon. The StatusTray retains ownership of the 28 // StatusIcon. Returns NULL if the StatusIcon could not be created. 29 StatusIcon* CreateStatusIcon(); 30 31 // Removes the current status icon associated with this identifier, if any. 32 void RemoveStatusIcon(StatusIcon* icon); 33 34 protected: 35 StatusTray(); 36 // Factory method for creating a status icon for this platform. 37 virtual StatusIcon* CreatePlatformStatusIcon() = 0; 38 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. 45 const StatusIconList& status_icons() { return status_icons_; } 46 47 private: 48 FRIEND_TEST_ALL_PREFIXES(StatusTrayTest, CreateRemove); 49 50 // List containing all active StatusIcons. 51 StatusIconList status_icons_; 52 53 DISALLOW_COPY_AND_ASSIGN(StatusTray); 54 }; 55 56 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ 57