Bug 1354321 - Rename installer-created shortcuts on update if the branding name has changed. r?agashlin
MozReview-Commit-ID: IB74aVjhQ58
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -75,16 +75,18 @@
${AndIf} ${FileExists} "$SMPROGRAMS\${BrandFullName}.lnk"
FileOpen $0 "$SMPROGRAMS\${BrandFullName}.lnk" a
FileClose $0
${EndIf}
; Adds a pinned Task Bar shortcut (see MigrateTaskBarShortcut for details).
${MigrateTaskBarShortcut}
+ ${UpdateShortcutNames}
+
${RemoveDeprecatedKeys}
${SetAppKeys}
${FixClassKeys}
${SetUninstallKeys}
; Remove files that may be left behind by the application in the
; VirtualStore directory.
@@ -296,16 +298,75 @@
${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \
"$INSTDIR"
${EndIf}
${EndUnless}
!macroend
!define ShowShortcuts "!insertmacro ShowShortcuts"
+; Update the branding information on all shortcuts our installer created,
+; in case the branding has changed between updates.
+; This should only be called sometime after both MigrateStartMenuShortcut
+; and MigrateTaskBarShurtcut
+!macro UpdateShortcutNames
+ ${GetLongPath} "$INSTDIR\uninstall\${SHORTCUTS_LOG}" $R9
+ ${If} ${FileExists} "$R9"
+ ClearErrors
+ ; The entries in the shortcut log are numbered, but we never actually
+ ; create more than one shortcut (or log entry) in each location.
+ ReadINIStr $R8 "$R9" "STARTMENU" "Shortcut0"
+ ${IfNot} ${Errors}
+ ${If} ${FileExists} "$SMPROGRAMS\$R8"
+ ${AndIf} $R8 != "${BrandFullName}.lnk"
+ ShellLink::GetShortCutTarget "$SMPROGRAMS\$R8"
+ Pop $R7
+ ${GetLongPath} "$R7" $R7
+ ${If} "$INSTDIR\${FileMainEXE}" == "$R7"
+ Rename "$SMPROGRAMS\$R8" "$SMPROGRAMS\${BrandFullName}.lnk"
+ WriteINIStr "$R9" "STARTMENU" "Shortcut0" "${BrandFullName}.lnk"
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+
+ ClearErrors
+ ReadINIStr $R8 "$R9" "DESKTOP" "Shortcut0"
+ ${IfNot} ${Errors}
+ ${If} ${FileExists} "$DESKTOP\$R8"
+ ${AndIf} $R8 != "${BrandFullName}.lnk"
+ ShellLink::GetShortCutTarget "$DESKTOP\$R8"
+ Pop $R7
+ ${GetLongPath} "$R7" $R7
+ ${If} "$INSTDIR\${FileMainEXE}" == "$R7"
+ Rename "$DESKTOP\$R8" "$DESKTOP\${BrandFullName}.lnk"
+ WriteINIStr "$R9" "DESKTOP" "Shortcut0" "${BrandFullName}.lnk"
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+
+ ClearErrors
+ ReadINIStr $R8 "$R9" "QUICKLAUNCH" "Shortcut0"
+ ${IfNot} ${Errors}
+ ; "QUICKLAUNCH" actually means a taskbar pin.
+ ${If} ${FileExists} "$QUICKLAUNCH\User Pinned\TaskBar\$R8"
+ ${AndIf} $R8 != "${BrandFullName}.lnk"
+ ShellLink::GetShortCutTarget "$QUICKLAUNCH\User Pinned\TaskBar\$R8"
+ Pop $R7
+ ${GetLongPath} "$R7" $R7
+ ${If} "$INSTDIR\${FileMainEXE}" == "$R7"
+ Rename "$QUICKLAUNCH\User Pinned\TaskBar\$R8" \
+ "$QUICKLAUNCH\User Pinned\TaskBar\${BrandFullName}.lnk"
+ WriteINIStr "$R9" "QUICKLAUNCH" "Shortcut0" "${BrandFullName}.lnk"
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+ ${EndIf}
+!macroend
+!define UpdateShortcutNames "!insertmacro UpdateShortcutNames"
+
!macro AddAssociationIfNoneExist FILE_TYPE KEY
ClearErrors
EnumRegKey $7 HKCR "${FILE_TYPE}" 0
${If} ${Errors}
WriteRegStr SHCTX "SOFTWARE\Classes\${FILE_TYPE}" "" ${KEY}
${EndIf}
WriteRegStr SHCTX "SOFTWARE\Classes\${FILE_TYPE}\OpenWithProgids" ${KEY} ""
!macroend