Bug 1592968 - Use the registry to record creating a taskbar pin. r=agashlin
authorMolly Howell <mhowell@mozilla.com>
Thu, 14 Nov 2019 21:10:07 +0000
changeset 502058 2556a28ab75a074ba8a7ef30e5360cb66a18e04c
parent 502057 8fa2316b02404d9fde7a88fe6948df683a2f84a0
child 502059 d519e5920a23a531269fec72a0ef440674692603
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagashlin
bugs1592968
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1592968 - Use the registry to record creating a taskbar pin. r=agashlin My initial idea of using the shortcuts log to store this information didn't work out because the helper, when run by an updater which was run by the maintenance service, doesn't get write permissions on that file. Differential Revision: https://phabricator.services.mozilla.com/D52276
browser/installer/windows/nsis/shared.nsh
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -1090,24 +1090,36 @@
 ; Adds a pinned shortcut to Task Bar on update for Windows 7 and above if this
 ; macro has never been called before and the application is default (see
 ; PinToTaskBar for more details).
 ; Since defaults handling is handled by Windows in Win8 and later, we always
 ; attempt to pin a taskbar on that OS.  If Windows sets the defaults at
 ; installation time, then we don't get the opportunity to run this code at
 ; that time.
 !macro MigrateTaskBarShortcut
+  ; Find out if this is an ESR build or not, because it affects what we've
+  ; named some of our application registry keys.
+  ClearErrors
+  ${WordFind} "${UpdateChannel}" "esr" "E#" $3
+  ${If} ${Errors}
+    StrCpy $3 ""
+  ${Else}
+    StrCpy $3 " ESR"
+  ${EndIf}
+
   ${GetShortcutsLogPath} $0
   ${If} ${FileExists} "$0"
     ClearErrors
     ReadINIStr $1 "$0" "TASKBAR" "Migrated"
     ${If} ${Errors}
       ClearErrors
       WriteIniStr "$0" "TASKBAR" "Migrated" "true"
-      WriteINIStr "$0" "TASKBAR" "Pinned" "true"
+      WriteRegDWORD SHCTX \
+        "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})\Main" \
+        "WasPinnedToTaskbar" 1
       ${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
         ; browser, or if we're on win8 or later, we always pin.
         ${If} $AddTaskbarSC == ""
           ; No need to check the default on Win8 and later
           ${If} ${AtMostWin2008R2}
             ; Check if the Firefox is the http handler for this user
@@ -1127,22 +1139,26 @@
       ${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.
+        ; again, but also record that we've done so by writing a particular
+        ; registry value, so that we don't continue to do this repeatedly.
         ClearErrors
-        ReadINIStr $1 "$0" "TASKBAR" "Pinned"
+        ReadRegDWORD $2 SHCTX \
+            "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})\Main" \
+            "WasPinnedToTaskbar"
         ${If} ${Errors}
-          WriteINIStr "$0" "TASKBAR" "Pinned" "true"
+          WriteRegDWORD SHCTX \
+            "Software\Mozilla\${BrandFullNameInternal}\${AppVersion}$3 (${ARCH} ${AB_CD})\Main" \
+            "WasPinnedToTaskbar" 1
           ${If} $AddTaskbarSC != "0"
             ${PinToTaskBar}
           ${EndIf}
         ${EndIf}
       ${EndIf}
     ${EndIf}
   ${EndIf}
 !macroend