diff --git a/brightray/browser/win/windows_toast_notification.cc b/brightray/browser/win/windows_toast_notification.cc index f353987876ce..dd060d10e394 100644 --- a/brightray/browser/win/windows_toast_notification.cc +++ b/brightray/browser/win/windows_toast_notification.cc @@ -85,6 +85,11 @@ void WindowsToastNotification::NotificationDismissed() { delete this; } +void WindowsToastNotification::NotificationFailed() { + delegate_->NotificationError(); + delete this; +} + bool WindowsToastNotification::GetToastXml( ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager, const std::wstring& title, @@ -231,12 +236,15 @@ bool WindowsToastNotification::AppendTextToXml( } bool WindowsToastNotification::SetupCallbacks(ABI::Windows::UI::Notifications::IToastNotification* toast) { - EventRegistrationToken activatedToken, dismissedToken; + EventRegistrationToken activatedToken, dismissedToken, failedToken; event_handler_ = Make(this); if (FAILED(toast->add_Activated(event_handler_.Get(), &activatedToken))) return false; - return SUCCEEDED(toast->add_Dismissed(event_handler_.Get(), &dismissedToken)); + if (FAILED(toast->add_Dismissed(event_handler_.Get(), &dismissedToken))) + return false; + + return SUCCEEDED(toast->add_Failed(event_handler_.Get(), &failedToken)); } /* @@ -262,4 +270,11 @@ IFACEMETHODIMP ToastEventHandler::Invoke( return S_OK; } +IFACEMETHODIMP ToastEventHandler::Invoke( + ABI::Windows::UI::Notifications::IToastNotification* sender, + ABI::Windows::UI::Notifications::IToastFailedEventArgs* e) { + notification_->NotificationFailed(); + return S_OK; +} + } // namespace brightray diff --git a/brightray/browser/win/windows_toast_notification.h b/brightray/browser/win/windows_toast_notification.h index 8a24e44af29f..91f0537a7a9a 100644 --- a/brightray/browser/win/windows_toast_notification.h +++ b/brightray/browser/win/windows_toast_notification.h @@ -27,6 +27,9 @@ using DesktopToastActivatedEventHandler = using DesktopToastDismissedEventHandler = ABI::Windows::Foundation::ITypedEventHandler; +using DesktopToastFailedEventHandler = + ABI::Windows::Foundation::ITypedEventHandler; class WindowsToastNotification { public: @@ -49,6 +52,7 @@ class WindowsToastNotification { void NotificationClicked(); void NotificationDismissed(); + void NotificationFailed(); bool GetToastXml(ABI::Windows::UI::Notifications::IToastNotificationManagerStatics* toastManager, const std::wstring& title, @@ -85,13 +89,15 @@ class WindowsToastNotification { class ToastEventHandler : public RuntimeClass, DesktopToastActivatedEventHandler, - DesktopToastDismissedEventHandler> { + DesktopToastDismissedEventHandler, + DesktopToastFailedEventHandler> { public: ToastEventHandler(WindowsToastNotification* notification); ~ToastEventHandler(); IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, IInspectable* args); IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, ABI::Windows::UI::Notifications::IToastDismissedEventArgs* e); + IFACEMETHODIMP Invoke(ABI::Windows::UI::Notifications::IToastNotification* sender, ABI::Windows::UI::Notifications::IToastFailedEventArgs* e); private: WindowsToastNotification* notification_; // weak ref.