Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / balloon_collection_base.h
blob89f33414caf6de55aa7078b153d30d99f7946a83
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.
5 // Handles the visible notification (or balloons).
7 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_
8 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_
10 #include <deque>
11 #include <string>
13 #include "base/basictypes.h"
15 class Balloon;
16 class GURL;
17 class Notification;
18 class Profile;
20 // This class provides support for implementing a BalloonCollection
21 // including the parts common between Chrome UI and ChromeOS UI.
22 class BalloonCollectionBase {
23 public:
24 BalloonCollectionBase();
25 virtual ~BalloonCollectionBase();
27 typedef std::deque<Balloon*> Balloons;
29 // Adds a balloon to the collection. Takes ownership of pointer.
30 virtual void Add(Balloon* balloon, bool add_to_front);
32 // Removes a balloon from the collection (if present). Frees
33 // the pointer after removal.
34 virtual void Remove(Balloon* balloon);
36 // Returns true if any balloon matches the given notification id.
37 virtual const Notification* FindById(const std::string& id) const;
39 // Finds any balloon matching the given notification id, and
40 // calls CloseByScript on it. Returns true if anything was
41 // found.
42 virtual bool CloseById(const std::string& id);
44 // Finds all balloons matching the given notification source,
45 // and calls CloseByScript on them. Returns true if anything
46 // was found.
47 virtual bool CloseAllBySourceOrigin(const GURL& source_origin);
49 // Finds all balloons matching the given profile and calls CloseByScript
50 // on them. Returns true if anything was found.
51 virtual bool CloseAllByProfile(Profile* profile);
53 // Calls CloseByScript on all balloons.
54 virtual void CloseAll();
56 const Balloons& balloons() const { return balloons_; }
58 // Returns the balloon matching the given notification id, or
59 // NULL if there is no matching balloon.
60 Balloon* FindBalloonById(const std::string& notification_id);
62 // Returns the balloon matching the given notification, or
63 // NULL if there is no matching balloon.
64 Balloon* FindBalloon(const Notification& notification);
66 // The number of balloons being displayed.
67 int count() const { return static_cast<int>(balloons_.size()); }
69 private:
70 // Queue of active balloons. Pointers are owned by this class.
71 Balloons balloons_;
73 DISALLOW_COPY_AND_ASSIGN(BalloonCollectionBase);
76 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_