summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/notification_ui_manager.h
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 03:44:03 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-30 03:44:03 +0000
commit29672abd046612aa325fcfc0e69e1cc4d91c299c (patch)
treeb20163ccfd4ed8711f9d69c7b00bbce949b8acd4 /chrome/browser/notifications/notification_ui_manager.h
parent574de276b0b39820961f7cf03cf23e0389878a4a (diff)
downloadchromium_src-29672abd046612aa325fcfc0e69e1cc4d91c299c.zip
chromium_src-29672abd046612aa325fcfc0e69e1cc4d91c299c.tar.gz
chromium_src-29672abd046612aa325fcfc0e69e1cc4d91c299c.tar.bz2
Connect the various pieces for notifications... hook up NotificationUIManager to BrowserProcess to DesktopNotificationService to RenderView.
BUG=none TEST=none Review URL: http://codereview.chromium.org/342043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/notification_ui_manager.h')
-rw-r--r--chrome/browser/notifications/notification_ui_manager.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/chrome/browser/notifications/notification_ui_manager.h b/chrome/browser/notifications/notification_ui_manager.h
new file mode 100644
index 0000000..192058f
--- /dev/null
+++ b/chrome/browser/notifications/notification_ui_manager.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 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.
+
+#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
+#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_
+
+#include <deque>
+
+#include "base/id_map.h"
+#include "base/scoped_ptr.h"
+#include "chrome/browser/notifications/balloon.h"
+#include "chrome/browser/notifications/balloon_collection.h"
+
+class Notification;
+class Profile;
+class QueuedNotification;
+class SiteInstance;
+
+// The notification manager manages use of the desktop for notifications.
+// It maintains a queue of pending notifications when space becomes constrained.
+class NotificationUIManager :
+ public BalloonCollectionImpl::BalloonSpaceChangeListener {
+ public:
+ NotificationUIManager();
+ virtual ~NotificationUIManager();
+
+ // Creates an initialized UI manager with a new balloon collection
+ // and the listener relationship setup.
+ // Except for unit tests, this is the way to construct the object.
+ static NotificationUIManager* Create();
+
+ // Initializes the UI manager with a balloon collection; this object
+ // takes ownership of the balloon collection.
+ void Initialize(BalloonCollection* balloon_collection) {
+ DCHECK(!balloon_collection_.get());
+ DCHECK(balloon_collection);
+ balloon_collection_.reset(balloon_collection);
+ }
+
+ // Adds a notification to be displayed. Virtual for unit test override.
+ virtual void Add(const Notification& notification,
+ Profile* profile);
+
+ private:
+ // Attempts to display notifications from the show_queue if the user
+ // is active.
+ void CheckAndShowNotifications();
+
+ // Attempts to display notifications from the show_queue.
+ void ShowNotifications();
+
+ // BalloonCollectionObserver implementation.
+ virtual void OnBalloonSpaceChanged();
+
+ // An owned pointer to the collection of active balloons.
+ scoped_ptr<BalloonCollection> balloon_collection_;
+
+ // A queue of notifications which are waiting to be shown.
+ typedef std::deque<QueuedNotification*> NotificationDeque;
+ NotificationDeque show_queue_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationUIManager);
+};
+
+#endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_H_