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

Side by Side Diff: ui/message_center/views/message_center_bubble.cc

Issue 2031763003: Remove itself from the widget observers in destructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comment #17 Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/views/message_center_bubble.h" 5 #include "ui/message_center/views/message_center_bubble.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "ui/base/l10n/l10n_util.h" 8 #include "ui/base/l10n/l10n_util.h"
9 #include "ui/message_center/message_center_style.h" 9 #include "ui/message_center/message_center_style.h"
10 #include "ui/message_center/views/message_center_view.h" 10 #include "ui/message_center/views/message_center_view.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 MessageCenterBubble::MessageCenterBubble(MessageCenter* message_center, 62 MessageCenterBubble::MessageCenterBubble(MessageCenter* message_center,
63 MessageCenterTray* tray, 63 MessageCenterTray* tray,
64 bool first_item_has_no_margin) 64 bool first_item_has_no_margin)
65 : MessageBubbleBase(message_center, tray), 65 : MessageBubbleBase(message_center, tray),
66 message_center_view_(NULL), 66 message_center_view_(NULL),
67 initially_settings_visible_(false), 67 initially_settings_visible_(false),
68 first_item_has_no_margin_(first_item_has_no_margin) {} 68 first_item_has_no_margin_(first_item_has_no_margin) {}
69 69
70 MessageCenterBubble::~MessageCenterBubble() { 70 MessageCenterBubble::~MessageCenterBubble() {
71 // Removs this from the widget observers just in case. MessageCenterBubble
72 // might be destoryed without calling its Widget's Close/CloseNow.
73 if (bubble_view() && bubble_view()->GetWidget())
74 bubble_view()->GetWidget()->RemoveObserver(this);
71 } 75 }
72 76
73 void MessageCenterBubble::SetSettingsVisible() { 77 void MessageCenterBubble::SetSettingsVisible() {
74 if (message_center_view_) 78 if (message_center_view_)
75 message_center_view_->SetSettingsVisible(true); 79 message_center_view_->SetSettingsVisible(true);
76 else 80 else
77 initially_settings_visible_ = true; 81 initially_settings_visible_ = true;
78 } 82 }
79 83
80 views::TrayBubbleView::InitParams MessageCenterBubble::GetInitParams( 84 views::TrayBubbleView::InitParams MessageCenterBubble::GetInitParams(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (!bubble_view()) 121 if (!bubble_view())
118 return; // Could get called after view is closed 122 return; // Could get called after view is closed
119 const NotificationList::Notifications& notifications = 123 const NotificationList::Notifications& notifications =
120 message_center()->GetVisibleNotifications(); 124 message_center()->GetVisibleNotifications();
121 message_center_view_->SetNotifications(notifications); 125 message_center_view_->SetNotifications(notifications);
122 bubble_view()->GetWidget()->Show(); 126 bubble_view()->GetWidget()->Show();
123 bubble_view()->UpdateBubble(); 127 bubble_view()->UpdateBubble();
124 } 128 }
125 129
126 void MessageCenterBubble::OnWidgetClosing(views::Widget* widget) { 130 void MessageCenterBubble::OnWidgetClosing(views::Widget* widget) {
127 bubble_view()->GetWidget()->RemoveObserver(this); 131 if (bubble_view() && bubble_view()->GetWidget())
132 bubble_view()->GetWidget()->RemoveObserver(this);
128 if (message_center_view_) 133 if (message_center_view_)
129 message_center_view_->SetIsClosing(true); 134 message_center_view_->SetIsClosing(true);
130 } 135 }
131 136
132 void MessageCenterBubble::OnMouseEnteredView() { 137 void MessageCenterBubble::OnMouseEnteredView() {
133 } 138 }
134 139
135 void MessageCenterBubble::OnMouseExitedView() { 140 void MessageCenterBubble::OnMouseExitedView() {
136 } 141 }
137 142
138 size_t MessageCenterBubble::NumMessageViewsForTest() const { 143 size_t MessageCenterBubble::NumMessageViewsForTest() const {
139 return message_center_view_->NumMessageViewsForTest(); 144 return message_center_view_->NumMessageViewsForTest();
140 } 145 }
141 146
142 } // namespace message_center 147 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698