Bug 1567229 - Attempt creating a taskbar pin a second time on Windows 10. r=agashlin

At least for now, this behavior is behind a hidden pref. The intent is to
experiment with the feature and determine that way whether enabling it
permanently is a good idea, and if so the pref gate will be removed in a
separate bug.

This patch depends on bug 1567247 and will fail to build without it.

Differential Revision: https://phabricator.services.mozilla.com/D41100

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Howell 2019-08-21 16:09:46 +00:00
parent 6f1b6a839a
commit ea12a48529
4 changed files with 30 additions and 1 deletions

View File

@ -30,7 +30,7 @@ const INSTALLER_PREFS_BRANCH = "installer.";
// current use (e.g., currently active experiments).
// Only add prefs to this list which are in INSTALLER_PREFS_BRANCH;
// any others will be ignored.
const INSTALLER_PREFS_LIST = [];
const INSTALLER_PREFS_LIST = ["installer.taskbarpin.win10.enabled"];
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"

View File

@ -121,6 +121,11 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro WriteRegStr2
!insertmacro WriteRegDWORD2
; This needs to be inserted after InitHashAppModelId because it uses
; $AppUserModelID and the compiler can't handle using variables lexically before
; they've been declared.
!insertmacro GetInstallerRegistryPref
!include shared.nsh
; Helper macros for ui callbacks. Insert these after shared.nsh

View File

@ -1099,6 +1099,7 @@
${If} ${Errors}
ClearErrors
WriteIniStr "$0" "TASKBAR" "Migrated" "true"
WriteINIStr "$0" "TASKBAR" "Pinned" "true"
${If} ${AtLeastWin7}
; If we didn't run the stub installer, AddTaskbarSC will be empty.
; We determine whether to pin based on whether we're the default
@ -1121,6 +1122,24 @@
${PinToTaskBar}
${EndIf}
${EndIf}
${ElseIf} ${AtLeastWin10}
${GetInstallerRegistryPref} "Software\Mozilla\${AppName}" \
"installer.taskbarpin.win10.enabled" $2
${If} $2 == "true"
; On Windows 10, we may have previously tried to make a taskbar pin
; and failed because the API we tried to use was blocked by the OS.
; We have an option that works in more cases now, so we're going to try
; again, but also record that we've done so by writing "Pinned" into the
; shortcuts log, so that we don't continue to do this repeatedly.
ClearErrors
ReadINIStr $1 "$0" "TASKBAR" "Pinned"
${If} ${Errors}
WriteINIStr "$0" "TASKBAR" "Pinned" "true"
${If} $AddTaskbarSC != "0"
${PinToTaskBar}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
${EndIf}
!macroend

View File

@ -93,6 +93,11 @@ VIAddVersionKey "OriginalFilename" "helper.exe"
!insertmacro WriteRegDWORD2
!insertmacro WriteRegStr2
; This needs to be inserted after InitHashAppModelId because it uses
; $AppUserModelID and the compiler can't handle using variables lexically before
; they've been declared.
!insertmacro GetInstallerRegistryPref
!insertmacro un.ChangeMUIHeaderImage
!insertmacro un.CheckForFilesInUse
!insertmacro un.CleanUpdateDirectories