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 #include "chrome/browser/status_icons/status_tray.h" 6 7 #include <algorithm> 8 9 #include "base/stl_util-inl.h" 10 #include "chrome/browser/status_icons/status_icon.h" 11 12 StatusTray::StatusTray() { 13 } 14 15 StatusTray::~StatusTray() { 16 RemoveAllIcons(); 17 } 18 19 void StatusTray::RemoveAllIcons() { 20 // Walk any active status icons and delete them. 21 STLDeleteContainerPointers(status_icons_.begin(), status_icons_.end()); 22 status_icons_.clear(); 23 } 24 25 StatusIcon* StatusTray::CreateStatusIcon() { 26 StatusIcon* icon = CreatePlatformStatusIcon(); 27 if (icon) 28 status_icons_.push_back(icon); 29 return icon; 30 } 31 32 void StatusTray::RemoveStatusIcon(StatusIcon* icon) { 33 StatusIconList::iterator iter = std::find( 34 status_icons_.begin(), status_icons_.end(), icon); 35 if (iter != status_icons_.end()) { 36 // Free the StatusIcon from the list. 37 delete *iter; 38 status_icons_.erase(iter); 39 } 40 } 41