| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/status_icons/status_tray.h" | 5 #include "chrome/browser/status_icons/status_tray.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util.h" |
| 10 #include "chrome/browser/status_icons/status_icon.h" | 10 #include "chrome/browser/status_icons/status_icon.h" |
| 11 | 11 |
| 12 StatusTray::StatusTray() { | 12 StatusTray::StatusTray() { |
| 13 } | 13 } |
| 14 | 14 |
| 15 StatusTray::~StatusTray() { | 15 StatusTray::~StatusTray() { |
| 16 RemoveAllIcons(); | 16 RemoveAllIcons(); |
| 17 } | 17 } |
| 18 | 18 |
| 19 void StatusTray::RemoveAllIcons() { | 19 void StatusTray::RemoveAllIcons() { |
| 20 STLDeleteElements(&status_icons_); | 20 STLDeleteElements(&status_icons_); |
| 21 } | 21 } |
| 22 | 22 |
| 23 StatusIcon* StatusTray::CreateStatusIcon() { | 23 StatusIcon* StatusTray::CreateStatusIcon() { |
| 24 StatusIcon* icon = CreatePlatformStatusIcon(); | 24 StatusIcon* icon = CreatePlatformStatusIcon(); |
| 25 if (icon) | 25 if (icon) |
| 26 status_icons_.push_back(icon); | 26 status_icons_.push_back(icon); |
| 27 return icon; | 27 return icon; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void StatusTray::RemoveStatusIcon(StatusIcon* icon) { | 30 void StatusTray::RemoveStatusIcon(StatusIcon* icon) { |
| 31 StatusIconList::iterator iter = std::find( | 31 StatusIconList::iterator iter = std::find( |
| 32 status_icons_.begin(), status_icons_.end(), icon); | 32 status_icons_.begin(), status_icons_.end(), icon); |
| 33 if (iter != status_icons_.end()) { | 33 if (iter != status_icons_.end()) { |
| 34 // Free the StatusIcon from the list. | 34 // Free the StatusIcon from the list. |
| 35 delete *iter; | 35 delete *iter; |
| 36 status_icons_.erase(iter); | 36 status_icons_.erase(iter); |
| 37 } | 37 } |
| 38 } | 38 } |
| OLD | NEW |