diff --git a/shell/browser/notifications/win/notification_presenter_win.cc b/shell/browser/notifications/win/notification_presenter_win.cc index 39acd451247e..7bf69ec2838d 100644 --- a/shell/browser/notifications/win/notification_presenter_win.cc +++ b/shell/browser/notifications/win/notification_presenter_win.cc @@ -30,9 +30,8 @@ namespace { bool SaveIconToPath(const SkBitmap& bitmap, const base::FilePath& path) { std::optional> png_data = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false); - if (!png_data.has_value()) + if (!png_data.has_value() || !png_data.value().size()) return false; - return base::WriteFile(path, png_data.value()); } @@ -64,8 +63,10 @@ bool NotificationPresenterWin::Init() { std::wstring NotificationPresenterWin::SaveIconToFilesystem( const SkBitmap& icon, const GURL& origin) { - std::string filename; + if (icon.drawsNothing()) + return L""; + std::string filename; if (origin.is_valid()) { filename = base::MD5String(origin.spec()) + ".png"; } else { @@ -75,11 +76,11 @@ std::wstring NotificationPresenterWin::SaveIconToFilesystem( ScopedAllowBlockingForElectron allow_blocking; base::FilePath path = temp_dir_.GetPath().Append(base::UTF8ToWide(filename)); - if (base::PathExists(path)) - return path.value(); - if (SaveIconToPath(icon, path)) - return path.value(); - return base::UTF8ToWide(origin.spec()); + + if (!SaveIconToPath(icon, path)) + return L""; + + return path.value(); } Notification* NotificationPresenterWin::CreateNotificationObject( diff --git a/shell/browser/notifications/win/windows_toast_notification.cc b/shell/browser/notifications/win/windows_toast_notification.cc index fb7e2a132fb1..5eaf88ca2059 100644 --- a/shell/browser/notifications/win/windows_toast_notification.cc +++ b/shell/browser/notifications/win/windows_toast_notification.cc @@ -302,6 +302,7 @@ std::u16string WindowsToastNotification::GetToastXml( // Optional icon as app logo override (small icon). if (!icon_path.empty()) { xml_writer.StartElement(kImage); + xml_writer.AddAttribute(kID, "1"); xml_writer.AddAttribute(kPlacement, kAppLogoOverride); xml_writer.AddAttribute(kHintCrop, kHintCropNone); xml_writer.AddAttribute(kSrc, base::WideToUTF8(icon_path));