summaryrefslogtreecommitdiffstats
path: root/browser/components/shell/nsWindowsShellService.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/shell/nsWindowsShellService.cpp')
-rw-r--r--browser/components/shell/nsWindowsShellService.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/browser/components/shell/nsWindowsShellService.cpp b/browser/components/shell/nsWindowsShellService.cpp
index 86c7694bf8..f7bca95b09 100644
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -39,6 +39,7 @@
#include "nsIXULAppInfo.h"
#include "nsINIParser.h"
#include "nsNativeAppSupportWin.h"
+#include "Windows11TaskbarPinning.h"
#include <windows.h>
#include <shellapi.h>
@@ -1626,7 +1627,7 @@ nsWindowsShellService::GetTaskbarTabPins(nsTArray<nsString>& aShortcutPaths) {
static nsresult PinCurrentAppToTaskbarWin10(bool aCheckOnly,
const nsAString& aAppUserModelId,
- nsAutoString aShortcutPath) {
+ const nsAString& aShortcutPath) {
// The behavior here is identical if we're only checking or if we try to pin
// but the app is already pinned so we update the variable accordingly.
if (!aCheckOnly) {
@@ -1695,6 +1696,28 @@ static nsresult PinCurrentAppToTaskbarImpl(
}
}
+ auto pinWithWin11TaskbarAPIResults =
+ PinCurrentAppToTaskbarWin11(aCheckOnly, aAppUserModelId, shortcutPath);
+ switch (pinWithWin11TaskbarAPIResults.result) {
+ case Win11PinToTaskBarResultStatus::NotSupported:
+ // Fall through to the win 10 mechanism
+ break;
+
+ case Win11PinToTaskBarResultStatus::Success:
+ case Win11PinToTaskBarResultStatus::AlreadyPinned:
+ return NS_OK;
+
+ case Win11PinToTaskBarResultStatus::NotCurrentlyAllowed:
+ case Win11PinToTaskBarResultStatus::Failed:
+ // return NS_ERROR_FAILURE;
+
+ // Fall through to the old mechanism for now
+ // In future, we should be sending telemetry for when
+ // an error occurs or for when pinning is not allowed
+ // with the Win 11 APIs.
+ break;
+ }
+
return PinCurrentAppToTaskbarWin10(aCheckOnly, aAppUserModelId, shortcutPath);
}
@@ -1720,7 +1743,7 @@ static nsresult PinCurrentAppToTaskbarAsyncImpl(bool aCheckOnly,
}
nsAutoString aumid;
- if (NS_WARN_IF(!mozilla::widget::WinTaskbar::GenerateAppUserModelID(
+ if (NS_WARN_IF(!mozilla::widget::WinTaskbar::GetAppUserModelID(
aumid, aPrivateBrowsing))) {
return NS_ERROR_FAILURE;
}