Bug 1794159 - Part 3: Enable MSIX pinning in nsWindowsShellService r=nrishel,nalexander,firefox-desktop-core-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D217763
This commit is contained in:
@@ -1284,6 +1284,33 @@ NS_IMETHODIMP nsWindowsShellService::HasMatchingShortcut(
|
||||
}
|
||||
|
||||
static bool IsCurrentAppPinnedToTaskbarSync(const nsAString& aumid) {
|
||||
// Use new Windows pinning APIs to determine whether or not we're pinned.
|
||||
// If these fail we can safely fall back to the old method for regular
|
||||
// installs however MSIX will always return false.
|
||||
|
||||
// Bug 1911343: Add a check for whether we're looking for a regular pin
|
||||
// or PB pin based on the AUMID value once private browser pinning
|
||||
// is supported on MSIX.
|
||||
// Right now only run this check on MSIX to avoid
|
||||
// false positives when only private browsing is pinned.
|
||||
if (widget::WinUtils::HasPackageIdentity()) {
|
||||
auto pinWithWin11TaskbarAPIResults =
|
||||
IsCurrentAppPinnedToTaskbarWin11(false);
|
||||
switch (pinWithWin11TaskbarAPIResults.result) {
|
||||
case Win11PinToTaskBarResultStatus::NotPinned:
|
||||
return false;
|
||||
break;
|
||||
case Win11PinToTaskBarResultStatus::AlreadyPinned:
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
// Fall through to the old mechanism.
|
||||
// The old mechanism should continue working for non-MSIX
|
||||
// builds.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// There are two shortcut targets that we created. One always matches the
|
||||
// binary we're running as (eg: firefox.exe). The other is the wrapper
|
||||
// for launching in Private Browsing mode. We need to inspect shortcuts
|
||||
@@ -1740,6 +1767,7 @@ static nsresult PinCurrentAppToTaskbarImpl(
|
||||
case Win11PinToTaskBarResultStatus::AlreadyPinned:
|
||||
return NS_OK;
|
||||
|
||||
case Win11PinToTaskBarResultStatus::NotPinned:
|
||||
case Win11PinToTaskBarResultStatus::NotCurrentlyAllowed:
|
||||
case Win11PinToTaskBarResultStatus::Failed:
|
||||
// return NS_ERROR_FAILURE;
|
||||
@@ -1864,12 +1892,6 @@ NS_IMETHODIMP
|
||||
nsWindowsShellService::PinCurrentAppToTaskbarAsync(bool aPrivateBrowsing,
|
||||
JSContext* aCx,
|
||||
dom::Promise** aPromise) {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1712628 tracks implementing
|
||||
// this for MSIX packages.
|
||||
if (widget::WinUtils::HasPackageIdentity()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return PinCurrentAppToTaskbarAsyncImpl(
|
||||
/* aCheckOnly */ false, aPrivateBrowsing, aCx, aPromise);
|
||||
}
|
||||
@@ -1877,12 +1899,6 @@ nsWindowsShellService::PinCurrentAppToTaskbarAsync(bool aPrivateBrowsing,
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::CheckPinCurrentAppToTaskbarAsync(
|
||||
bool aPrivateBrowsing, JSContext* aCx, dom::Promise** aPromise) {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1712628 tracks implementing
|
||||
// this for MSIX packages.
|
||||
if (widget::WinUtils::HasPackageIdentity()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
return PinCurrentAppToTaskbarAsyncImpl(
|
||||
/* aCheckOnly = */ true, aPrivateBrowsing, aCx, aPromise);
|
||||
}
|
||||
@@ -1890,12 +1906,6 @@ nsWindowsShellService::CheckPinCurrentAppToTaskbarAsync(
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::IsCurrentAppPinnedToTaskbarAsync(
|
||||
const nsAString& aumid, JSContext* aCx, /* out */ dom::Promise** aPromise) {
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=1712628 tracks implementing
|
||||
// this for MSIX packages.
|
||||
if (widget::WinUtils::HasPackageIdentity()) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (!NS_IsMainThread()) {
|
||||
return NS_ERROR_NOT_SAME_THREAD;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user