Commit Graph
87 Commits
Author SHA1 Message Date
Kagami Sascha Rosylight ff069ee769 Bug 1912074 - Add more validity checks r=nalexander,nrishel,win-reviewers,gstoll
Differential Revision: https://phabricator.services.mozilla.com/D218776
2024-08-31 10:38:24 +00:00
Iulian Moraru 34d818720f Backed out changeset 056846758066 (bug 1912074) for causing mochitest-chrome failures on test_principal.html. CLOSED TREE 2024-08-23 04:41:22 +03:00
Kagami Sascha Rosylight c3331111b7 Bug 1912074 - Add more validity checks r=nalexander,nrishel
Differential Revision: https://phabricator.services.mozilla.com/D218776
2024-08-22 20:58:46 +00:00
Magnus Melin bbd67965e9 Bug 1898709 - Use GetMostRecentBrowserWindow() instead of GetMostRecentWindow(u"navigator:browser") to cater for Thunderbird's main window. r=nalexander
Based on https://github.com/Betterbird/thunderbird-patches/blob/main/115/bugs/1863798-toast-notification-foreground-mail-client-m-c.patch

Fixed cases where general code assume main window is Firefox.
GetMostRecentBrowserWindow is getting "navigator:browser" for Firefox, so there is no change in behavior,
but it means more things will work for Thunderbird.

Differential Revision: https://phabricator.services.mozilla.com/D211520
2024-05-24 17:43:52 +00:00
Kagami Sascha Rosylight 959a733236 Bug 1848801 - Use system dismiss button for persistent notification r=nrishel,fluent-reviewers,bolsson
Per the documentation the system should handle `arguments=dismiss` to fire dismiss event but somehow it still fires activate event. This patch thus handles it manually while still taking advantage of the Windows provided localization of the button.

Differential Revision: https://phabricator.services.mozilla.com/D198286
2024-01-12 22:16:31 +00:00
Narcis Beleuzu c947c1f9c7 Backed out changeset e92a8f339bfc (bug 1848801) for xpcshell failures on test_windows_alert_service.js . CLOSED TREE 2024-01-12 19:43:32 +02:00
Kagami Sascha Rosylight 24f08dfcaa Bug 1848801 - Use system dismiss button for persistent notification r=nrishel,fluent-reviewers,bolsson
Per the documentation the system should handle `arguments=dismiss` to fire dismiss event but somehow it still fires activate event. This patch thus handles it manually.

Differential Revision: https://phabricator.services.mozilla.com/D198286
2024-01-12 14:05:39 +00:00
Nicholas Rishel 32025f3198 Bug 1870757 - Add image placement attribute to nsIWindowsAlertNotification. r=nalexander,mhughes
Adds option to specify Windows toast image placement for notifications popped from the system principal.

Differential Revision: https://phabricator.services.mozilla.com/D197029
2023-12-27 21:49:33 +00:00
Nicholas Rishel 7f1d4a56ca Bug 1870754 - Initialize gfx when popping a notification from a background task. r=nalexander,mhughes
This prevents a failed debug assertion in the image decoder due to color management attempting to initialize off the main thread. This is only an issue for debug builds, release builds instead return an error in color management initialization and otherwise continue on to decode the image correctly.

Differential Revision: https://phabricator.services.mozilla.com/D197028
2023-12-27 21:49:33 +00:00
Nicholas Rishel e32a9e9359 Bug 1871210 - Extend AlertNotification with WindowsAlertNotification for custom handling of alert buttons on Windows. r=nalexander,mhughes
When `nsIWindowsAlertNotification`'s `handleActions` property is set to true, actions are sent in the notification observer's `aData` field instead of the notification cookie.

Differential Revision: https://phabricator.services.mozilla.com/D196613
2023-12-27 21:49:32 +00:00
Masatoshi Kimura a3e419385e Bug 1844908 - Remove pre-Win10-specific codepath from widget/. r=handyman
Differential Revision: https://phabricator.services.mozilla.com/D184307
2023-07-26 08:52:54 +00:00
Natalia Csoregi 42e803a2dd Backed out 19 changesets (bug 1844908) for causing win bustage on AvailableMemoryTracker.cpp. CLOSED TREE
Backed out changeset 44c66f2233cf (bug 1844908)
Backed out changeset a8010ff534bf (bug 1844908)
Backed out changeset 225dc3aeb220 (bug 1844908)
Backed out changeset a1414db64e33 (bug 1844908)
Backed out changeset 7f1e0a527839 (bug 1844908)
Backed out changeset 6dc7646d1ffa (bug 1844908)
Backed out changeset 8d715131510f (bug 1844908)
Backed out changeset 4b6fe8a4e7db (bug 1844908)
Backed out changeset 2b419fabf1e8 (bug 1844908)
Backed out changeset af84e701d616 (bug 1844908)
Backed out changeset 2fa203969ec5 (bug 1844908)
Backed out changeset 2b3d2df94db3 (bug 1844908)
Backed out changeset 7eca452f5fd7 (bug 1844908)
Backed out changeset 3d961cf25afe (bug 1844908)
Backed out changeset 3c59143f8dd7 (bug 1844908)
Backed out changeset ab50c6c5425a (bug 1844908)
Backed out changeset b2c5636df673 (bug 1844908)
Backed out changeset e9a0f1c6760c (bug 1844908)
Backed out changeset 945ccbedde0b (bug 1844908)
2023-07-25 19:55:35 +03:00
Masatoshi Kimura 4182954d50 Bug 1844908 - Remove pre-Win10-specific codepath from widget/. r=handyman
Differential Revision: https://phabricator.services.mozilla.com/D184307
2023-07-25 14:41:05 +00:00
Kagami Sascha Rosylight 170742cea9 Bug 1794475 - Part 1: Add a default dismiss button when there's no action r=nrishel,fluent-reviewers,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D183516
2023-07-19 20:31:13 +00:00
Butkovits Atila f773399141 Backed out 3 changesets (bug 1794475) for causing failures at test_windows_alert_service.js. CLOSED TREE
Backed out changeset 0c549a545b3f (bug 1794475)
Backed out changeset e0afefa32c0e (bug 1794475)
Backed out changeset 39012036cf49 (bug 1794475)
2023-07-19 16:53:20 +03:00
Kagami Sascha Rosylight e88a3b0d3e Bug 1794475 - Part 1: Add a default dismiss button when there's no action r=nrishel,fluent-reviewers,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D183516
2023-07-19 11:50:08 +00:00
Nick Alexander 9f2bea61fe Bug 1805514 - Part 3: Allow JS opaque relaunch data and actions. r=nrishel
This commit replaces two existing launch argument keys, `launchURL`
and `privilegedName`, with an opaque string of data.  Here opaque
means, "does not need to be inspected by the Windows notification
server DLL" (and in general, by the system backend components).

The existing `action` argument key was always intended for this
purpose but was not used in the first implementation.  Here, we make
`action` a stringified JSON object, which is easy for API consumers to
manage and generalizes to (mostly) arbitrary relaunch data.

This JSON object is a compound `notificationData` object containing
both:
- the consumer-provided `opaqueRelaunchData` (generally, an action);
- and implementation-provided details (the alert's name, if
  privileged, etc).
This compound object and the fact that everything transits as strings
makes everything a little more confusing than it really is.

The API to this opaque relaunch data is based on strings for
convenience.  It would be possible to manage JSON objects, perhaps by
using `nsIStructuredCloneContainer` to serialize "structured clone
encodable" JS objects across the process boundaries, but managing the
objects and container in that approach is much more effort than having
the API consumer stringify as desired.

In addition, this patch makes the notification server extract the
Firefox `action` data from the Windows toast `arguments` passed to the
server callback.  Since this fallback data is now provided to Firefox
at launch, there's no need to fetch it from the Windows notification
object; we simply need to know whether to pass through to a Windows
8.1 callback (`tagWasHandled=true`) or to act on the fallback data
(`tagWasHandled=false`).  This is simpler than teaching Firefox to
extract the arguments for toast itself or the appropriate action
button.

Differential Revision: https://phabricator.services.mozilla.com/D182314
2023-07-15 02:34:06 +00:00
Nicholas Rishel 02b52857e9 Bug 1822817 - Post: Log when Windows native notifications fail. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D173497
2023-03-31 17:30:15 +00:00
Nicholas Rishel 1655e0eda1 Bug 1822817 - Part 2: Fix Windows 8 notification images not showing. r=nalexander,cmartin
Use PNGs instead of BMPs for Windows toast notification images.

BMPs were isolated as the cause of Windows toasts failing to display images when provided in the `src` attribute of the `<image>` tag for Windows 8. The same was not observed for PNGs.

This issue only affects Windows 8.

Differential Revision: https://phabricator.services.mozilla.com/D173787
2023-03-31 17:30:15 +00:00
Nicholas Rishel 6ce88ebe57 Bug 1822817 - Part 1: Fix Windows 8 native notifications failing. r=nalexander
`IToastNotification2` is not available in Windows 8, so querying it caused the toast to fail. When the content was only text, the toast would immediately fail triggering a fallback to XUL style alerts. When it contained an image, the async image load caused the toast to fail after the fallback branch had been decided.

The toast tag assigned and retrieved from `IToastNotification2` is used by Windows to track notifications in the Action Center and is only relevant in the context of Windows 10+.

Differential Revision: https://phabricator.services.mozilla.com/D173496
2023-03-31 17:30:14 +00:00
Nicholas Rishel adb4b17d6c Bug 1822842 - Trim down notification server event viewer logging unless alerts.useSystemBackend.windows.notificationserver.verbose=true. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D173076
2023-03-22 18:25:55 +00:00
Matthew Noorenberghe 2aea99c96d Bug 1073717 - [Web Notifications] Add support for "silent" toast notifications on Windows. r=mhowell
Depends on D119590

Differential Revision: https://phabricator.services.mozilla.com/D119591
2023-01-07 01:03:53 +00:00
Nicholas Rishel 5e00cc71c7 Bug 1797679 - Fall back to launching a new tab to the host port for Windows native notifications abandoned due to closed tabs. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D160460
2023-01-06 18:36:24 +00:00
Nicholas Rishel 2bb46b9407 Bug 1787004 - Pre: Refactor logic for hiding private notifications when the private browsing context is closed to share code from cleaning up notification data when the application quits. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D162178
2023-01-06 18:36:23 +00:00
Nicholas Rishel e13b7bedad Bug 1795974 - Pre 2: Create Windows Toast Notifications utility header to share strings and functionality between the firefox.exe and notificationserver.dll. r=nalexander
Differential Revision: https://phabricator.services.mozilla.com/D165350
2023-01-06 18:36:22 +00:00
Nicholas Rishel 7baa4a7cb4 Bug 1797678 - Pre 1: Clean up ToastNotificationHandler.cpp. r=nalexander
`nullptr` check cleanup, simplified string conversions, renames.

Differential Revision: https://phabricator.services.mozilla.com/D160456
2023-01-06 18:36:21 +00:00
Nick Alexander 39515d47e6 Bug 1790692 - Make image smaller DOM notifications/non-system (chrome-privileged) alerts. r=nrishel
This is a partial reversion of Bug 1775135.

Differential Revision: https://phabricator.services.mozilla.com/D157362
2022-09-15 23:32:10 +00:00
Iulian Moraru 039dbaec45 Backed out changeset fe1aceefa7ac (bug 1790692) for causing xpcshell failures on test_windows_alert_service.js. CLOSED TREE 2022-09-15 20:35:03 +03:00
Nick Alexander 7950d56584 Bug 1790692 - Make image smaller for DOM notifications/non-system (chrome-privileged) alerts. r=nrishel
This is a partial reversion of Bug 1775135.

Differential Revision: https://phabricator.services.mozilla.com/D157362
2022-09-15 16:57:35 +00:00
Nicholas Rishel 8833631bbc Bug 1786578 - Dismiss Windows native toast notifications when Firefox is closed in a private browsing session. r=nalexander.
Prior to this commit the `ToastNotification`'s observer registration doesn't work due to `ToastNotification` not implementing `nsIWeakReference` while attempting to register itself as an observer as a weak reference.

Differential Revision: https://phabricator.services.mozilla.com/D155764
2022-09-14 20:48:48 +00:00
Nick Alexander 134f373fce Bug 1775135 - Make Windows native toasts use "ToastGeneric" template. r=nrishel
The immediate effect is to make any image larger and more prominent.
This might not be the right option for regular DOM notifications,
which support only `icon` (and not `image`) in Firefox at this time,
but we can adjust (perhaps limiting the generic template to privileged
alerts) as we need in the future.

Differential Revision: https://phabricator.services.mozilla.com/D156873
2022-09-13 02:43:17 +00:00
Nick Alexander b85602e1a7 Bug 1788960 - Part 1: Round trip name for privileged alerts through Firefox restart. r=nrishel
On Windows, when an alert is privileged and `name` is non-empty, round
trip its `name` (as `privilegedName`) through the Windows notification
mechanism, and provide it to the "relaunch" callback.

Differential Revision: https://phabricator.services.mozilla.com/D156636
2022-09-13 02:43:17 +00:00
Nick Alexander 5025b0ded2 Bug 1781929 - Part 4: Pass through or launch Firefox from notification server. r=nrishel
When the notification server callback is executed by the Windows
notification system, it invokes Firefox with additional command line
parameters, most importantly the Windows-specific notification
"Windows tag".

If no appropriate Firefox is running, the command line will be
processed, the provided Windows tag will be inspected (and seen to not
be registered with this running Firefox instance) and a "launch URL"
stored as part of the Windows notification itself opened (if one is
provided).

If an appropriate Firefox is running, the remoting protocol will
forward this command line to the running instance.  If the instance
recognizes the provided `--notification-windowsTag`, the command line
will be ignored.  When the notification server exits, Windows will
fallback to the Windows 8.1 style notification callbacks registered
for this Windows tag and the existing (non notification server)
behaviour will occur.

In fact, the server therefore waits for a Windows tag-specific system
event to be signalled by the invoked Firefox (or a sibling process).
If we were to return `S_OK` from the notification server immediately,
and a running Firefox process would handle the notification via
Windows 8.1-style notification callbacks, then Windows would fall back
to those callbacks.  The invoked callbacks unregister themselves upon
completion, often before the launched Firefox has an opportunity to
process the command line.  By waiting for this system event, we allow
the invoked Firefox to process the command line while its own
notification callbacks are registered and therefore recognize that its
callbacks will handle the notification.

Differential Revision: https://phabricator.services.mozilla.com/D154468
2022-09-03 22:49:02 +00:00
Nick Alexander cf5c239c63 Bug 1781929 - Part 3: Include launchUrl in Windows toast notification. r=nrishel
Differential Revision: https://phabricator.services.mozilla.com/D155909
2022-09-03 22:49:01 +00:00
Nick Alexander da503dec10 Bug 1781929 - Part 1: Handle toast notifications from background tasks specially. r=nrishel
In background task mode:

1. Re-launch Firefox into the default browsing profile, not the
   (possibly ephemeral) background task profile.
2. Don't show the in-product notification settings, which won't apply
   to the relevant Firefox profile.

Differential Revision: https://phabricator.services.mozilla.com/D155908
2022-09-03 22:49:00 +00:00
Nicholas Rishel 9719573e49 Bug 1784367 - Prevent duplicate Windows notifications from occuring due to multiple tabs receiving same notification. r=nalexander
Use the existing mName field of alert which includes the host port and tag (or uuid) for Windows notification tag.

When a notification originates from the browser chrome, generate an identify on the fly as before.

The tag is hashed in order to fit the 16 character limit for tags. Note the limit was bumped to 64 in Windows 10 Creators Update.

Differential Revision: https://phabricator.services.mozilla.com/D155140
2022-09-03 22:49:00 +00:00
Marian-Vasile Laza 48f9a164c7 Backed out 5 changesets (bug 1781929, bug 1784367) for causing bc test failures. CLOSED TREE
Backed out changeset 34003f6f7b27 (bug 1781929)
Backed out changeset 8e6fe1c18e8d (bug 1781929)
Backed out changeset e50432e37751 (bug 1781929)
Backed out changeset abf6eff708d8 (bug 1781929)
Backed out changeset 15fec49b7587 (bug 1784367)
2022-09-03 02:26:04 +03:00
Nick Alexander 6249d25e59 Bug 1781929 - Part 4: Pass through or launch Firefox from notification server. r=nrishel
When the notification server callback is executed by the Windows
notification system, it invokes Firefox with additional command line
parameters, most importantly the Windows-specific notification
"Windows tag".

If no appropriate Firefox is running, the command line will be
processed, the provided Windows tag will be inspected (and seen to not
be registered with this running Firefox instance) and a "launch URL"
stored as part of the Windows notification itself opened (if one is
provided).

If an appropriate Firefox is running, the remoting protocol will
forward this command line to the running instance.  If the instance
recognizes the provided `--notification-windowsTag`, the command line
will be ignored.  When the notification server exits, Windows will
fallback to the Windows 8.1 style notification callbacks registered
for this Windows tag and the existing (non notification server)
behaviour will occur.

In fact, the server therefore waits for a Windows tag-specific system
event to be signalled by the invoked Firefox (or a sibling process).
If we were to return `S_OK` from the notification server immediately,
and a running Firefox process would handle the notification via
Windows 8.1-style notification callbacks, then Windows would fall back
to those callbacks.  The invoked callbacks unregister themselves upon
completion, often before the launched Firefox has an opportunity to
process the command line.  By waiting for this system event, we allow
the invoked Firefox to process the command line while its own
notification callbacks are registered and therefore recognize that its
callbacks will handle the notification.

Differential Revision: https://phabricator.services.mozilla.com/D154468
2022-09-02 20:22:51 +00:00
Nick Alexander a6846e3c69 Bug 1781929 - Part 3: Include launchUrl in Windows toast notification. r=nrishel
Differential Revision: https://phabricator.services.mozilla.com/D155909
2022-09-02 20:22:51 +00:00
Nick Alexander 7ff452aa93 Bug 1781929 - Part 1: Handle toast notifications from background tasks specially. r=nrishel
In background task mode:

1. Re-launch Firefox into the default browsing profile, not the
   (possibly ephemeral) background task profile.
2. Don't show the in-product notification settings, which won't apply
   to the relevant Firefox profile.

Differential Revision: https://phabricator.services.mozilla.com/D155908
2022-09-02 20:22:50 +00:00
Nicholas Rishel 01b77311c1 Bug 1784367 - Prevent duplicate Windows notifications from occuring due to multiple tabs receiving same notification. r=nalexander
Use the existing mName field of alert which includes the host port and tag (or uuid) for Windows notification tag.

When a notification originates from the browser chrome, generate an identify on the fly as before.

The tag is hashed in order to fit the 16 character limit for tags. Note the limit was bumped to 64 in Windows 10 Creators Update.

Differential Revision: https://phabricator.services.mozilla.com/D155140
2022-09-02 20:22:49 +00:00
Nick Alexander 57136875f1 Bug 1787573 - Allow privileged Windows native notification actions to have activationType="system". r=nrishel,smaug
This allows Windows native notification action buttons to access the
built-in "dismiss" and "snooze" support without requiring a Firefox
invocation.

Differential Revision: https://phabricator.services.mozilla.com/D155906
2022-09-01 22:48:21 +00:00
Nicholas Rishel 36ff5ff2a5 Bug 1787015 - Consolidate raw COM pointers into smart ComPtr. r=nalexander
Also moved from `typedef` to `using _ =` syntax to match new templated import of `ComPtr` in ToastNotificationHandler.h.

Depends on D155525

Differential Revision: https://phabricator.services.mozilla.com/D155526
2022-08-24 22:32:02 +00:00
Nicholas Rishel 2639adf9f4 Bug 1787001 - Fix leaking COM object. r=nalexander
`ComPtr` constructor increments the refcount when initializing with a raw COM pointer.

Differential Revision: https://phabricator.services.mozilla.com/D155525
2022-08-24 22:32:02 +00:00
Nicholas Rishel a96823cad4 Bug 1774083 - Part 4: Prepend Windows toast launch arguments to the toast action arguments. r=nalexander
Windows toast actions (buttons) override the launch argument. The launch arguments are necessary for the notification server to reconstruct the source of the toast, therefore we prepend it to the action argument.

Differential Revision: https://phabricator.services.mozilla.com/D152466
2022-08-02 19:40:40 +00:00
Nicholas Rishel a10fe6ef6f Bug 1774083 - Part 3: Allow Windows notifications to persist after dismissed by timeout. r=nalexander
Adds a GUID to the notification's launch attribute too verify a timeout dismissed event doesn't remain in the Action Center.

Remove event hiding to allow notifications to be acted upon after the page or browser is closed.

Differential Revision: https://phabricator.services.mozilla.com/D151741
2022-08-02 19:40:39 +00:00
Nicholas Rishel ccf09c982e Bug 1774083 - Part 2: Launch Firefox from notification COM server when activation event occurs. r=nalexander
Adds `program` and `profile` paths to Windows toast notifications so that the COM server can reconstruct the origin in order to relaunch the application.

Differential Revision: https://phabricator.services.mozilla.com/D151740
2022-08-02 19:40:39 +00:00
Nicholas Rishel f1906f8871 Bug 1774082 - Add AUMID handling for Windows toast notifications. r=nalexander
For MSIX packages, the package AUMID is used.

For NSIS/MSI installs, AUMID is retrieve from HKCR.

For portable builds, the registry is updated at runtime to populate icons, display name, and the COM server.

The COM server has been registered as will be implemented using DllSurrogate; this allows us to offload managing the eventloop and lifetime of the COM server to dllhost.exe, and minimizes the added code complexity.

The COM server is loaded as a separate executable from the sending process to prevent issues that would occur when multiple instances of the sending process (e.g. profiles running in parallel) try to stand up parallel COM servers. The separated COM executable also allows for multiple applications to share a common COM server.

Bonus: fixes Bug 1500054, Bug 1766095, and Bug 1743424.

Differential Revision: https://phabricator.services.mozilla.com/D151739
2022-08-02 19:40:38 +00:00
Iulian Moraru c4ef492a26 Backed out 6 changesets (bug 1774083, bug 1774082) for causing xpcshell failures. CLOSED TREE
Backed out changeset 4056bc743e25 (bug 1774083)
Backed out changeset ad20680728cc (bug 1774083)
Backed out changeset 173c4519227f (bug 1774083)
Backed out changeset 54beca69e971 (bug 1774083)
Backed out changeset 1d9d80c75d9d (bug 1774082)
Backed out changeset 7b03aa4c49d1 (bug 1774082)
2022-08-02 02:46:47 +03:00
Nicholas Rishel 501b2179c7 Bug 1774083 - Part 4: Prepend Windows toast launch arguments to the toast action arguments. r=nalexander
Windows toast actions (buttons) override the launch argument. The launch arguments are necessary for the notification server to reconstruct the source of the toast, therefore we prepend it to the action argument.

Differential Revision: https://phabricator.services.mozilla.com/D152466
2022-08-01 21:38:07 +00:00