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 #include "ui/message_center/message_center.h" | 5 #include "ui/message_center/message_center.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "ui/message_center/notification.h" | 10 #include "ui/message_center/notification.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 void MessageCenter::SetNotificationButtonIcon( | 97 void MessageCenter::SetNotificationButtonIcon( |
98 const std::string& notification_id, int button_index, | 98 const std::string& notification_id, int button_index, |
99 const gfx::ImageSkia& image) { | 99 const gfx::ImageSkia& image) { |
100 if (notification_list_->SetNotificationButtonIcon(notification_id, | 100 if (notification_list_->SetNotificationButtonIcon(notification_id, |
101 button_index, image)) | 101 button_index, image)) |
102 NotifyMessageCenterChanged(true); | 102 NotifyMessageCenterChanged(true); |
103 } | 103 } |
104 | 104 |
105 //------------------------------------------------------------------------------ | 105 //------------------------------------------------------------------------------ |
106 // Overridden from NotificationList::Delegate. | 106 // Overridden from NotificationList::Delegate: |
107 | 107 |
108 void MessageCenter::SendRemoveNotification(const std::string& id, | 108 void MessageCenter::SendRemoveNotification(const std::string& id, |
109 bool by_user) { | 109 bool by_user) { |
110 if (delegate_) | 110 if (delegate_) |
111 delegate_->NotificationRemoved(id, by_user); | 111 delegate_->NotificationRemoved(id, by_user); |
112 } | 112 } |
113 | 113 |
114 void MessageCenter::SendRemoveAllNotifications(bool by_user) { | 114 void MessageCenter::SendRemoveAllNotifications(bool by_user) { |
115 if (delegate_) { | 115 if (delegate_) { |
116 const NotificationList::Notifications& notifications = | 116 const NotificationList::Notifications& notifications = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 void MessageCenter::OnNotificationClicked(const std::string& id) { | 154 void MessageCenter::OnNotificationClicked(const std::string& id) { |
155 if (delegate_) | 155 if (delegate_) |
156 delegate_->OnClicked(id); | 156 delegate_->OnClicked(id); |
157 if (HasPopupNotifications()) { | 157 if (HasPopupNotifications()) { |
158 notification_list_->MarkSinglePopupAsShown(id, true); | 158 notification_list_->MarkSinglePopupAsShown(id, true); |
159 NotifyMessageCenterChanged(false); | 159 NotifyMessageCenterChanged(false); |
160 } | 160 } |
161 } | 161 } |
162 | 162 |
163 void MessageCenter::OnQuietModeChanged(bool quiet_mode) { | |
164 NotifyMessageCenterChanged(true); | |
165 } | |
166 | |
167 void MessageCenter::OnButtonClicked(const std::string& id, int button_index) { | 163 void MessageCenter::OnButtonClicked(const std::string& id, int button_index) { |
168 if (delegate_) | 164 if (delegate_) |
169 delegate_->OnButtonClicked(id, button_index); | 165 delegate_->OnButtonClicked(id, button_index); |
170 if (HasPopupNotifications()) { | 166 if (HasPopupNotifications()) { |
171 notification_list_->MarkSinglePopupAsShown(id, true); | 167 notification_list_->MarkSinglePopupAsShown(id, true); |
172 NotifyMessageCenterChanged(false); | 168 NotifyMessageCenterChanged(false); |
173 } | 169 } |
174 } | 170 } |
175 | 171 |
176 NotificationList* MessageCenter::GetNotificationList() { | 172 void MessageCenter::OnExpand(const std::string& id) { |
177 return notification_list_.get(); | 173 notification_list_->MarkNotificationAsExpanded(id); |
| 174 } |
| 175 |
| 176 void MessageCenter::OnQuietModeChanged(bool quiet_mode) { |
| 177 NotifyMessageCenterChanged(true); |
178 } | 178 } |
179 | 179 |
180 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, | 180 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, |
181 int button_index) { | 181 int button_index) { |
182 } | 182 } |
183 | 183 |
184 //------------------------------------------------------------------------------ | 184 //------------------------------------------------------------------------------ |
185 // Private. | 185 // Private. |
186 | 186 |
187 void MessageCenter::NotifyMessageCenterChanged(bool new_notification) { | 187 void MessageCenter::NotifyMessageCenterChanged(bool new_notification) { |
188 FOR_EACH_OBSERVER(Observer, | 188 FOR_EACH_OBSERVER(Observer, |
189 observer_list_, | 189 observer_list_, |
190 OnMessageCenterChanged(new_notification)); | 190 OnMessageCenterChanged(new_notification)); |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 } // namespace message_center | 194 } // namespace message_center |
OLD | NEW |