Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1267)

Unified Diff: ash/system/web_notification/web_notification_tray.cc

Issue 11684003: Make MessageCenter a singleton object and build on Windows. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update comment. Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/system/web_notification/web_notification_tray.cc
diff --git a/ash/system/web_notification/web_notification_tray.cc b/ash/system/web_notification/web_notification_tray.cc
index 5e7822fbb8d3c063863e94884f5916ff799a8a78..f079d53cf2dd70ce2c8b383e1c98dbfa81993c5e 100644
--- a/ash/system/web_notification/web_notification_tray.cc
+++ b/ash/system/web_notification/web_notification_tray.cc
@@ -83,7 +83,8 @@ WebNotificationTray::WebNotificationTray(
: internal::TrayBackgroundView(status_area_widget),
button_(NULL),
show_message_center_on_unlock_(false) {
- message_center_.reset(new message_center::MessageCenter(this));
+ message_center_ = message_center::MessageCenter::GetInstance();
+ message_center_->AddObserver(this);
button_ = new views::ImageButton(this);
button_->set_triggerable_event_flags(
ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON);
@@ -92,8 +93,8 @@ WebNotificationTray::WebNotificationTray(
}
WebNotificationTray::~WebNotificationTray() {
- // message_center_ has a weak pointer to this; destroy it early.
- message_center_.reset();
+ // Ensure the message center doesn't notify a destroyed object.
+ message_center_->RemoveObserver(this);
// Release any child views that might have back pointers before ~View().
message_center_bubble_.reset();
popup_bubble_.reset();
@@ -116,7 +117,7 @@ void WebNotificationTray::ShowMessageCenterBubble() {
UpdateTray();
HidePopupBubble();
message_center::MessageCenterBubble* bubble =
- new message_center::MessageCenterBubble(message_center_.get());
+ new message_center::MessageCenterBubble(message_center_);
message_center_bubble_.reset(
new internal::WebNotificationBubbleWrapper(this, bubble));
@@ -156,7 +157,7 @@ void WebNotificationTray::ShowPopupBubble() {
popup_bubble_.reset(
new internal::WebNotificationBubbleWrapper(
this, new message_center::MessagePopupBubble(
- message_center_.get())));
+ message_center_)));
}
}
@@ -294,7 +295,7 @@ void WebNotificationTray::HideBubble(const views::TrayBubbleView* bubble_view) {
HideBubbleWithView(bubble_view);
}
-void WebNotificationTray::MessageCenterChanged(bool new_notification) {
+void WebNotificationTray::OnMessageCenterChanged(bool new_notification) {
if (message_center_bubble()) {
if (message_center_->NotificationCount() == 0)
HideMessageCenterBubble();
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | ash/system/web_notification/web_notification_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698