From 6e432b193e734f3af0530149232cac63eac007de Mon Sep 17 00:00:00 2001 From: Nicholas Rishel Date: Thu, 4 Aug 2022 21:46:15 +0000 Subject: [PATCH] Bug 1782818 - Use COM notification server for toast notifications in MSIX packages. r=nalexander,Jamie This converges Windows native notification behavior across all installers to use the COM notification server. This also fixes an issue where interacting with an MSIX notification opened a new window with new tabs correlated to the toast notification launch arguments. MSIX by default calls the application sending a notification with the provided launch arugments, which was an problem as we use launch arguments in the COM server to reconstruct the origin of a notification. Differential Revision: https://phabricator.services.mozilla.com/D153538 --- .../installer/windows/msix/AppxManifest.xml.in | 14 ++++++++++++++ python/mozbuild/mozbuild/repackaging/msix.py | 2 ++ .../NotificationComServer.cpp | 17 ++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/browser/installer/windows/msix/AppxManifest.xml.in b/browser/installer/windows/msix/AppxManifest.xml.in index 845db766f4d9..74b14226189d 100644 --- a/browser/installer/windows/msix/AppxManifest.xml.in +++ b/browser/installer/windows/msix/AppxManifest.xml.in @@ -85,6 +85,20 @@ Assets\Document44x44.png + + + + + + + + + + + diff --git a/python/mozbuild/mozbuild/repackaging/msix.py b/python/mozbuild/mozbuild/repackaging/msix.py index 1baa06455157..b6b279c13549 100644 --- a/python/mozbuild/mozbuild/repackaging/msix.py +++ b/python/mozbuild/mozbuild/repackaging/msix.py @@ -631,6 +631,8 @@ def repackage_msix( "APPX_VERSION": version, "MOZ_APP_DISPLAYNAME": displayname, "MOZ_APP_NAME": app_name, + # Keep synchronized with `toolkit\mozapps\notificationserver\NotificationComServer.cpp`. + "MOZ_INOTIFICATIONACTIVATION_CLSID": "916f9b5d-b5b2-4d36-b047-03c7a52f81c8", } defines.update(brandingUuids) diff --git a/toolkit/mozapps/notificationserver/NotificationComServer.cpp b/toolkit/mozapps/notificationserver/NotificationComServer.cpp index 35a8aa46d31a..184b55be44cc 100644 --- a/toolkit/mozapps/notificationserver/NotificationComServer.cpp +++ b/toolkit/mozapps/notificationserver/NotificationComServer.cpp @@ -7,6 +7,8 @@ #include #include +#include "mozilla/WinHeaderOnlyUtils.h" + #include "NotificationFactory.h" using namespace std::filesystem; @@ -41,10 +43,23 @@ bool PopulateDllPath(HINSTANCE dllInstance) { // requested we verify the CLSID's InprocServer registry entry matches this // DLL's path. bool CheckRuntimeClsid(REFCLSID rclsid) { + // MSIX Notification COM Server registration is isolated to the package and is + // identical across installs/channels. + if (mozilla::HasPackageIdentity()) { + // Keep synchronized with `python\mozbuild\mozbuild\repackaging\msix.py`. + constexpr CLSID MOZ_INOTIFICATIONACTIVATION_CLSID = { + 0x916f9b5d, + 0xb5b2, + 0x4d36, + {0xb0, 0x47, 0x03, 0xc7, 0xa5, 0x2f, 0x81, 0xc8}}; + + return IsEqualCLSID(rclsid, MOZ_INOTIFICATIONACTIVATION_CLSID); + } + std::wstring clsid_str; { wchar_t* raw_clsid_str; - if (StringFromCLSID(rclsid, &raw_clsid_str) == S_OK) { + if (SUCCEEDED(StringFromCLSID(rclsid, &raw_clsid_str))) { clsid_str += raw_clsid_str; CoTaskMemFree(raw_clsid_str); } else {