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
This commit is contained in:
Nicholas Rishel 2022-08-04 21:46:15 +00:00
Родитель faeb79e52f
Коммит 6e432b193e
3 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -85,6 +85,20 @@
<uap:Logo>Assets\Document44x44.png</uap:Logo>
</uap3:Protocol>
</uap3:Extension>
<!-- COM registrations for the notification server. -->
<com:Extension Category="windows.comServer">
<com:ComServer>
<com:SurrogateServer DisplayName="NotificationServer"
AppId="@MOZ_INOTIFICATIONACTIVATION_CLSID@">
<com:Class Id="@MOZ_INOTIFICATIONACTIVATION_CLSID@"
Path="VFS\ProgramFiles\@APPX_INSTDIR@\notificationserver.dll"
ThreadingModel="Both" />
</com:SurrogateServer>
</com:ComServer>
</com:Extension>
<desktop:Extension Category="windows.toastNotificationActivation">
<desktop:ToastNotificationActivation ToastActivatorCLSID="@MOZ_INOTIFICATIONACTIVATION_CLSID@" />
</desktop:Extension>
</Extensions>
</Application>
</Applications>

Просмотреть файл

@ -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)

Просмотреть файл

@ -7,6 +7,8 @@
#include <filesystem>
#include <string>
#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 {