Skip to content

Commit

Permalink
Installer stuffs reverted by copying 121 code because I can't redo th…
Browse files Browse the repository at this point in the history
…e revert because I rart
  • Loading branch information
K4sum1 committed Jan 27, 2024
1 parent 621da96 commit f2cb153
Show file tree
Hide file tree
Showing 7 changed files with 634 additions and 282 deletions.
146 changes: 117 additions & 29 deletions browser/installer/windows/nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Var TmpVal
Var InstallType
Var AddStartMenuSC
Var AddTaskbarSC
Var AddQuickLaunchSC
Var AddDesktopSC
Var AddPrivateBrowsingSC
Var InstallMaintenanceService
Expand Down Expand Up @@ -381,20 +382,22 @@ Section "-Application" APP_IDX

ClearErrors

; Apply LPAC permissions to install directory.
${LogHeader} "File access permissions"
Push "Marker"
AccessControl::GrantOnFile \
"$INSTDIR" "(${LpacFirefoxInstallFilesSid})" "GenericRead + GenericExecute"
Pop $TmpVal ; get "Marker" or error msg
${If} $TmpVal == "Marker"
${LogMsg} "Granted access for LPAC to $INSTDIR"
${Else}
${LogMsg} "** Error granting access for LPAC to $INSTDIR : $TmpVal **"
Pop $TmpVal ; get "Marker"
${EndIf}
${If} ${AtLeastWin10}
; Apply LPAC permissions to install directory.
${LogHeader} "File access permissions"
Push "Marker"
AccessControl::GrantOnFile \
"$INSTDIR" "(${LpacFirefoxInstallFilesSid})" "GenericRead + GenericExecute"
Pop $TmpVal ; get "Marker" or error msg
${If} $TmpVal == "Marker"
${LogMsg} "Granted access for LPAC to $INSTDIR"
${Else}
${LogMsg} "** Error granting access for LPAC to $INSTDIR : $TmpVal **"
Pop $TmpVal ; get "Marker"
${EndIf}

ClearErrors
ClearErrors
${EndIf}

; Default for creating Start Menu shortcut
; (1 = create, 0 = don't create)
Expand All @@ -406,6 +409,16 @@ Section "-Application" APP_IDX
StrCpy $AddPrivateBrowsingSC "1"
${EndIf}

; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)
${If} $AddQuickLaunchSC == ""
; Don't install the quick launch shortcut on Windows 7
${If} ${AtLeastWin7}
StrCpy $AddQuickLaunchSC "0"
${Else}
StrCpy $AddQuickLaunchSC "1"
${EndIf}
${EndIf}

; Default for creating Desktop shortcut (1 = create, 0 = don't create)
${If} $AddDesktopSC == ""
StrCpy $AddDesktopSC "1"
Expand Down Expand Up @@ -494,11 +507,13 @@ Section "-Application" APP_IDX
SetShellVarContext all ; Set SHCTX to HKLM

; The keys below can be set in HKCU if needed.
; For pre win8, the following keys should only be set if we can write to HKLM.
; For post win8, the keys below can be set in HKCU if needed.
${If} $TmpVal == "HKLM"
; Set the Start Menu Internet and Registered App HKLM registry keys.
${SetStartMenuInternet} "HKLM"
${FixShellIconHandler} "HKLM"
${Else}
${ElseIf} ${AtLeastWin8}
; Set the Start Menu Internet and Registered App HKCU registry keys.
${SetStartMenuInternet} "HKCU"
${FixShellIconHandler} "HKCU"
Expand Down Expand Up @@ -559,7 +574,9 @@ Section "-Application" APP_IDX
WriteRegDWORD HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Telemetry" 1
!endif

${WriteToastNotificationRegistration} $TmpVal
${If} ${AtLeastWin10}
${WriteToastNotificationRegistration} $TmpVal
${EndIf}

; Create shortcuts
${LogHeader} "Adding Shortcuts"
Expand Down Expand Up @@ -648,14 +665,16 @@ Section "-Application" APP_IDX
; Update lastwritetime of the Start Menu shortcut to clear the tile cache.
; Do this for both shell contexts in case the user has shortcuts in multiple
; locations, then restore the previous context at the end.
SetShellVarContext all
${TouchStartMenuShortcut}
SetShellVarContext current
${TouchStartMenuShortcut}
${If} $TmpVal == "HKLM"
${If} ${AtLeastWin8}
SetShellVarContext all
${ElseIf} $TmpVal == "HKCU"
${TouchStartMenuShortcut}
SetShellVarContext current
${TouchStartMenuShortcut}
${If} $TmpVal == "HKLM"
SetShellVarContext all
${ElseIf} $TmpVal == "HKCU"
SetShellVarContext current
${EndIf}
${EndIf}

${If} $AddDesktopSC == 1
Expand Down Expand Up @@ -684,6 +703,27 @@ Section "-Application" APP_IDX
${EndIf}
${EndIf}

; If elevated the Quick Launch shortcut must be added from the unelevated
; original process.
${If} $AddQuickLaunchSC == 1
${Unless} ${AtLeastWin7}
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/UAC:" $0
${If} ${Errors}
Call AddQuickLaunchShortcut
${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandShortName}.lnk"
${Else}
; It is not possible to add a log entry from the unelevated process so
; add the log entry without the path since there is no simple way to
; know the correct full path.
${LogMsg} "Added Quick Launch Shortcut: ${BrandShortName}.lnk"
GetFunctionAddress $0 AddQuickLaunchShortcut
UAC::ExecCodeSegment $0
${EndIf}
${EndUnless}
${EndIf}

!ifdef MOZ_OPTIONAL_EXTENSIONS
${If} ${FileExists} "$INSTDIR\distribution\optional-extensions"
${LogHeader} "Installing optional extensions if requested"
Expand Down Expand Up @@ -970,6 +1010,14 @@ FunctionEnd
################################################################################
# Helper Functions

Function AddQuickLaunchShortcut
CreateShortCut "$QUICKLAUNCH\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
${If} ${FileExists} "$QUICKLAUNCH\${BrandShortName}.lnk"
ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandShortName}.lnk" \
"$INSTDIR"
${EndIf}
FunctionEnd

Function CheckExistingInstall
; If there is a pending file copy from a previous upgrade don't allow
; installing until after the system has rebooted.
Expand Down Expand Up @@ -1667,15 +1715,55 @@ Function preSummary
DeleteINIStr "$PLUGINSDIR\summary.ini" "Settings" NextButtonText
${EndIf}


; Remove the "Field 4" ini section in case the user hits back and changes the
; installation directory which could change whether the make default checkbox
; should be displayed.
DeleteINISec "$PLUGINSDIR\summary.ini" "Field 4"

; Check if it is possible to write to HKLM
ClearErrors
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
${Unless} ${Errors}
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
; Check if Firefox is the http handler for this user.
SetShellVarContext current ; Set SHCTX to the current user
${IsHandlerForInstallDir} "http" $R9
; If Firefox isn't the http handler for this user show the option to set
; Firefox as the default browser.
${If} "$R9" != "true"
${AndIf} ${AtMostWin2008R2}
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "4"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Type "checkbox"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Text "$(SUMMARY_TAKE_DEFAULTS)"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Left "0"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Right "-1"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" State "1"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Top "32"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Bottom "53"
${EndIf}
${EndUnless}

${If} "$TmpVal" == "true"
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "4"

WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Type "label"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Text "$(SUMMARY_REBOOT_REQUIRED_INSTALL)"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Left "0"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Right "-1"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Top "35"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Bottom "50"
; If there is already a Type entry in the "Field 4" section with a value of
; checkbox then the set as the default browser checkbox is displayed and
; this text must be moved below it.
ReadINIStr $0 "$PLUGINSDIR\summary.ini" "Field 4" "Type"
${If} "$0" == "checkbox"
StrCpy $0 "5"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top "53"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "68"
${Else}
StrCpy $0 "4"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top "35"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "50"
${EndIf}
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "$0"

WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Type "label"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Text "$(SUMMARY_REBOOT_REQUIRED_INSTALL)"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Left "0"
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Right "-1"
${EndIf}

!insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Function .onInit

SetSilent silent

${Unless} ${AtLeastWin10}
${Unless} ${AtLeastWin95}
Abort
${EndUnless}
FunctionEnd
Expand Down
Loading

0 comments on commit f2cb153

Please sign in to comment.