| 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_NOTIFICATION_UI_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/id_map.h" | 12 #include "base/id_map.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/prefs/public/pref_observer.h" | |
| 15 #include "base/timer.h" | 14 #include "base/timer.h" |
| 16 #include "chrome/browser/api/prefs/pref_member.h" | 15 #include "chrome/browser/api/prefs/pref_member.h" |
| 17 #include "chrome/browser/notifications/balloon.h" | 16 #include "chrome/browser/notifications/balloon.h" |
| 18 #include "chrome/browser/notifications/balloon_collection.h" | 17 #include "chrome/browser/notifications/balloon_collection.h" |
| 19 #include "chrome/browser/notifications/notification_prefs_manager.h" | 18 #include "chrome/browser/notifications/notification_prefs_manager.h" |
| 20 #include "chrome/browser/notifications/notification_ui_manager.h" | 19 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 21 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 22 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 23 | 22 |
| 24 class Notification; | 23 class Notification; |
| 25 class PrefService; | 24 class PrefService; |
| 26 class Profile; | 25 class Profile; |
| 27 class QueuedNotification; | 26 class QueuedNotification; |
| 28 | 27 |
| 29 // The notification manager manages use of the desktop for notifications. | 28 // The notification manager manages use of the desktop for notifications. |
| 30 // It maintains a queue of pending notifications when space becomes constrained. | 29 // It maintains a queue of pending notifications when space becomes constrained. |
| 31 class NotificationUIManagerImpl | 30 class NotificationUIManagerImpl |
| 32 : public NotificationUIManager, | 31 : public NotificationUIManager, |
| 33 public NotificationPrefsManager, | 32 public NotificationPrefsManager, |
| 34 public BalloonCollection::BalloonSpaceChangeListener, | 33 public BalloonCollection::BalloonSpaceChangeListener, |
| 35 public content::NotificationObserver, | 34 public content::NotificationObserver { |
| 36 public PrefObserver { | |
| 37 public: | 35 public: |
| 38 explicit NotificationUIManagerImpl(PrefService* local_state); | 36 explicit NotificationUIManagerImpl(PrefService* local_state); |
| 39 virtual ~NotificationUIManagerImpl(); | 37 virtual ~NotificationUIManagerImpl(); |
| 40 | 38 |
| 41 // Initializes the UI manager with a balloon collection; this object | 39 // Initializes the UI manager with a balloon collection; this object |
| 42 // takes ownership of the balloon collection. | 40 // takes ownership of the balloon collection. |
| 43 void Initialize(BalloonCollection* balloon_collection); | 41 void Initialize(BalloonCollection* balloon_collection); |
| 44 | 42 |
| 45 // NotificationUIManager: | 43 // NotificationUIManager: |
| 46 virtual void Add(const Notification& notification, | 44 virtual void Add(const Notification& notification, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 GetPositionPreference() const OVERRIDE; | 56 GetPositionPreference() const OVERRIDE; |
| 59 virtual void SetPositionPreference( | 57 virtual void SetPositionPreference( |
| 60 BalloonCollection::PositionPreference preference) OVERRIDE; | 58 BalloonCollection::PositionPreference preference) OVERRIDE; |
| 61 | 59 |
| 62 private: | 60 private: |
| 63 // content::NotificationObserver override. | 61 // content::NotificationObserver override. |
| 64 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 65 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 66 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
| 67 | 65 |
| 68 // PrefObserver override. | 66 void OnDesktopNotificationPositionChanged(); |
| 69 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
| 70 const std::string& pref_name) OVERRIDE; | |
| 71 | 67 |
| 72 // Attempts to display notifications from the show_queue if the user | 68 // Attempts to display notifications from the show_queue if the user |
| 73 // is active. | 69 // is active. |
| 74 void CheckAndShowNotifications(); | 70 void CheckAndShowNotifications(); |
| 75 | 71 |
| 76 // Attempts to display notifications from the show_queue. | 72 // Attempts to display notifications from the show_queue. |
| 77 void ShowNotifications(); | 73 void ShowNotifications(); |
| 78 | 74 |
| 79 // BalloonCollectionObserver implementation. | 75 // BalloonCollectionObserver implementation. |
| 80 virtual void OnBalloonSpaceChanged() OVERRIDE; | 76 virtual void OnBalloonSpaceChanged() OVERRIDE; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 IntegerPrefMember position_pref_; | 96 IntegerPrefMember position_pref_; |
| 101 | 97 |
| 102 // Used by screen-saver and full-screen handling support. | 98 // Used by screen-saver and full-screen handling support. |
| 103 bool is_user_active_; | 99 bool is_user_active_; |
| 104 base::RepeatingTimer<NotificationUIManagerImpl> user_state_check_timer_; | 100 base::RepeatingTimer<NotificationUIManagerImpl> user_state_check_timer_; |
| 105 | 101 |
| 106 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerImpl); | 102 DISALLOW_COPY_AND_ASSIGN(NotificationUIManagerImpl); |
| 107 }; | 103 }; |
| 108 | 104 |
| 109 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ | 105 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_UI_MANAGER_IMPL_H_ |
| OLD | NEW |