diff --git a/browser/installer/windows/nsis/installer.nsi b/browser/installer/windows/nsis/installer.nsi index 24907e25f15af..9e51088ce108b 100644 --- a/browser/installer/windows/nsis/installer.nsi +++ b/browser/installer/windows/nsis/installer.nsi @@ -52,6 +52,7 @@ Var FinishPhaseStart Var FinishPhaseEnd Var InstallResult Var LaunchedNewApp +Var PostSigningData ; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for ; an application's Start Menu PROGRAMS directory and doesn't define the @@ -98,6 +99,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe" !insertmacro CheckForFilesInUse !insertmacro CleanUpdateDirectories !insertmacro CopyFilesFromDir +!insertmacro CopyPostSigningData !insertmacro CreateRegKey !insertmacro GetFirstInstallPath !insertmacro GetLongPath @@ -742,6 +744,23 @@ Section "-InstallEndCleanup" DetailPrint "$(STATUS_CLEANUP)" SetDetailsPrint none + ; Maybe copy the post-signing data? + StrCpy $PostSigningData "" + ${GetParameters} $0 + ClearErrors + ; We don't get post-signing data from the MSI. + ${GetOptions} $0 "/LaunchedFromMSI" $1 + ${If} ${Errors} + ; The stub will handle copying the data if it ran us. + ClearErrors + ${GetOptions} $0 "/LaunchedFromStub" $1 + ${If} ${Errors} + ; We're being run standalone, copy the data. + ${CopyPostSigningData} + Pop $PostSigningData + ${EndIf} + ${EndIf} + ${Unless} ${Silent} ClearErrors ${MUI_INSTALLOPTIONS_READ} $0 "summary.ini" "Field 4" "State" @@ -1157,6 +1176,16 @@ Function SendPing nsJSON::Set /tree ping "Data" "finish_time" /value "$1" ${EndIf} + ; $PostSigningData should only be empty if we didn't try to copy the + ; postSigningData file at all. If we did try and the file was missing + ; or empty, this will be "0", and for consistency with the stub we will + ; still submit it. + ${If} $PostSigningData != "" + nsJSON::Quote /always $PostSigningData + Pop $0 + nsJSON::Set /tree ping "Data" "attribution" /value $0 + ${EndIf} + nsJSON::Set /tree ping "Data" "new_launched" /value "$LaunchedNewApp" nsJSON::Set /tree ping "Data" "succeeded" /value false diff --git a/browser/installer/windows/nsis/stub.nsi b/browser/installer/windows/nsis/stub.nsi index cdc7ed1bbb621..1341f4dea6816 100644 --- a/browser/installer/windows/nsis/stub.nsi +++ b/browser/installer/windows/nsis/stub.nsi @@ -243,6 +243,7 @@ Var ArchToInstall !include "common.nsh" +!insertmacro CopyPostSigningData !insertmacro ElevateUAC !insertmacro GetLongPath !insertmacro GetPathFromString @@ -1287,7 +1288,9 @@ Function FinishInstall StrCpy $ExitCode "${ERR_SUCCESS}" - Call CopyPostSigningData + ${CopyPostSigningData} + Pop $PostSigningData + Call LaunchApp FunctionEnd @@ -1440,17 +1443,6 @@ Function WaitForAppLaunch ${EndIf} FunctionEnd -Function CopyPostSigningData - ${LineRead} "$EXEDIR\postSigningData" "1" $PostSigningData - ${If} ${Errors} - ClearErrors - StrCpy $PostSigningData "0" - ${Else} - CreateDirectory "$LOCALAPPDATA\Mozilla\Firefox" - CopyFiles /SILENT "$EXEDIR\postSigningData" "$LOCALAPPDATA\Mozilla\Firefox" - ${Endif} -FunctionEnd - Function DisplayDownloadError WebBrowser::CancelTimer $TimerHandle ; To better display the error state on the taskbar set the progress completed diff --git a/toolkit/mozapps/installer/windows/nsis/common.nsh b/toolkit/mozapps/installer/windows/nsis/common.nsh index 663c728cf6536..941e0fc6e8691 100644 --- a/toolkit/mozapps/installer/windows/nsis/common.nsh +++ b/toolkit/mozapps/installer/windows/nsis/common.nsh @@ -7851,6 +7851,40 @@ end: !endif !macroend +/** + * Copy the post-signing data, which was left alongside the installer + * by the self-extractor stub, into the global location for this data. + * + * If the post-signing data file doesn't exist, or is empty, "0" is + * pushed on the stack, and nothing is copied. + * Otherwise the first line of the post-signing data (including newline, + * if any) is pushed on the stack. + */ +!macro CopyPostSigningData + !ifndef ${_MOZFUNC_UN}CopyPostSigningData + !verbose push + !verbose ${_MOZFUNC_VERBOSE} + !define ${_MOZFUNC_UN}CopyPostSigningData "Call ${_MOZFUNC_UN}CopyPostSigningData" + + Function CopyPostSigningData + Push $0 ; Stack: old $0 + + ${LineRead} "$EXEDIR\postSigningData" "1" $0 + ${If} ${Errors} + ClearErrors + StrCpy $0 "0" + ${Else} + CreateDirectory "$LOCALAPPDATA\Mozilla\Firefox" + CopyFiles /SILENT "$EXEDIR\postSigningData" "$LOCALAPPDATA\Mozilla\Firefox" + ${Endif} + + Exch $0 ; Stack: postSigningData + FunctionEnd + + !verbose pop + !endif +!macroend + ################################################################################ # Helpers for taskbar progress