| 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 "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
| 13 #include "chrome/browser/notifications/notification_ui_manager.h" | 13 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 14 #include "chrome/browser/notifications/notification_ui_manager_impl.h" | 14 #include "chrome/browser/notifications/notification_ui_manager_impl.h" |
| 15 #include "ui/message_center/message_center.h" | 15 #include "ui/message_center/message_center.h" |
| 16 #include "ui/message_center/message_center_tray_delegate.h" |
| 16 | 17 |
| 17 class Notification; | 18 class Notification; |
| 18 class Profile; | 19 class Profile; |
| 19 | 20 |
| 20 // This class extends NotificationUIManagerImpl and delegates actual display | 21 // This class extends NotificationUIManagerImpl and delegates actual display |
| 21 // of notifications to MessageCenter, doing necessary conversions. | 22 // of notifications to MessageCenter, doing necessary conversions. |
| 22 class MessageCenterNotificationManager | 23 class MessageCenterNotificationManager |
| 23 : public NotificationUIManagerImpl, | 24 : public NotificationUIManagerImpl, |
| 24 public message_center::MessageCenter::Delegate { | 25 public message_center::MessageCenter::Delegate { |
| 25 public: | 26 public: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 virtual void DisableExtension(const std::string& notification_id) OVERRIDE; | 46 virtual void DisableExtension(const std::string& notification_id) OVERRIDE; |
| 46 virtual void DisableNotificationsFromSource( | 47 virtual void DisableNotificationsFromSource( |
| 47 const std::string& notification_id) OVERRIDE; | 48 const std::string& notification_id) OVERRIDE; |
| 48 virtual void ShowSettings(const std::string& notification_id) OVERRIDE; | 49 virtual void ShowSettings(const std::string& notification_id) OVERRIDE; |
| 49 virtual void ShowSettingsDialog(gfx::NativeView context) OVERRIDE; | 50 virtual void ShowSettingsDialog(gfx::NativeView context) OVERRIDE; |
| 50 virtual void OnClicked(const std::string& notification_id) OVERRIDE; | 51 virtual void OnClicked(const std::string& notification_id) OVERRIDE; |
| 51 virtual void OnButtonClicked(const std::string& notification_id, | 52 virtual void OnButtonClicked(const std::string& notification_id, |
| 52 int button_index) OVERRIDE; | 53 int button_index) OVERRIDE; |
| 53 | 54 |
| 54 private: | 55 private: |
| 56 scoped_ptr<message_center::MessageCenterTrayDelegate> tray_; |
| 55 message_center::MessageCenter* message_center_; // Weak, global. | 57 message_center::MessageCenter* message_center_; // Weak, global. |
| 56 | 58 |
| 57 // This class keeps a set of original Notification objects and corresponding | 59 // This class keeps a set of original Notification objects and corresponding |
| 58 // Profiles, so when MessageCenter calls back with a notification_id, this | 60 // Profiles, so when MessageCenter calls back with a notification_id, this |
| 59 // class has necessary mapping to other source info - for example, it calls | 61 // class has necessary mapping to other source info - for example, it calls |
| 60 // NotificationDelegate supplied by client when someone clicks on a Notification | 62 // NotificationDelegate supplied by client when someone clicks on a Notification |
| 61 // in MessageCenter. Likewise, if a Profile or Extension is being removed, the | 63 // in MessageCenter. Likewise, if a Profile or Extension is being removed, the |
| 62 // map makes it possible to revoke the notifications from MessageCenter. | 64 // map makes it possible to revoke the notifications from MessageCenter. |
| 63 // To keep that set, we use the private ProfileNotification class that stores | 65 // To keep that set, we use the private ProfileNotification class that stores |
| 64 // a superset of all information about a notification. | 66 // a superset of all information about a notification. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 // They take ownership of profile_notification object. | 92 // They take ownership of profile_notification object. |
| 91 void AddProfileNotification(ProfileNotification* profile_notification); | 93 void AddProfileNotification(ProfileNotification* profile_notification); |
| 92 void RemoveProfileNotification(ProfileNotification* profile_notification); | 94 void RemoveProfileNotification(ProfileNotification* profile_notification); |
| 93 | 95 |
| 94 ProfileNotification* FindProfileNotification(const std::string& id) const; | 96 ProfileNotification* FindProfileNotification(const std::string& id) const; |
| 95 | 97 |
| 96 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); | 98 DISALLOW_COPY_AND_ASSIGN(MessageCenterNotificationManager); |
| 97 }; | 99 }; |
| 98 | 100 |
| 99 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ | 101 #endif // CHROME_BROWSER_NOTIFICATIONS_MESSAGE_CENTER_NOTIFICATION_MANAGER_H_ |
| OLD | NEW |