diff options
Diffstat (limited to 'chromium/content/browser/notifications/blink_notification_service_impl.cc')
-rw-r--r-- | chromium/content/browser/notifications/blink_notification_service_impl.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/chromium/content/browser/notifications/blink_notification_service_impl.cc b/chromium/content/browser/notifications/blink_notification_service_impl.cc index 605a9ed20ce..53101e0342c 100644 --- a/chromium/content/browser/notifications/blink_notification_service_impl.cc +++ b/chromium/content/browser/notifications/blink_notification_service_impl.cc @@ -5,6 +5,7 @@ #include "content/browser/notifications/blink_notification_service_impl.h" #include "base/bind.h" +#include "base/bind_helpers.h" #include "base/callback_helpers.h" #include "base/logging.h" #include "base/strings/string16.h" @@ -141,8 +142,10 @@ void BlinkNotificationServiceImpl::CloseNonPersistentNotificationOnUIThread( const std::string& notification_id) { Service()->CloseNotification(browser_context_, notification_id); + // TODO(https://crbug.com/442141): Pass a callback here to focus the tab + // which created the notification, unless the event is canceled. NotificationEventDispatcherImpl::GetInstance() - ->DispatchNonPersistentCloseEvent(notification_id); + ->DispatchNonPersistentCloseEvent(notification_id, base::DoNothing()); } blink::mojom::PermissionStatus @@ -245,6 +248,24 @@ void BlinkNotificationServiceImpl:: std::move(callback).Run(blink::mojom::PersistentNotificationError::NONE); } +void BlinkNotificationServiceImpl::ClosePersistentNotification( + const std::string& notification_id) { + DCHECK_CURRENTLY_ON(BrowserThread::IO); + + if (CheckPermissionStatus() != blink::mojom::PermissionStatus::GRANTED) + return; + + // Using base::Unretained here is safe because Service() returns a singleton. + BrowserThread::PostTask( + BrowserThread::UI, FROM_HERE, + base::BindOnce(&PlatformNotificationService::ClosePersistentNotification, + base::Unretained(Service()), browser_context_, + notification_id)); + + notification_context_->DeleteNotificationData( + notification_id, origin_.GetURL(), base::DoNothing()); +} + void BlinkNotificationServiceImpl::GetNotifications( int64_t service_worker_registration_id, const std::string& filter_tag, |