Chromium Code Reviews| 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 UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
| 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/message_center/message_center_export.h" | 9 #include "ui/message_center/message_center_export.h" |
| 10 #include "ui/message_center/notification_list.h" | 10 #include "ui/message_center/notification_list.h" |
| 11 #include "ui/notifications/notification_types.h" | 11 #include "ui/notifications/notification_types.h" |
| 12 | 12 |
| 13 template <typename T> struct DefaultSingletonTraits; | |
| 14 | |
| 13 namespace base { | 15 namespace base { |
| 14 class DictionaryValue; | 16 class DictionaryValue; |
| 15 } | 17 } |
| 16 | 18 |
| 17 // Class for managing the NotificationList. The client (e.g. Chrome) calls | 19 // Class for managing the NotificationList. The client (e.g. Chrome) calls |
| 18 // [Add|Remove|Update]Notification to create and update notifications in the | 20 // [Add|Remove|Update]Notification to create and update notifications in the |
| 19 // list. It can also implement Delegate to receive callbacks when a | 21 // list. It can also implement Delegate to receive callbacks when a |
| 20 // notification is removed (closed), or clicked on. | 22 // notification is removed (closed), or clicked on. |
| 21 // If a Host is provided, it will be informed when the notification list | 23 // If a Host is provided, it will be informed when the notification list |
| 22 // changes, and is expected to handle creating, showing, and hiding of any | 24 // changes, and is expected to handle creating, showing, and hiding of any |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 // | 65 // |
| 64 // TODO(miket): consider providing default implementations for the pure | 66 // TODO(miket): consider providing default implementations for the pure |
| 65 // virtuals above, to avoid changing so many files in disparate parts of | 67 // virtuals above, to avoid changing so many files in disparate parts of |
| 66 // the codebase each time we enhance this interface. | 68 // the codebase each time we enhance this interface. |
| 67 virtual void OnButtonClicked(const std::string& id, int button_index); | 69 virtual void OnButtonClicked(const std::string& id, int button_index); |
| 68 | 70 |
| 69 protected: | 71 protected: |
| 70 virtual ~Delegate() {} | 72 virtual ~Delegate() {} |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 // |host| is expected to manage any notification bubbles. It may be NULL. | 75 static MessageCenter* GetInstance(); |
| 74 explicit MessageCenter(Host* host); | |
| 75 | 76 |
| 76 virtual ~MessageCenter(); | 77 virtual ~MessageCenter(); |
| 77 | 78 |
| 79 // Called once to set the host, which is expected to manage any notification | |
| 80 // bubbles. |host| can be NULL. | |
|
stevenjb
2012/12/27 19:49:34
I would remove the '|host| can be NULL' part of th
dewittj
2012/12/27 23:38:50
Done.
| |
| 81 void SetHost(Host* host); | |
| 78 // Called once to set the delegate. | 82 // Called once to set the delegate. |
| 79 void SetDelegate(Delegate* delegate); | 83 void SetDelegate(Delegate* delegate); |
| 80 | 84 |
| 81 // Informs the notification list whether the message center is visible. | 85 // Informs the notification list whether the message center is visible. |
| 82 // This affects whether or not a message has been "read". | 86 // This affects whether or not a message has been "read". |
| 83 void SetMessageCenterVisible(bool visible); | 87 void SetMessageCenterVisible(bool visible); |
| 84 | 88 |
| 85 // Accessors to notification_list_ | 89 // Accessors to notification_list_ |
| 86 size_t NotificationCount() const; | 90 size_t NotificationCount() const; |
| 87 size_t UnreadNotificationCount() const; | 91 size_t UnreadNotificationCount() const; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE; | 130 virtual void DisableNotificationByExtension(const std::string& id) OVERRIDE; |
| 127 virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE; | 131 virtual void DisableNotificationByUrl(const std::string& id) OVERRIDE; |
| 128 virtual void ShowNotificationSettings(const std::string& id) OVERRIDE; | 132 virtual void ShowNotificationSettings(const std::string& id) OVERRIDE; |
| 129 virtual void OnNotificationClicked(const std::string& id) OVERRIDE; | 133 virtual void OnNotificationClicked(const std::string& id) OVERRIDE; |
| 130 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE; | 134 virtual void OnQuietModeChanged(bool quiet_mode) OVERRIDE; |
| 131 virtual void OnButtonClicked(const std::string& id, int button_index) | 135 virtual void OnButtonClicked(const std::string& id, int button_index) |
| 132 OVERRIDE; | 136 OVERRIDE; |
| 133 virtual NotificationList* GetNotificationList() OVERRIDE; | 137 virtual NotificationList* GetNotificationList() OVERRIDE; |
| 134 | 138 |
| 135 private: | 139 private: |
| 140 MessageCenter(); | |
| 141 friend struct DefaultSingletonTraits<MessageCenter>; | |
| 142 | |
| 136 scoped_ptr<NotificationList> notification_list_; | 143 scoped_ptr<NotificationList> notification_list_; |
| 137 Host* host_; | 144 Host* host_; |
| 138 Delegate* delegate_; | 145 Delegate* delegate_; |
| 139 | 146 |
| 140 DISALLOW_COPY_AND_ASSIGN(MessageCenter); | 147 DISALLOW_COPY_AND_ASSIGN(MessageCenter); |
| 141 }; | 148 }; |
| 142 | 149 |
| 143 } // namespace message_center | 150 } // namespace message_center |
| 144 | 151 |
| 145 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ | 152 #endif // UI_MESSAGE_CENTER_MESSAGE_CENTER_H_ |
| OLD | NEW |