Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 // Handles the visible notification (or balloons). | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | |
| 8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | |
| 9 #pragma once | |
| 10 | |
| 11 #include <deque> | |
| 12 #include <string> | |
| 13 | |
| 14 #include "chrome/browser/notifications/balloon.h" | |
|
oshima
2010/11/11 19:00:17
looks like forward decl is enough?
John Gregg
2010/11/11 23:17:46
Done.
| |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 // This class provides support for implementing a BalloonCollection | |
| 19 // including the parts common between Chrome UI and ChromeOS UI. | |
| 20 class BalloonCollectionBase { | |
| 21 public: | |
| 22 BalloonCollectionBase(); | |
| 23 virtual ~BalloonCollectionBase(); | |
| 24 | |
| 25 typedef std::deque<Balloon*> Balloons; | |
| 26 | |
| 27 // Adds a balloon to the collection. Takes ownership of pointer. | |
| 28 virtual void Add(Balloon* balloon); | |
| 29 | |
| 30 // Removes a balloon from the collection (if present). Frees | |
| 31 // the pointer after removal. | |
| 32 virtual void Remove(Balloon* balloon); | |
| 33 | |
| 34 // Finds any balloon matching the given notification id, and | |
| 35 // calls CloseByScript on it. Returns true if anything was | |
| 36 // found. | |
| 37 virtual bool CloseById(const std::string& id); | |
| 38 | |
| 39 // Finds all balloons matching the given notification source, | |
| 40 // and calls CloseByScript on them. Returns true if anything | |
| 41 // was found. | |
| 42 virtual bool CloseAllBySourceOrigin(const GURL& source_origin); | |
| 43 | |
| 44 const Balloons& balloons() const { return balloons_; } | |
| 45 | |
| 46 // Returns the balloon matching the given notification, or | |
| 47 // NULL if there is no matching balloon. | |
| 48 Balloon* FindBalloon(const Notification& notification); | |
| 49 | |
| 50 // The number of balloons being displayed. | |
| 51 int count() const { return static_cast<int>(balloons_.size()); } | |
| 52 | |
| 53 private: | |
| 54 // Queue of active balloons. Pointers are owned by this class. | |
| 55 Balloons balloons_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionBase); | |
| 58 }; | |
| 59 | |
| 60 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | |
| OLD | NEW |