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