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 | 9 |
9 namespace message_center { | 10 namespace message_center { |
10 | 11 |
11 //------------------------------------------------------------------------------ | 12 //------------------------------------------------------------------------------ |
12 | 13 |
13 MessageCenter::MessageCenter(Host* host) | 14 // static |
14 : host_(host), | 15 MessageCenter* MessageCenter::GetInstance() { |
15 delegate_(NULL) { | 16 return Singleton<MessageCenter>::get(); |
16 notification_list_.reset(new NotificationList(this)); | |
17 } | 17 } |
18 | 18 |
19 MessageCenter::~MessageCenter() { | 19 MessageCenter::~MessageCenter() { |
20 notification_list_.reset(); | 20 notification_list_.reset(); |
21 } | 21 } |
22 | 22 |
23 void MessageCenter::SetHost(Host* host) { | |
stevenjb
2012/12/27 19:49:34
DCHECK(!host_) since we don't support multiple hos
dewittj
2012/12/27 23:38:50
Since the MessageCenter is now not being destroyed
stevenjb
2013/01/02 16:35:02
Thinking about this some more, it seems like we ne
| |
24 host_ = host; | |
25 } | |
26 | |
23 void MessageCenter::SetDelegate(Delegate* delegate) { | 27 void MessageCenter::SetDelegate(Delegate* delegate) { |
24 DCHECK(!delegate_); | 28 DCHECK(!delegate_); |
25 delegate_ = delegate; | 29 delegate_ = delegate; |
26 } | 30 } |
27 | 31 |
28 void MessageCenter::SetMessageCenterVisible(bool visible) { | 32 void MessageCenter::SetMessageCenterVisible(bool visible) { |
29 notification_list_->SetMessageCenterVisible(visible); | 33 notification_list_->SetMessageCenterVisible(visible); |
30 } | 34 } |
31 | 35 |
32 size_t MessageCenter::NotificationCount() const { | 36 size_t MessageCenter::NotificationCount() const { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 } | 147 } |
144 | 148 |
145 NotificationList* MessageCenter::GetNotificationList() { | 149 NotificationList* MessageCenter::GetNotificationList() { |
146 return notification_list_.get(); | 150 return notification_list_.get(); |
147 } | 151 } |
148 | 152 |
149 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, | 153 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, |
150 int button_index) { | 154 int button_index) { |
151 } | 155 } |
152 | 156 |
157 //------------------------------------------------------------------------------ | |
158 // Private. | |
159 | |
160 MessageCenter::MessageCenter() | |
161 : host_(NULL), | |
162 delegate_(NULL) { | |
163 notification_list_.reset(new NotificationList(this)); | |
164 } | |
165 | |
166 | |
153 } // namespace message_center | 167 } // namespace message_center |
OLD | NEW |