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

Unified Diff: chrome/browser/notifications/message_center_notification_manager.h

Issue 17286015: Adds a first-run balloon to the Windows notification center. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/message_center_notification_manager.h
diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h
index ae5fc9ad0e1c4e098c128d839817c872c93375c7..23ceecfb7456bf491eb7e7eef55aab8dfe40ad2b 100644
--- a/chrome/browser/notifications/message_center_notification_manager.h
+++ b/chrome/browser/notifications/message_center_notification_manager.h
@@ -9,6 +9,9 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_member.h"
+#include "base/timer.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/notifications/notification_ui_manager_impl.h"
@@ -18,19 +21,26 @@
class MessageCenterSettingsController;
class Notification;
+class PrefService;
class Profile;
// This class extends NotificationUIManagerImpl and delegates actual display
-// of notifications to MessageCenter, doing necessary conversions.
+// of notifications to MessageCenter, doing necessary conversions. Supports
+// weak pointers for reliable lifetime in timer callbacks.
class MessageCenterNotificationManager
: public NotificationUIManagerImpl,
public message_center::MessageCenter::Delegate,
- public message_center::MessageCenterObserver {
+ public message_center::MessageCenterObserver,
+ public base::SupportsWeakPtr<MessageCenterNotificationManager> {
Andrew T Wilson (Slow) 2013/06/19 06:28:57 Unless external classes need to be able to create
dewittj 2013/06/20 02:20:54 Done.
public:
explicit MessageCenterNotificationManager(
- message_center::MessageCenter* message_center);
+ message_center::MessageCenter* message_center,
+ PrefService* local_state);
virtual ~MessageCenterNotificationManager();
+ // Called when the pref changes for the first run balloon.
+ void DisplayFirstRunBalloon();
+
// NotificationUIManager
virtual bool DoesIdExist(const std::string& notification_id) OVERRIDE;
virtual bool CancelById(const std::string& notification_id) OVERRIDE;
@@ -59,6 +69,8 @@ class MessageCenterNotificationManager
virtual void OnNotificationRemoved(const std::string& notification_id,
bool by_user) OVERRIDE;
virtual void OnNotificationCenterClosed() OVERRIDE;
+ virtual void OnNotificationUpdated(const std::string& notification_id)
+ OVERRIDE;
private:
class ImageDownloadsObserver {
@@ -171,6 +183,19 @@ class MessageCenterNotificationManager
// notification is found.
ProfileNotification* FindProfileNotification(const std::string& id) const;
+ // This function is run on update to ensure that the notification balloon is
+ // shown only when there are no popups present.
+ void CheckFirstRunTimer();
+
+ // |first_run_pref_| is used to keep track of whether we've ever shown the
+ // first run balloon before, even across restarts.
+ BooleanPrefMember first_run_pref_;
+
+ // The timer after which we will show the first run balloon. This timer is
+ // restarted every time the message center is closed and every time the last
+ // popup disappears from the screen.
+ base::OneShotTimer<MessageCenterNotificationManager> first_run_balloon_timer_;
+
DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager);
};

Powered by Google App Engine
This is Rietveld 408576698