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 "ash/system/web_notification/message_center.h" | 5 #include "ui/message_center/message_center.h" |
| 6 |
6 #include "base/logging.h" | 7 #include "base/logging.h" |
7 | 8 |
8 namespace message_center { | 9 namespace message_center { |
9 | 10 |
10 //------------------------------------------------------------------------------ | 11 //------------------------------------------------------------------------------ |
11 | 12 |
12 MessageCenter::MessageCenter(Host* host) | 13 MessageCenter::MessageCenter(Host* host) |
13 : host_(host), | 14 : host_(host), |
14 delegate_(NULL) { | 15 delegate_(NULL) { |
15 notification_list_.reset(new WebNotificationList(this)); | 16 notification_list_.reset(new NotificationList(this)); |
16 } | 17 } |
17 | 18 |
18 MessageCenter::~MessageCenter() { | 19 MessageCenter::~MessageCenter() { |
19 notification_list_.reset(); | 20 notification_list_.reset(); |
20 } | 21 } |
21 | 22 |
22 void MessageCenter::SetDelegate(Delegate* delegate) { | 23 void MessageCenter::SetDelegate(Delegate* delegate) { |
23 DCHECK(!delegate_); | 24 DCHECK(!delegate_); |
24 delegate_ = delegate; | 25 delegate_ = delegate; |
25 } | 26 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 74 |
74 void MessageCenter::SetNotificationImage(const std::string& id, | 75 void MessageCenter::SetNotificationImage(const std::string& id, |
75 const gfx::ImageSkia& image) { | 76 const gfx::ImageSkia& image) { |
76 if (!notification_list_->SetNotificationImage(id, image)) | 77 if (!notification_list_->SetNotificationImage(id, image)) |
77 return; | 78 return; |
78 if (host_) | 79 if (host_) |
79 host_->MessageCenterChanged(true); | 80 host_->MessageCenterChanged(true); |
80 } | 81 } |
81 | 82 |
82 //------------------------------------------------------------------------------ | 83 //------------------------------------------------------------------------------ |
83 // Overridden from WebNotificationList::Delegate. | 84 // Overridden from NotificationList::Delegate. |
84 | 85 |
85 void MessageCenter::SendRemoveNotification(const std::string& id) { | 86 void MessageCenter::SendRemoveNotification(const std::string& id) { |
86 if (delegate_) | 87 if (delegate_) |
87 delegate_->NotificationRemoved(id); | 88 delegate_->NotificationRemoved(id); |
88 } | 89 } |
89 | 90 |
90 void MessageCenter::SendRemoveAllNotifications() { | 91 void MessageCenter::SendRemoveAllNotifications() { |
91 if (delegate_) { | 92 if (delegate_) { |
92 const WebNotificationList::Notifications& notifications = | 93 const NotificationList::Notifications& notifications = |
93 notification_list_->notifications(); | 94 notification_list_->notifications(); |
94 for (WebNotificationList::Notifications::const_iterator loopiter = | 95 for (NotificationList::Notifications::const_iterator loopiter = |
95 notifications.begin(); | 96 notifications.begin(); |
96 loopiter != notifications.end(); ) { | 97 loopiter != notifications.end(); ) { |
97 WebNotificationList::Notifications::const_iterator curiter = loopiter++; | 98 NotificationList::Notifications::const_iterator curiter = loopiter++; |
98 std::string notification_id = curiter->id; | 99 std::string notification_id = curiter->id; |
99 // May call RemoveNotification and erase curiter. | 100 // May call RemoveNotification and erase curiter. |
100 delegate_->NotificationRemoved(notification_id); | 101 delegate_->NotificationRemoved(notification_id); |
101 } | 102 } |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 void MessageCenter::DisableNotificationByExtension( | 106 void MessageCenter::DisableNotificationByExtension( |
106 const std::string& id) { | 107 const std::string& id) { |
107 if (delegate_) | 108 if (delegate_) |
(...skipping 12 matching lines...) Expand all Loading... |
120 void MessageCenter::ShowNotificationSettings(const std::string& id) { | 121 void MessageCenter::ShowNotificationSettings(const std::string& id) { |
121 if (delegate_) | 122 if (delegate_) |
122 delegate_->ShowSettings(id); | 123 delegate_->ShowSettings(id); |
123 } | 124 } |
124 | 125 |
125 void MessageCenter::OnNotificationClicked(const std::string& id) { | 126 void MessageCenter::OnNotificationClicked(const std::string& id) { |
126 if (delegate_) | 127 if (delegate_) |
127 delegate_->OnClicked(id); | 128 delegate_->OnClicked(id); |
128 } | 129 } |
129 | 130 |
130 WebNotificationList* MessageCenter::GetNotificationList() { | 131 NotificationList* MessageCenter::GetNotificationList() { |
131 return notification_list_.get(); | 132 return notification_list_.get(); |
132 } | 133 } |
133 | 134 |
134 } // namespace message_center | 135 } // namespace message_center |
OLD | NEW |