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 | 10 |
11 namespace message_center { | 11 namespace message_center { |
12 | 12 |
13 //------------------------------------------------------------------------------ | 13 //------------------------------------------------------------------------------ |
14 | 14 MessageCenter::MessageCenter() |
15 // static | 15 : delegate_(NULL) { |
16 MessageCenter* MessageCenter::GetInstance() { | 16 notification_list_.reset(new NotificationList(this)); |
17 return Singleton<MessageCenter>::get(); | |
18 } | 17 } |
19 | 18 |
20 MessageCenter::~MessageCenter() { | 19 MessageCenter::~MessageCenter() { |
21 notification_list_.reset(); | 20 notification_list_.reset(); |
22 } | 21 } |
23 | 22 |
24 void MessageCenter::AddObserver(Observer* observer) { | 23 void MessageCenter::AddObserver(Observer* observer) { |
25 observer_list_.AddObserver(observer); | 24 observer_list_.AddObserver(observer); |
26 } | 25 } |
27 | 26 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return notification_list_.get(); | 164 return notification_list_.get(); |
166 } | 165 } |
167 | 166 |
168 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, | 167 void MessageCenter::Delegate::OnButtonClicked(const std::string& id, |
169 int button_index) { | 168 int button_index) { |
170 } | 169 } |
171 | 170 |
172 //------------------------------------------------------------------------------ | 171 //------------------------------------------------------------------------------ |
173 // Private. | 172 // Private. |
174 | 173 |
175 MessageCenter::MessageCenter() | |
176 : delegate_(NULL) { | |
177 notification_list_.reset(new NotificationList(this)); | |
178 } | |
179 | |
180 void MessageCenter::NotifyMessageCenterChanged(bool new_notification) { | 174 void MessageCenter::NotifyMessageCenterChanged(bool new_notification) { |
181 FOR_EACH_OBSERVER(Observer, | 175 FOR_EACH_OBSERVER(Observer, |
182 observer_list_, | 176 observer_list_, |
183 OnMessageCenterChanged(new_notification)); | 177 OnMessageCenterChanged(new_notification)); |
184 } | 178 } |
185 | 179 |
186 | 180 |
187 } // namespace message_center | 181 } // namespace message_center |
OLD | NEW |