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 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 <memory> 9 #include <vector> 10 11 #include "base/macros.h" 12 #include "base/strings/string16.h" 13 14 namespace gfx { 15 class ImageSkia; 16 } 17 18 class StatusIcon; 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 enum StatusIconType { 25 NOTIFICATION_TRAY_ICON = 0, 26 MEDIA_STREAM_CAPTURE_ICON, 27 BACKGROUND_MODE_ICON, 28 OTHER_ICON, 29 NAMED_STATUS_ICON_COUNT 30 }; 31 32 // Static factory method that is implemented separately for each platform to 33 // produce the appropriate platform-specific instance. Returns NULL if this 34 // platform does not support status icons. 35 static std::unique_ptr<StatusTray> Create(); 36 37 virtual ~StatusTray(); 38 39 // Creates a new StatusIcon. The StatusTray retains ownership of the 40 // StatusIcon. Returns NULL if the StatusIcon could not be created. 41 StatusIcon* CreateStatusIcon(StatusIconType type, 42 const gfx::ImageSkia& image, 43 const base::string16& tool_tip); 44 45 // Removes |icon| from this status tray. 46 void RemoveStatusIcon(StatusIcon* icon); 47 48 protected: 49 using StatusIcons = std::vector<std::unique_ptr<StatusIcon>>; 50 51 StatusTray(); 52 53 // Factory method for creating a status icon for this platform. 54 virtual std::unique_ptr<StatusIcon> CreatePlatformStatusIcon( 55 StatusIconType type, 56 const gfx::ImageSkia& image, 57 const base::string16& tool_tip) = 0; 58 59 // Returns the list of active status icons so subclasses can operate on them. status_icons()60 const StatusIcons& status_icons() const { return status_icons_; } 61 62 private: 63 // List containing all active StatusIcons. The icons are owned by this 64 // StatusTray. 65 StatusIcons status_icons_; 66 67 DISALLOW_COPY_AND_ASSIGN(StatusTray); 68 }; 69 70 #endif // CHROME_BROWSER_STATUS_ICONS_STATUS_TRAY_H_ 71