summaryrefslogtreecommitdiff
path: root/chromium/ui/message_center/views/notification_view_md.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/message_center/views/notification_view_md.cc')
-rw-r--r--chromium/ui/message_center/views/notification_view_md.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/chromium/ui/message_center/views/notification_view_md.cc b/chromium/ui/message_center/views/notification_view_md.cc
index a81e70dd50e..5349bc34e5b 100644
--- a/chromium/ui/message_center/views/notification_view_md.cc
+++ b/chromium/ui/message_center/views/notification_view_md.cc
@@ -715,7 +715,12 @@ void NotificationViewMD::ButtonPressed(views::Button* sender,
if (sender == header_row_) {
if (IsExpandable() && content_row_->visible()) {
SetManuallyExpandedOrCollapsed(true);
+ auto weak_ptr = weak_ptr_factory_.GetWeakPtr();
ToggleExpanded();
+ // Check |this| is valid before continuing, because ToggleExpanded() might
+ // cause |this| to be deleted.
+ if (!weak_ptr)
+ return;
Layout();
SchedulePaint();
}
@@ -1216,6 +1221,8 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) {
}
void NotificationViewMD::ToggleInlineSettings(const ui::Event& event) {
+ if (!settings_row_)
+ return;
bool inline_settings_visible = !settings_row_->visible();
bool disable_notification =
settings_row_->visible() && block_all_button_->checked();
@@ -1229,7 +1236,16 @@ void NotificationViewMD::ToggleInlineSettings(const ui::Event& event) {
dont_block_button_->SetChecked(true);
SetSettingMode(inline_settings_visible);
- SetExpanded(!inline_settings_visible);
+
+ // Grab a weak pointer before calling SetExpanded() as it might cause |this|
+ // to be deleted.
+ {
+ auto weak_ptr = weak_ptr_factory_.GetWeakPtr();
+ SetExpanded(!inline_settings_visible);
+ if (!weak_ptr)
+ return;
+ }
+
PreferredSizeChanged();
if (inline_settings_visible)