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

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

Issue 1334363002: [Eraser] First pass at removing the notification center panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: peter comments Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/prefs/pref_member.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
17 #include "chrome/browser/notifications/google_now_notification_stats_collector.h " 16 #include "chrome/browser/notifications/google_now_notification_stats_collector.h "
18 #include "chrome/browser/notifications/message_center_stats_collector.h" 17 #include "chrome/browser/notifications/message_center_stats_collector.h"
19 #include "chrome/browser/notifications/notification.h" 18 #include "chrome/browser/notifications/notification.h"
20 #include "chrome/browser/notifications/notification_system_observer.h" 19 #include "chrome/browser/notifications/notification_system_observer.h"
21 #include "chrome/browser/notifications/notification_ui_manager.h" 20 #include "chrome/browser/notifications/notification_ui_manager.h"
22 #include "ui/message_center/message_center.h" 21 #include "ui/message_center/message_center.h"
23 #include "ui/message_center/message_center_observer.h" 22 #include "ui/message_center/message_center_observer.h"
24 #include "ui/message_center/message_center_tray_delegate.h" 23 #include "ui/message_center/message_center_tray_delegate.h"
25 #include "ui/message_center/message_center_types.h" 24 #include "ui/message_center/message_center_types.h"
26 25
27 class MessageCenterSettingsController; 26 class MessageCenterSettingsController;
28 class Notification; 27 class Notification;
29 class PrefRegistrySimple;
30 class PrefService;
31 class Profile; 28 class Profile;
32 class ProfileNotification; 29 class ProfileNotification;
33 30
34 namespace message_center { 31 namespace message_center {
35 class NotificationBlocker; 32 class NotificationBlocker;
36 FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManuallyCloseMessageCenter); 33 FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManuallyCloseMessageCenter);
37 } 34 }
38 35
39 // This class extends NotificationUIManagerImpl and delegates actual display 36 // This class extends NotificationUIManagerImpl and delegates actual display
40 // of notifications to MessageCenter, doing necessary conversions. 37 // of notifications to MessageCenter, doing necessary conversions.
41 class MessageCenterNotificationManager 38 class MessageCenterNotificationManager
42 : public NotificationUIManager, 39 : public NotificationUIManager,
43 public message_center::MessageCenterObserver { 40 public message_center::MessageCenterObserver {
44 public: 41 public:
45 MessageCenterNotificationManager( 42 MessageCenterNotificationManager(
46 message_center::MessageCenter* message_center, 43 message_center::MessageCenter* message_center,
47 PrefService* local_state,
48 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider); 44 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider);
49 ~MessageCenterNotificationManager() override; 45 ~MessageCenterNotificationManager() override;
50 46
51 // Registers preferences.
52 static void RegisterPrefs(PrefRegistrySimple* registry);
53
54 // NotificationUIManager 47 // NotificationUIManager
55 void Add(const Notification& notification, Profile* profile) override; 48 void Add(const Notification& notification, Profile* profile) override;
56 bool Update(const Notification& notification, Profile* profile) override; 49 bool Update(const Notification& notification, Profile* profile) override;
57 const Notification* FindById(const std::string& delegate_id, 50 const Notification* FindById(const std::string& delegate_id,
58 ProfileID profile_id) const override; 51 ProfileID profile_id) const override;
59 bool CancelById(const std::string& delegate_id, 52 bool CancelById(const std::string& delegate_id,
60 ProfileID profile_id) override; 53 ProfileID profile_id) override;
61 std::set<std::string> GetAllIdsByProfileAndSourceOrigin( 54 std::set<std::string> GetAllIdsByProfileAndSourceOrigin(
62 ProfileID profile_id, 55 ProfileID profile_id,
63 const GURL& source) override; 56 const GURL& source) override;
64 std::set<std::string> GetAllIdsByProfile(ProfileID profile_id) override; 57 std::set<std::string> GetAllIdsByProfile(ProfileID profile_id) override;
65 bool CancelAllBySourceOrigin(const GURL& source_origin) override; 58 bool CancelAllBySourceOrigin(const GURL& source_origin) override;
66 bool CancelAllByProfile(ProfileID profile_id) override; 59 bool CancelAllByProfile(ProfileID profile_id) override;
67 void CancelAll() override; 60 void CancelAll() override;
68 61
69 // MessageCenterObserver 62 // MessageCenterObserver
70 void OnNotificationRemoved(const std::string& notification_id, 63 void OnNotificationRemoved(const std::string& notification_id,
71 bool by_user) override; 64 bool by_user) override;
72 void OnCenterVisibilityChanged(message_center::Visibility) override; 65 void OnCenterVisibilityChanged(message_center::Visibility) override;
73 void OnNotificationUpdated(const std::string& notification_id) override; 66 void OnNotificationUpdated(const std::string& notification_id) override;
74 67
75 void EnsureMessageCenterClosed(); 68 void EnsureMessageCenterClosed();
76 69
77 #if defined(OS_WIN)
78 // Called when the pref changes for the first run balloon. The first run
79 // balloon is only displayed on Windows, since the visibility of the tray
80 // icon is limited.
81 void DisplayFirstRunBalloon();
82
83 void SetFirstRunTimeoutForTest(base::TimeDelta timeout);
84 bool FirstRunTimerIsActive() const;
85 #endif
86
87 // Takes ownership of |delegate|. 70 // Takes ownership of |delegate|.
88 void SetMessageCenterTrayDelegateForTest( 71 void SetMessageCenterTrayDelegateForTest(
89 message_center::MessageCenterTrayDelegate* delegate); 72 message_center::MessageCenterTrayDelegate* delegate);
90 73
91 // Returns the notification id which this manager will use to add to message 74 // Returns the notification id which this manager will use to add to message
92 // center, for this combination of delegate id and profile. 75 // center, for this combination of delegate id and profile.
93 std::string GetMessageCenterNotificationIdForTest( 76 std::string GetMessageCenterNotificationIdForTest(
94 const std::string& delegate_id, Profile* profile); 77 const std::string& delegate_id, Profile* profile);
95 78
96 private: 79 private:
(...skipping 19 matching lines...) Expand all
116 void RemoveProfileNotification(ProfileNotification* profile_notification); 99 void RemoveProfileNotification(ProfileNotification* profile_notification);
117 100
118 // Returns the ProfileNotification for the |id|, or NULL if no such 101 // Returns the ProfileNotification for the |id|, or NULL if no such
119 // notification is found. 102 // notification is found.
120 ProfileNotification* FindProfileNotification(const std::string& id) const; 103 ProfileNotification* FindProfileNotification(const std::string& id) const;
121 104
122 // Get the extension ID of the extension that the user chose to take over 105 // Get the extension ID of the extension that the user chose to take over
123 // Chorme Notification Center. 106 // Chorme Notification Center.
124 std::string GetExtensionTakingOverNotifications(Profile* profile); 107 std::string GetExtensionTakingOverNotifications(Profile* profile);
125 108
126 #if defined(OS_WIN)
127 // This function is run on update to ensure that the notification balloon is
128 // shown only when there are no popups present.
129 void CheckFirstRunTimer();
130
131 // |first_run_pref_| is used to keep track of whether we've ever shown the
132 // first run balloon before, even across restarts.
133 BooleanPrefMember first_run_pref_;
134
135 // The timer after which we will show the first run balloon. This timer is
136 // restarted every time the message center is closed and every time the last
137 // popup disappears from the screen.
138 base::OneShotTimer<MessageCenterNotificationManager> first_run_balloon_timer_;
139
140 // The first-run balloon will be shown |first_run_idle_timeout_| after all
141 // popups go away and the user has notifications in the message center.
142 base::TimeDelta first_run_idle_timeout_;
143 #endif
144
145 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider_; 109 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider_;
146 110
147 // To own the blockers. 111 // To own the blockers.
148 ScopedVector<message_center::NotificationBlocker> blockers_; 112 ScopedVector<message_center::NotificationBlocker> blockers_;
149 113
150 NotificationSystemObserver system_observer_; 114 NotificationSystemObserver system_observer_;
151 115
152 // Keeps track of all notification statistics for UMA purposes. 116 // Keeps track of all notification statistics for UMA purposes.
153 MessageCenterStatsCollector stats_collector_; 117 MessageCenterStatsCollector stats_collector_;
154 118
155 // Keeps track of notifications specific to Google Now for UMA purposes. 119 // Keeps track of notifications specific to Google Now for UMA purposes.
156 GoogleNowNotificationStatsCollector google_now_stats_collector_; 120 GoogleNowNotificationStatsCollector google_now_stats_collector_;
157 121
158 #if defined(OS_WIN)
159 // Provides weak pointers for the purpose of the first run timer.
160 base::WeakPtrFactory<MessageCenterNotificationManager> weak_factory_;
161 #endif
162
163 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); 122 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager);
164 }; 123 };
165 124
166 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ 125 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698