diff --git a/shell/browser/notifications/notification_presenter.cc b/shell/browser/notifications/notification_presenter.cc index 16ac82a36828..a996dba971cc 100644 --- a/shell/browser/notifications/notification_presenter.cc +++ b/shell/browser/notifications/notification_presenter.cc @@ -27,13 +27,8 @@ base::WeakPtr NotificationPresenter::CreateNotification( } void NotificationPresenter::RemoveNotification(Notification* notification) { - auto it = notifications_.find(notification); - if (it == notifications_.end()) { - return; - } - - notifications_.erase(notification); - delete notification; + if (const auto nh = notifications_.extract(notification)) + delete nh.value(); } void NotificationPresenter::CloseNotificationWithId(