 Chromium Code Reviews
 Chromium Code Reviews Issue 4635007:
  When an extension is uninstalled, close all desktop notifications from that e...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 4635007:
  When an extension is uninstalled, close all desktop notifications from that e...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| Index: chrome/browser/notifications/balloon_collection_base.h | 
| =================================================================== | 
| --- chrome/browser/notifications/balloon_collection_base.h (revision 0) | 
| +++ chrome/browser/notifications/balloon_collection_base.h (revision 0) | 
| @@ -0,0 +1,61 @@ | 
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +// Handles the visible notification (or balloons). | 
| + | 
| +#ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | 
| +#define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ | 
| +#pragma once | 
| + | 
| +#include <deque> | 
| +#include <string> | 
| + | 
| +#include "base/stl_util-inl.h" | 
| +#include "chrome/browser/notifications/balloon.h" | 
| + | 
| +class GURL; | 
| + | 
| +// This class implements a basic BalloonCollection with the parts | 
| +// shared between Chrome UI and ChromeOS UI. Some methods are | 
| +// still pure virtual which need to be implemented by the particular | 
| +// UI implementation. | 
| +class BalloonCollectionBase { | 
| + public: | 
| + BalloonCollectionBase(); | 
| + virtual ~BalloonCollectionBase(); | 
| + | 
| + typedef std::deque<Balloon*> Balloons; | 
| + | 
| + // Adds a balloon to the collection. Takes ownership of pointer. | 
| + virtual void Add(Balloon* balloon); | 
| + | 
| + // Removes a balloon from the collection (if present). Frees | 
| + // the pointer after removal. | 
| + virtual void Remove(Balloon* balloon); | 
| + | 
| + // Finds any balloon matching the given notification id, and | 
| + // calls CloseByScript on it. | 
| 
Andrew T Wilson (Slow)
2010/11/11 01:07:44
Does this remove it from the array (I'm guessing s
 
John Gregg
2010/11/11 18:13:51
No, this comment is precise (just calls CloseByScr
 | 
| + virtual bool CloseById(const std::string& id); | 
| + | 
| + // Removes all balloons matching the given notification source, | 
| + // and calls CloseByScript on them. | 
| + virtual bool CloseAllBySourceOrigin(const GURL& source_origin); | 
| 
Andrew T Wilson (Slow)
2010/11/11 01:07:44
Should document the return value.
 
John Gregg
2010/11/11 18:13:51
Done.
 | 
| + | 
| + const Balloons& balloons() const { return balloons_; } | 
| + | 
| + // Returns the balloon matching the given notification. | 
| 
Andrew T Wilson (Slow)
2010/11/11 01:07:44
Should we document that FindBalloon() returns NULL
 
John Gregg
2010/11/11 18:13:51
Done.
 | 
| + Balloon* FindBalloon(const Notification& notification); | 
| + | 
| + // The number of balloons being displayed. | 
| + int count() const { return balloons_.size(); } | 
| + | 
| + private: | 
| + // Queue of active balloons. These pointers are non-owned, and | 
| + // must be managed by the caller of this class. | 
| 
Andrew T Wilson (Slow)
2010/11/11 01:07:44
It's not clear to me how to reconcile this comment
 
John Gregg
2010/11/11 18:13:51
Yeah, stale comment.  Fixed.
 | 
| + Balloons balloons_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(BalloonCollectionBase); | 
| +}; | 
| + | 
| +#endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_BASE_H_ |