Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/notifications/notification_ui_manager.h

Issue 5319011: Listen for APP_TERMINATING in notification ui; close windows earlier in the p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <deque> 9 #include <deque>
10 #include <string> 10 #include <string>
11 11
12 #include "base/id_map.h" 12 #include "base/id_map.h"
13 #include "base/scoped_ptr.h" 13 #include "base/scoped_ptr.h"
14 #include "chrome/browser/notifications/balloon.h" 14 #include "chrome/browser/notifications/balloon.h"
15 #include "chrome/browser/notifications/balloon_collection.h" 15 #include "chrome/browser/notifications/balloon_collection.h"
16 #include "chrome/common/notification_observer.h"
17 #include "chrome/common/notification_registrar.h"
16 18
17 class Notification; 19 class Notification;
18 class Profile; 20 class Profile;
19 class QueuedNotification; 21 class QueuedNotification;
20 class SiteInstance; 22 class SiteInstance;
21 23
22 // The notification manager manages use of the desktop for notifications. 24 // The notification manager manages use of the desktop for notifications.
23 // It maintains a queue of pending notifications when space becomes constrained. 25 // It maintains a queue of pending notifications when space becomes constrained.
24 class NotificationUIManager 26 class NotificationUIManager
25 : public BalloonCollection::BalloonSpaceChangeListener { 27 : public BalloonCollection::BalloonSpaceChangeListener,
28 public NotificationObserver {
26 public: 29 public:
27 NotificationUIManager(); 30 NotificationUIManager();
28 virtual ~NotificationUIManager(); 31 virtual ~NotificationUIManager();
29 32
30 // Creates an initialized UI manager with a new balloon collection 33 // Creates an initialized UI manager with a new balloon collection
31 // and the listener relationship setup. 34 // and the listener relationship setup.
32 // Except for unit tests, this is the way to construct the object. 35 // Except for unit tests, this is the way to construct the object.
33 static NotificationUIManager* Create(); 36 static NotificationUIManager* Create();
34 37
35 // Initializes the UI manager with a balloon collection; this object 38 // Initializes the UI manager with a balloon collection; this object
(...skipping 10 matching lines...) Expand all
46 49
47 // Removes any notifications matching the supplied ID, either currently 50 // Removes any notifications matching the supplied ID, either currently
48 // displayed or in the queue. Returns true if anything was removed. 51 // displayed or in the queue. Returns true if anything was removed.
49 virtual bool CancelById(const std::string& notification_id); 52 virtual bool CancelById(const std::string& notification_id);
50 53
51 // Removes any notifications matching the supplied source origin 54 // Removes any notifications matching the supplied source origin
52 // (which could be an extension ID), either currently displayed or in the 55 // (which could be an extension ID), either currently displayed or in the
53 // queue. Returns true if anything was removed. 56 // queue. Returns true if anything was removed.
54 virtual bool CancelAllBySourceOrigin(const GURL& source_origin); 57 virtual bool CancelAllBySourceOrigin(const GURL& source_origin);
55 58
59 // Cancels all pending notifications and closes anything currently showing.
60 // Used when the app is terminating.
61 void CancelAll();
62
56 // Returns balloon collection. 63 // Returns balloon collection.
57 BalloonCollection* balloon_collection() { 64 BalloonCollection* balloon_collection() {
58 return balloon_collection_.get(); 65 return balloon_collection_.get();
59 } 66 }
60 67
68 // NotificationObserver interface (the event signaling kind of notifications)
69 virtual void Observe(NotificationType type,
70 const NotificationSource& source,
71 const NotificationDetails& details);
72
61 private: 73 private:
62 // Attempts to display notifications from the show_queue if the user 74 // Attempts to display notifications from the show_queue if the user
63 // is active. 75 // is active.
64 void CheckAndShowNotifications(); 76 void CheckAndShowNotifications();
65 77
66 // Attempts to display notifications from the show_queue. 78 // Attempts to display notifications from the show_queue.
67 void ShowNotifications(); 79 void ShowNotifications();
68 80
69 // BalloonCollectionObserver implementation. 81 // BalloonCollectionObserver implementation.
70 virtual void OnBalloonSpaceChanged(); 82 virtual void OnBalloonSpaceChanged();
71 83
72 // Replace an existing notification with this one if applicable; 84 // Replace an existing notification with this one if applicable;
73 // returns true if the replacement happened. 85 // returns true if the replacement happened.
74 bool TryReplacement(const Notification& notification); 86 bool TryReplacement(const Notification& notification);
75 87
76 // An owned pointer to the collection of active balloons. 88 // An owned pointer to the collection of active balloons.
77 scoped_ptr<BalloonCollection> balloon_collection_; 89 scoped_ptr<BalloonCollection> balloon_collection_;
78 90
79 // A queue of notifications which are waiting to be shown. 91 // A queue of notifications which are waiting to be shown.
80 typedef std::deque<QueuedNotification*> NotificationDeque; 92 typedef std::deque<QueuedNotification*> NotificationDeque;
81 NotificationDeque show_queue_; 93 NotificationDeque show_queue_;
82 94
95 // Registrar for the other kind of notifications (event signaling).
96 NotificationRegistrar registrar_;
97
83 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager); 98 DISALLOW_COPY_AND_ASSIGN(NotificationUIManager);
84 }; 99 };
85 100
86 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_ 101 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698