| 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 |
| 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" | 14 #include "base/prefs/pref_member.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "chrome/browser/notifications/google_now_notification_stats_collector.h
" | 17 #include "chrome/browser/notifications/google_now_notification_stats_collector.h
" |
| 18 #include "chrome/browser/notifications/message_center_stats_collector.h" | 18 #include "chrome/browser/notifications/message_center_stats_collector.h" |
| 19 #include "chrome/browser/notifications/notification.h" | 19 #include "chrome/browser/notifications/notification.h" |
| 20 #include "chrome/browser/notifications/notification_system_observer.h" | 20 #include "chrome/browser/notifications/notification_system_observer.h" |
| 21 #include "chrome/browser/notifications/notification_ui_manager.h" | 21 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 22 #include "content/public/browser/notification_observer.h" | |
| 23 #include "content/public/browser/notification_registrar.h" | |
| 24 #include "ui/message_center/message_center.h" | 22 #include "ui/message_center/message_center.h" |
| 25 #include "ui/message_center/message_center_observer.h" | 23 #include "ui/message_center/message_center_observer.h" |
| 26 #include "ui/message_center/message_center_tray_delegate.h" | 24 #include "ui/message_center/message_center_tray_delegate.h" |
| 27 #include "ui/message_center/message_center_types.h" | 25 #include "ui/message_center/message_center_types.h" |
| 28 | 26 |
| 29 class MessageCenterSettingsController; | 27 class MessageCenterSettingsController; |
| 30 class Notification; | 28 class Notification; |
| 31 class PrefRegistrySimple; | 29 class PrefRegistrySimple; |
| 32 class PrefService; | 30 class PrefService; |
| 33 class Profile; | 31 class Profile; |
| 34 | 32 |
| 35 namespace message_center { | 33 namespace message_center { |
| 36 class NotificationBlocker; | 34 class NotificationBlocker; |
| 37 FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManuallyCloseMessageCenter); | 35 FORWARD_DECLARE_TEST(WebNotificationTrayTest, ManuallyCloseMessageCenter); |
| 38 } | 36 } |
| 39 | 37 |
| 40 // This class extends NotificationUIManagerImpl and delegates actual display | 38 // This class extends NotificationUIManagerImpl and delegates actual display |
| 41 // of notifications to MessageCenter, doing necessary conversions. | 39 // of notifications to MessageCenter, doing necessary conversions. |
| 42 class MessageCenterNotificationManager | 40 class MessageCenterNotificationManager |
| 43 : public NotificationUIManager, | 41 : public NotificationUIManager, |
| 44 public message_center::MessageCenterObserver, | 42 public message_center::MessageCenterObserver { |
| 45 public content::NotificationObserver { | |
| 46 public: | 43 public: |
| 47 MessageCenterNotificationManager( | 44 MessageCenterNotificationManager( |
| 48 message_center::MessageCenter* message_center, | 45 message_center::MessageCenter* message_center, |
| 49 PrefService* local_state, | 46 PrefService* local_state, |
| 50 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider); | 47 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider); |
| 51 virtual ~MessageCenterNotificationManager(); | 48 virtual ~MessageCenterNotificationManager(); |
| 52 | 49 |
| 53 // Registers preferences. | 50 // Registers preferences. |
| 54 static void RegisterPrefs(PrefRegistrySimple* registry); | 51 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 55 | 52 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 void DisplayFirstRunBalloon(); | 81 void DisplayFirstRunBalloon(); |
| 85 | 82 |
| 86 void SetFirstRunTimeoutForTest(base::TimeDelta timeout); | 83 void SetFirstRunTimeoutForTest(base::TimeDelta timeout); |
| 87 bool FirstRunTimerIsActive() const; | 84 bool FirstRunTimerIsActive() const; |
| 88 #endif | 85 #endif |
| 89 | 86 |
| 90 // Takes ownership of |delegate|. | 87 // Takes ownership of |delegate|. |
| 91 void SetMessageCenterTrayDelegateForTest( | 88 void SetMessageCenterTrayDelegateForTest( |
| 92 message_center::MessageCenterTrayDelegate* delegate); | 89 message_center::MessageCenterTrayDelegate* delegate); |
| 93 | 90 |
| 94 protected: | |
| 95 // content::NotificationObserver override. | |
| 96 virtual void Observe(int type, | |
| 97 const content::NotificationSource& source, | |
| 98 const content::NotificationDetails& details) OVERRIDE; | |
| 99 | |
| 100 private: | 91 private: |
| 101 FRIEND_TEST_ALL_PREFIXES(message_center::WebNotificationTrayTest, | 92 FRIEND_TEST_ALL_PREFIXES(message_center::WebNotificationTrayTest, |
| 102 ManuallyCloseMessageCenter); | 93 ManuallyCloseMessageCenter); |
| 103 class ImageDownloadsObserver { | 94 class ImageDownloadsObserver { |
| 104 public: | 95 public: |
| 105 virtual void OnDownloadsCompleted() = 0; | 96 virtual void OnDownloadsCompleted() = 0; |
| 106 }; | 97 }; |
| 107 | 98 |
| 108 typedef base::Callback<void(const gfx::Image&)> SetImageCallback; | 99 typedef base::Callback<void(const gfx::Image&)> SetImageCallback; |
| 109 class ImageDownloads | 100 class ImageDownloads |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 220 |
| 230 // Provides weak pointers for the purpose of the first run timer. | 221 // Provides weak pointers for the purpose of the first run timer. |
| 231 base::WeakPtrFactory<MessageCenterNotificationManager> weak_factory_; | 222 base::WeakPtrFactory<MessageCenterNotificationManager> weak_factory_; |
| 232 #endif | 223 #endif |
| 233 | 224 |
| 234 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider_; | 225 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider_; |
| 235 | 226 |
| 236 // To own the blockers. | 227 // To own the blockers. |
| 237 ScopedVector<message_center::NotificationBlocker> blockers_; | 228 ScopedVector<message_center::NotificationBlocker> blockers_; |
| 238 | 229 |
| 239 // Registrar for the other kind of notifications (event signaling). | |
| 240 content::NotificationRegistrar registrar_; | |
| 241 | |
| 242 NotificationSystemObserver system_observer_; | 230 NotificationSystemObserver system_observer_; |
| 243 | 231 |
| 244 // Keeps track of all notification statistics for UMA purposes. | 232 // Keeps track of all notification statistics for UMA purposes. |
| 245 MessageCenterStatsCollector stats_collector_; | 233 MessageCenterStatsCollector stats_collector_; |
| 246 | 234 |
| 247 // Keeps track of notifications specific to Google Now for UMA purposes. | 235 // Keeps track of notifications specific to Google Now for UMA purposes. |
| 248 GoogleNowNotificationStatsCollector google_now_stats_collector_; | 236 GoogleNowNotificationStatsCollector google_now_stats_collector_; |
| 249 | 237 |
| 250 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); | 238 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); |
| 251 }; | 239 }; |
| 252 | 240 |
| 253 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ | 241 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |