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

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: Fix test failures 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..b21eba4511fb96ba550bceabfc74ed8dce6495a0 100644
--- a/chrome/browser/notifications/message_center_notification_manager.h
+++ b/chrome/browser/notifications/message_center_notification_manager.h
@@ -9,6 +9,10 @@
#include <string>
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_member.h"
+#include "base/time.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,6 +22,7 @@
class MessageCenterSettingsController;
class Notification;
+class PrefService;
class Profile;
// This class extends NotificationUIManagerImpl and delegates actual display
@@ -28,9 +33,17 @@ class MessageCenterNotificationManager
public message_center::MessageCenterObserver {
public:
explicit MessageCenterNotificationManager(
- message_center::MessageCenter* message_center);
+ message_center::MessageCenter* message_center,
+ PrefService* local_state);
virtual ~MessageCenterNotificationManager();
+#if defined(OS_WIN)
+ // Called when the pref changes for the first run balloon. The first run
+ // balloon is only displayed on Windows, since the visibility of the tray
+ // icon is limited.
+ void DisplayFirstRunBalloon();
+#endif
+
// NotificationUIManager
virtual bool DoesIdExist(const std::string& notification_id) OVERRIDE;
virtual bool CancelById(const std::string& notification_id) OVERRIDE;
@@ -59,6 +72,13 @@ 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;
+
+ // Takes ownership of |delegate|.
+ void SetMessageCenterTrayDelegateForTest(
+ message_center::MessageCenterTrayDelegate* delegate);
+ void SetFirstRunTimeoutForTest(base::TimeDelta timeout);
private:
class ImageDownloadsObserver {
@@ -171,6 +191,28 @@ class MessageCenterNotificationManager
// notification is found.
ProfileNotification* FindProfileNotification(const std::string& id) const;
+#if defined(OS_WIN)
+ // This function is run on update to ensure that the notification balloon is
+ // shown only when there are no popups present.
+ void CheckFirstRunTimer();
+#endif
+
+ // |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_;
Andrew T Wilson (Slow) 2013/06/20 21:08:59 So all this stuff is windows-only -- can we #if th
dewittj 2013/06/21 21:56:51 Done.
+
+ // The first-run balloon will be shown |first_run_idle_timeout_| after all
+ // popups go away and the user has notifications in the message center.
+ base::TimeDelta first_run_idle_timeout_;
+
+ // Provides weak pointers for the purpose of the first run timer.
+ base::WeakPtrFactory<MessageCenterNotificationManager> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager);
};

Powered by Google App Engine
This is Rietveld 408576698