| OLD | NEW |
| 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 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // Overridden from ImageDownloadsObserver. | 174 // Overridden from ImageDownloadsObserver. |
| 175 virtual void OnDownloadsCompleted() OVERRIDE; | 175 virtual void OnDownloadsCompleted() OVERRIDE; |
| 176 | 176 |
| 177 Profile* profile() const { return profile_; } | 177 Profile* profile() const { return profile_; } |
| 178 const Notification& notification() const { return notification_; } | 178 const Notification& notification() const { return notification_; } |
| 179 | 179 |
| 180 // Returns extension_id if the notification originates from an extension, | 180 // Returns extension_id if the notification originates from an extension, |
| 181 // empty string otherwise. | 181 // empty string otherwise. |
| 182 std::string GetExtensionId(); | 182 std::string GetExtensionId(); |
| 183 | 183 |
| 184 // Route a new notification to an app/extension. |
| 185 void AddToAlternateProvider(const std::string extension_id); |
| 186 |
| 184 private: | 187 private: |
| 185 // Weak, guaranteed not to be used after profile removal by parent class. | 188 // Weak, guaranteed not to be used after profile removal by parent class. |
| 186 Profile* profile_; | 189 Profile* profile_; |
| 187 Notification notification_; | 190 Notification notification_; |
| 188 // Track the downloads for this notification so the notification can be | 191 // Track the downloads for this notification so the notification can be |
| 189 // updated properly. | 192 // updated properly. |
| 190 scoped_ptr<ImageDownloads> downloads_; | 193 scoped_ptr<ImageDownloads> downloads_; |
| 191 }; | 194 }; |
| 192 | 195 |
| 193 scoped_ptr<message_center::MessageCenterTrayDelegate> tray_; | 196 scoped_ptr<message_center::MessageCenterTrayDelegate> tray_; |
| 194 message_center::MessageCenter* message_center_; // Weak, global. | 197 message_center::MessageCenter* message_center_; // Weak, global. |
| 195 | 198 |
| 196 // Use a map by notification_id since this mapping is the most often used. | 199 // Use a map by notification_id since this mapping is the most often used. |
| 197 typedef std::map<std::string, ProfileNotification*> NotificationMap; | 200 typedef std::map<std::string, ProfileNotification*> NotificationMap; |
| 198 NotificationMap profile_notifications_; | 201 NotificationMap profile_notifications_; |
| 199 | 202 |
| 200 // Helpers that add/remove the notification from local map and MessageCenter. | 203 // Helpers that add/remove the notification from local map. |
| 201 // They take ownership of profile_notification object. | 204 // The local map takes ownership of profile_notification object. |
| 202 void AddProfileNotification(ProfileNotification* profile_notification); | 205 void AddProfileNotification(ProfileNotification* profile_notification); |
| 203 void RemoveProfileNotification(ProfileNotification* profile_notification); | 206 void RemoveProfileNotification(ProfileNotification* profile_notification); |
| 204 | 207 |
| 205 // Returns the ProfileNotification for the |id|, or NULL if no such | 208 // Returns the ProfileNotification for the |id|, or NULL if no such |
| 206 // notification is found. | 209 // notification is found. |
| 207 ProfileNotification* FindProfileNotification(const std::string& id) const; | 210 ProfileNotification* FindProfileNotification(const std::string& id) const; |
| 208 | 211 |
| 212 // Get the extension ID of the extension that the user chose to take over |
| 213 // Chorme Notification Center. |
| 214 std::string GetExtensionTakingOverNotifications(Profile* profile); |
| 215 |
| 209 #if defined(OS_WIN) | 216 #if defined(OS_WIN) |
| 210 // This function is run on update to ensure that the notification balloon is | 217 // This function is run on update to ensure that the notification balloon is |
| 211 // shown only when there are no popups present. | 218 // shown only when there are no popups present. |
| 212 void CheckFirstRunTimer(); | 219 void CheckFirstRunTimer(); |
| 213 | 220 |
| 214 // |first_run_pref_| is used to keep track of whether we've ever shown the | 221 // |first_run_pref_| is used to keep track of whether we've ever shown the |
| 215 // first run balloon before, even across restarts. | 222 // first run balloon before, even across restarts. |
| 216 BooleanPrefMember first_run_pref_; | 223 BooleanPrefMember first_run_pref_; |
| 217 | 224 |
| 218 // The timer after which we will show the first run balloon. This timer is | 225 // The timer after which we will show the first run balloon. This timer is |
| (...skipping 22 matching lines...) Expand all Loading... |
| 241 // Keeps track of all notification statistics for UMA purposes. | 248 // Keeps track of all notification statistics for UMA purposes. |
| 242 MessageCenterStatsCollector stats_collector_; | 249 MessageCenterStatsCollector stats_collector_; |
| 243 | 250 |
| 244 // Keeps track of notifications specific to Google Now for UMA purposes. | 251 // Keeps track of notifications specific to Google Now for UMA purposes. |
| 245 GoogleNowNotificationStatsCollector google_now_stats_collector_; | 252 GoogleNowNotificationStatsCollector google_now_stats_collector_; |
| 246 | 253 |
| 247 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); | 254 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); |
| 248 }; | 255 }; |
| 249 | 256 |
| 250 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ | 257 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |