browser/installer/windows/nsis/installer.nsi

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 # Required Plugins:
     6 # AppAssocReg    http://nsis.sourceforge.net/Application_Association_Registration_plug-in
     7 # ApplicationID  http://nsis.sourceforge.net/ApplicationID_plug-in
     8 # CityHash       http://mxr.mozilla.org/mozilla-central/source/other-licenses/nsis/Contrib/CityHash
     9 # ShellLink      http://nsis.sourceforge.net/ShellLink_plug-in
    10 # UAC            http://nsis.sourceforge.net/UAC_plug-in
    11 # ServicesHelper Mozilla specific plugin that is located in /other-licenses/nsis
    13 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
    14 !verbose 3
    16 ; 7-Zip provides better compression than the lzma from NSIS so we add the files
    17 ; uncompressed and use 7-Zip to create a SFX archive of it
    18 SetDatablockOptimize on
    19 SetCompress off
    20 CRCCheck on
    22 RequestExecutionLevel user
    24 ; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can
    25 ; be removed after we require NSIS 3.0a2 or greater.
    26 !ifdef NSIS_PACKEDVERSION
    27   Unicode true
    28   ManifestSupportedOS all
    29   ManifestDPIAware true
    30 !endif
    32 !addplugindir ./
    34 Var TmpVal
    35 Var InstallType
    36 Var AddStartMenuSC
    37 Var AddQuickLaunchSC
    38 Var AddDesktopSC
    39 Var InstallMaintenanceService
    40 Var PageName
    41 Var PreventRebootRequired
    43 ; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
    44 ; an application's Start Menu PROGRAMS directory and doesn't define the
    45 ; StartMenuDir variable can use the common InstallOnInitCommon macro.
    46 !define NO_STARTMENU_DIR
    48 ; On Vista and above attempt to elevate Standard Users in addition to users that
    49 ; are a member of the Administrators group.
    50 !define NONADMIN_ELEVATE
    52 !define AbortSurveyURL "http://www.kampyle.com/feedback_form/ff-feedback-form.php?site_code=8166124&form_id=12116&url="
    54 ; Other included files may depend upon these includes!
    55 ; The following includes are provided by NSIS.
    56 !include FileFunc.nsh
    57 !include LogicLib.nsh
    58 !include MUI.nsh
    59 !include WinMessages.nsh
    60 !include WinVer.nsh
    61 !include WordFunc.nsh
    63 !insertmacro GetOptions
    64 !insertmacro GetParameters
    65 !insertmacro GetSize
    66 !insertmacro StrFilter
    67 !insertmacro WordFind
    68 !insertmacro WordReplace
    70 ; The following includes are custom.
    71 !include branding.nsi
    72 !include defines.nsi
    73 !include common.nsh
    74 !include locales.nsi
    76 VIAddVersionKey "FileDescription" "${BrandShortName} Installer"
    77 VIAddVersionKey "OriginalFilename" "setup.exe"
    79 ; Must be inserted before other macros that use logging
    80 !insertmacro _LoggingCommon
    82 !insertmacro AddDisabledDDEHandlerValues
    83 !insertmacro ChangeMUIHeaderImage
    84 !insertmacro CheckForFilesInUse
    85 !insertmacro CleanUpdateDirectories
    86 !insertmacro CopyFilesFromDir
    87 !insertmacro CreateRegKey
    88 !insertmacro GetLongPath
    89 !insertmacro GetPathFromString
    90 !insertmacro GetParent
    91 !insertmacro InitHashAppModelId
    92 !insertmacro IsHandlerForInstallDir
    93 !insertmacro IsPinnedToTaskBar
    94 !insertmacro IsUserAdmin
    95 !insertmacro LogDesktopShortcut
    96 !insertmacro LogQuickLaunchShortcut
    97 !insertmacro LogStartMenuShortcut
    98 !insertmacro ManualCloseAppPrompt
    99 !insertmacro OnStubInstallUninstall
   100 !insertmacro PinnedToStartMenuLnkCount
   101 !insertmacro RegCleanAppHandler
   102 !insertmacro RegCleanMain
   103 !insertmacro RegCleanUninstall
   104 !ifdef MOZ_METRO
   105 !insertmacro RemoveDEHRegistrationIfMatching
   106 !endif
   107 !insertmacro SetAppLSPCategories
   108 !insertmacro SetBrandNameVars
   109 !insertmacro UpdateShortcutAppModelIDs
   110 !insertmacro UnloadUAC
   111 !insertmacro WriteRegStr2
   112 !insertmacro WriteRegDWORD2
   113 !insertmacro CheckIfRegistryKeyExists
   115 !include shared.nsh
   117 ; Helper macros for ui callbacks. Insert these after shared.nsh
   118 !insertmacro CheckCustomCommon
   119 !insertmacro InstallEndCleanupCommon
   120 !insertmacro InstallOnInitCommon
   121 !insertmacro InstallStartCleanupCommon
   122 !insertmacro LeaveDirectoryCommon
   123 !insertmacro LeaveOptionsCommon
   124 !insertmacro OnEndCommon
   125 !insertmacro PreDirectoryCommon
   127 Name "${BrandFullName}"
   128 OutFile "setup.exe"
   129 !ifdef HAVE_64BIT_OS
   130   InstallDir "$PROGRAMFILES64\${BrandFullName}\"
   131 !else
   132   InstallDir "$PROGRAMFILES32\${BrandFullName}\"
   133 !endif
   134 ShowInstDetails nevershow
   136 ################################################################################
   137 # Modern User Interface - MUI
   139 !define MOZ_MUI_CUSTOM_ABORT
   140 !define MUI_CUSTOMFUNCTION_ABORT "CustomAbort"
   141 !define MUI_ICON setup.ico
   142 !define MUI_UNICON setup.ico
   143 !define MUI_WELCOMEPAGE_TITLE_3LINES
   144 !define MUI_HEADERIMAGE
   145 !define MUI_HEADERIMAGE_RIGHT
   146 !define MUI_WELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
   148 ; Use a right to left header image when the language is right to left
   149 !ifdef ${AB_CD}_rtl
   150 !define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
   151 !else
   152 !define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
   153 !endif
   155 /**
   156  * Installation Pages
   157  */
   158 ; Welcome Page
   159 !define MUI_PAGE_CUSTOMFUNCTION_PRE preWelcome
   160 !insertmacro MUI_PAGE_WELCOME
   162 ; Custom Options Page
   163 Page custom preOptions leaveOptions
   165 ; Select Install Directory Page
   166 !define MUI_PAGE_CUSTOMFUNCTION_PRE preDirectory
   167 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDirectory
   168 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
   169 !insertmacro MUI_PAGE_DIRECTORY
   171 ; Custom Components Page
   172 !ifdef MOZ_MAINTENANCE_SERVICE
   173 Page custom preComponents leaveComponents
   174 !endif
   176 ; Custom Shortcuts Page
   177 Page custom preShortcuts leaveShortcuts
   179 ; Custom Summary Page
   180 Page custom preSummary leaveSummary
   182 ; Install Files Page
   183 !insertmacro MUI_PAGE_INSTFILES
   185 ; Finish Page
   186 !define MUI_FINISHPAGE_TITLE_3LINES
   187 !define MUI_FINISHPAGE_RUN
   188 !define MUI_FINISHPAGE_RUN_FUNCTION LaunchApp
   189 !define MUI_FINISHPAGE_RUN_TEXT $(LAUNCH_TEXT)
   190 !define MUI_PAGE_CUSTOMFUNCTION_PRE preFinish
   191 !insertmacro MUI_PAGE_FINISH
   193 ; Use the default dialog for IDD_VERIFY for a simple Banner
   194 ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
   196 ################################################################################
   197 # Install Sections
   199 ; Cleanup operations to perform at the start of the installation.
   200 Section "-InstallStartCleanup"
   201   SetDetailsPrint both
   202   DetailPrint $(STATUS_CLEANUP)
   203   SetDetailsPrint none
   205   SetOutPath "$INSTDIR"
   206   ${StartInstallLog} "${BrandFullName}" "${AB_CD}" "${AppVersion}" "${GREVersion}"
   208   StrCpy $PreventRebootRequired "false"
   209   ${GetParameters} $R8
   210   ${GetOptions} "$R8" "/INI=" $R7
   211   ${Unless} ${Errors}
   212     ; The configuration file must also exist
   213     ${If} ${FileExists} "$R7"
   214       ReadINIStr $R8 $R7 "Install" "PreventRebootRequired"
   215       ${If} $R8 == "true"
   216         StrCpy $PreventRebootRequired "true"
   217         StrCpy $R2 "false"
   218         StrCpy $R3 "false"
   219         ${OnStubInstallUninstall} "$R2" "$R3"
   220       ${EndIf}
   221     ${EndIf}
   222   ${EndUnless}
   224   ; Delete the app exe if present to prevent launching the app while we are
   225   ; installing.
   226   ClearErrors
   227   ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   228   ${If} ${Errors}
   229     ; If the user closed the application it can take several seconds for it to
   230     ; shut down completely. If the application is being used by another user we
   231     ; can rename the file and then delete is when the system is restarted.
   232     Sleep 5000
   233     ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   234     ClearErrors
   235   ${EndIf}
   237   ; setup the application model id registration value
   238   ${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
   240   ; Remove the updates directory for Vista and above
   241   ${CleanUpdateDirectories} "Mozilla\Firefox" "Mozilla\updates"
   243   ${RemoveDeprecatedFiles}
   245   ${InstallStartCleanupCommon}
   246 SectionEnd
   248 Section "-Application" APP_IDX
   249   ${StartUninstallLog}
   251   SetDetailsPrint both
   252   DetailPrint $(STATUS_INSTALL_APP)
   253   SetDetailsPrint none
   255   RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
   257   ${LogHeader} "Installing Main Files"
   258   ${CopyFilesFromDir} "$EXEDIR\core" "$INSTDIR" \
   259                       "$(ERROR_CREATE_DIRECTORY_PREFIX)" \
   260                       "$(ERROR_CREATE_DIRECTORY_SUFFIX)"
   262   ; Register DLLs
   263   ; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but
   264   ; is only registered for the last application installed. When the last
   265   ; application installed is uninstalled AccessibleMarshal.dll will no longer be
   266   ; registered. bug 338878
   267   ${LogHeader} "DLL Registration"
   268   ClearErrors
   269   ${RegisterDLL} "$INSTDIR\AccessibleMarshal.dll"
   270   ${If} ${Errors}
   271     ${LogMsg} "** ERROR Registering: $INSTDIR\AccessibleMarshal.dll **"
   272   ${Else}
   273     ${LogUninstall} "DLLReg: \AccessibleMarshal.dll"
   274     ${LogMsg} "Registered: $INSTDIR\AccessibleMarshal.dll"
   275   ${EndIf}
   277   ; Write extra files created by the application to the uninstall log so they
   278   ; will be removed when the application is uninstalled. To remove an empty
   279   ; directory write a bogus filename to the deepest directory and all empty
   280   ; parent directories will be removed.
   281   ${LogUninstall} "File: \components\compreg.dat"
   282   ${LogUninstall} "File: \components\xpti.dat"
   283   ${LogUninstall} "File: \active-update.xml"
   284   ${LogUninstall} "File: \install.log"
   285   ${LogUninstall} "File: \install_status.log"
   286   ${LogUninstall} "File: \install_wizard.log"
   287   ${LogUninstall} "File: \updates.xml"
   289   ClearErrors
   291   ; Default for creating Start Menu shortcut
   292   ; (1 = create, 0 = don't create)
   293   ${If} $AddStartMenuSC == ""
   294     StrCpy $AddStartMenuSC "1"
   295   ${EndIf}
   297   ; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)
   298   ${If} $AddQuickLaunchSC == ""
   299     ; Don't install the quick launch shortcut on Windows 7
   300     ${If} ${AtLeastWin7}
   301       StrCpy $AddQuickLaunchSC "0"
   302     ${Else}
   303       StrCpy $AddQuickLaunchSC "1"
   304     ${EndIf}
   305   ${EndIf}
   307   ; Default for creating Desktop shortcut (1 = create, 0 = don't create)
   308   ${If} $AddDesktopSC == ""
   309     StrCpy $AddDesktopSC "1"
   310   ${EndIf}
   312   ${LogHeader} "Adding Registry Entries"
   313   SetShellVarContext current  ; Set SHCTX to HKCU
   314   ${RegCleanMain} "Software\Mozilla"
   315   ${RegCleanUninstall}
   316 !ifdef MOZ_METRO
   317   ${ResetWin8PromptKeys} "HKCU" ""
   318 !endif
   319   ${UpdateProtocolHandlers}
   321   ClearErrors
   322   WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
   323   ${If} ${Errors}
   324     StrCpy $TmpVal "HKCU" ; used primarily for logging
   325   ${Else}
   326     SetShellVarContext all  ; Set SHCTX to HKLM
   327     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
   328     StrCpy $TmpVal "HKLM" ; used primarily for logging
   329     ${RegCleanMain} "Software\Mozilla"
   330     ${RegCleanUninstall}
   331     ${UpdateProtocolHandlers}
   333     ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
   334     ${If} "$0" != "${GREVersion}"
   335       WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
   336     ${EndIf}
   337   ${EndIf}
   339   ${RemoveDeprecatedKeys}
   341   ; The previous installer adds several regsitry values to both HKLM and HKCU.
   342   ; We now try to add to HKLM and if that fails to HKCU
   344   ; The order that reg keys and values are added is important if you use the
   345   ; uninstall log to remove them on uninstall. When using the uninstall log you
   346   ; MUST add children first so they will be removed first on uninstall so they
   347   ; will be empty when the key is deleted. This allows the uninstaller to
   348   ; specify that only empty keys will be deleted.
   349   ${SetAppKeys}
   351   ${FixClassKeys}
   353   ; Uninstall keys can only exist under HKLM on some versions of windows. Since
   354   ; it doesn't cause problems always add them.
   355   ${SetUninstallKeys}
   357   ; On install always add the FirefoxHTML and FirefoxURL keys.
   358   ; An empty string is used for the 5th param because FirefoxHTML is not a
   359   ; protocol handler.
   360   ${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
   361   StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
   363   ; In Win8, the delegate execute handler picks up the value in FirefoxURL and
   364   ; FirefoxHTML to launch the desktop browser when it needs to.
   365   ${AddDisabledDDEHandlerValues} "FirefoxHTML" "$2" "$8,1" \
   366                                  "${AppRegName} Document" ""
   367   ${AddDisabledDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" \
   368                                  "true"
   370   ; For pre win8, the following keys should only be set if we can write to HKLM.
   371   ; For post win8, the keys below get set in both HKLM and HKCU.
   372   ${If} $TmpVal == "HKLM"
   373     ; Set the Start Menu Internet and Vista Registered App HKLM registry keys.
   374     ${SetStartMenuInternet} "HKLM"
   375     ${FixShellIconHandler} "HKLM"
   377     ; If we are writing to HKLM and create either the desktop or start menu
   378     ; shortcuts set IconsVisible to 1 otherwise to 0.
   379     ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
   380     StrCpy $0 "Software\Clients\StartMenuInternet\$R9\InstallInfo"
   381     ${If} $AddDesktopSC == 1
   382     ${OrIf} $AddStartMenuSC == 1
   383       WriteRegDWORD HKLM "$0" "IconsVisible" 1
   384     ${Else}
   385       WriteRegDWORD HKLM "$0" "IconsVisible" 0
   386     ${EndIf}
   387   ${EndIf}
   389   ${If} ${AtLeastWin8}
   390     ; Set the Start Menu Internet and Vista Registered App HKCU registry keys.
   391     ${SetStartMenuInternet} "HKCU"
   392     ${FixShellIconHandler} "HKCU"
   394     ; If we create either the desktop or start menu shortcuts, then
   395     ; set IconsVisible to 1 otherwise to 0.
   396     ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
   397     StrCpy $0 "Software\Clients\StartMenuInternet\$R9\InstallInfo"
   398     ${If} $AddDesktopSC == 1
   399     ${OrIf} $AddStartMenuSC == 1
   400       WriteRegDWORD HKCU "$0" "IconsVisible" 1
   401     ${Else}
   402       WriteRegDWORD HKCU "$0" "IconsVisible" 0
   403     ${EndIf}
   404 !ifdef MOZ_METRO
   405     ${CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
   406                                         "FirefoxURL" \
   407                                         "FirefoxHTML"
   408     ${AddMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
   409                                     "$INSTDIR\CommandExecuteHandler.exe" \
   410                                     $AppUserModelID \
   411                                     "FirefoxURL" \
   412                                     "FirefoxHTML"
   413 !else
   414   ; The metro browser is not enabled by the mozconfig.
   415   ${If} ${AtLeastWin8}
   416     ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
   417                              $AppUserModelID \
   418                              "FirefoxURL" \
   419                              "FirefoxHTML"
   420   ${EndIf}
   421 !endif
   422   ${EndIf}
   424 !ifdef MOZ_MAINTENANCE_SERVICE
   425   ; If the maintenance service page was displayed then a value was already 
   426   ; explicitly selected for installing the maintenance service and 
   427   ; and so InstallMaintenanceService will already be 0 or 1.
   428   ; If the maintenance service page was not displayed then 
   429   ; InstallMaintenanceService will be equal to "".
   430   ${If} $InstallMaintenanceService == ""
   431     Call IsUserAdmin
   432     Pop $R0
   433     ${If} $R0 == "true"
   434     ; Only proceed if we have HKLM write access
   435     ${AndIf} $TmpVal == "HKLM"
   436     ; On Windows 2000 we do not install the maintenance service.
   437     ${AndIf} ${AtLeastWinXP}
   438       ; The user is an admin so we should default to install service yes
   439       StrCpy $InstallMaintenanceService "1"
   440     ${Else}
   441       ; The user is not admin so we should default to install service no
   442       StrCpy $InstallMaintenanceService "0"
   443     ${EndIf}
   444   ${EndIf}
   446   ${If} $InstallMaintenanceService == "1"
   447     ; The user wants to install the maintenance service, so execute
   448     ; the pre-packaged maintenance service installer. 
   449     ; This option can only be turned on if the user is an admin so there
   450     ; is no need to use ExecShell w/ verb runas to enforce elevated.
   451     nsExec::Exec "$\"$INSTDIR\maintenanceservice_installer.exe$\""
   452   ${EndIf}
   453 !endif
   455   ; These need special handling on uninstall since they may be overwritten by
   456   ; an install into a different location.
   457   StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
   458   ${WriteRegStr2} $TmpVal "$0" "" "$INSTDIR\${FileMainEXE}" 0
   459   ${WriteRegStr2} $TmpVal "$0" "Path" "$INSTDIR" 0
   461   StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\$R9"
   462   ${CreateRegKey} "$TmpVal" "$0" 0
   463   StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
   464   ${CreateRegKey} "$TmpVal" "$0" 0
   466   ${If} $TmpVal == "HKLM"
   467     ; Set the permitted LSP Categories for WinVista and above
   468     ${SetAppLSPCategories} ${LSP_CATEGORIES}
   469   ${EndIf}
   471   ; Create shortcuts
   472   ${LogHeader} "Adding Shortcuts"
   474   ; Remove the start menu shortcuts and directory if the SMPROGRAMS section
   475   ; exists in the shortcuts_log.ini and the SMPROGRAMS. The installer's shortcut
   476   ; creation code will create the shortcut in the root of the Start Menu
   477   ; Programs directory.
   478   ${RemoveStartMenuDir}
   480   ; Always add the application's shortcuts to the shortcuts log ini file. The
   481   ; DeleteShortcuts macro will do the right thing on uninstall if the
   482   ; shortcuts don't exist.
   483   ${LogStartMenuShortcut} "${BrandFullName}.lnk"
   484   ${LogQuickLaunchShortcut} "${BrandFullName}.lnk"
   485   ${LogDesktopShortcut} "${BrandFullName}.lnk"
   487   ; Best effort to update the Win7 taskbar and start menu shortcut app model
   488   ; id's. The possible contexts are current user / system and the user that
   489   ; elevated the installer.
   490   Call FixShortcutAppModelIDs
   491   ; If the current context is all also perform Win7 taskbar and start menu link
   492   ; maintenance for the current user context.
   493   ${If} $TmpVal == "HKLM"
   494     SetShellVarContext current  ; Set SHCTX to HKCU
   495     Call FixShortcutAppModelIDs
   496     SetShellVarContext all  ; Set SHCTX to HKLM
   497   ${EndIf}
   499   ; If running elevated also perform Win7 taskbar and start menu link
   500   ; maintenance for the unelevated user context in case that is different than
   501   ; the current user.
   502   ClearErrors
   503   ${GetParameters} $0
   504   ${GetOptions} "$0" "/UAC:" $0
   505   ${Unless} ${Errors}
   506     GetFunctionAddress $0 FixShortcutAppModelIDs
   507     UAC::ExecCodeSegment $0
   508   ${EndUnless}
   510   ; UAC only allows elevating to an Admin account so there is no need to add
   511   ; the Start Menu or Desktop shortcuts from the original unelevated process
   512   ; since this will either add it for the user if unelevated or All Users if
   513   ; elevated.
   514   ${If} $AddStartMenuSC == 1
   515     CreateShortCut "$SMPROGRAMS\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}"
   516     ${If} ${FileExists} "$SMPROGRAMS\${BrandFullName}.lnk"
   517       ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandFullName}.lnk" \
   518                                            "$INSTDIR"
   519       ${If} ${AtLeastWin7}
   520       ${AndIf} "$AppUserModelID" != ""
   521         ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID" "true"
   522       ${EndIf}
   523       ${LogMsg} "Added Shortcut: $SMPROGRAMS\${BrandFullName}.lnk"
   524     ${Else}
   525       ${LogMsg} "** ERROR Adding Shortcut: $SMPROGRAMS\${BrandFullName}.lnk"
   526     ${EndIf}
   527   ${EndIf}
   529   ${If} $AddDesktopSC == 1
   530     CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}"
   531     ${If} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
   532       ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandFullName}.lnk" \
   533                                              "$INSTDIR"
   534       ${If} ${AtLeastWin7}
   535       ${AndIf} "$AppUserModelID" != ""
   536         ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID"  "true"
   537       ${EndIf}
   538       ${LogMsg} "Added Shortcut: $DESKTOP\${BrandFullName}.lnk"
   539     ${Else}
   540       ${LogMsg} "** ERROR Adding Shortcut: $DESKTOP\${BrandFullName}.lnk"
   541     ${EndIf}
   542   ${EndIf}
   544   ; If elevated the Quick Launch shortcut must be added from the unelevated
   545   ; original process.
   546   ${If} $AddQuickLaunchSC == 1
   547     ${Unless} ${AtLeastWin7}
   548       ClearErrors
   549       ${GetParameters} $0
   550       ${GetOptions} "$0" "/UAC:" $0
   551       ${If} ${Errors}
   552         Call AddQuickLaunchShortcut
   553         ${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandFullName}.lnk"
   554       ${Else}
   555         ; It is not possible to add a log entry from the unelevated process so
   556         ; add the log entry without the path since there is no simple way to
   557         ; know the correct full path.
   558         ${LogMsg} "Added Quick Launch Shortcut: ${BrandFullName}.lnk"
   559         GetFunctionAddress $0 AddQuickLaunchShortcut
   560         UAC::ExecCodeSegment $0
   561       ${EndIf}
   562     ${EndUnless}
   563   ${EndIf}
   565 !ifdef MOZ_MAINTENANCE_SERVICE
   566   ${If} $TmpVal == "HKLM"
   567     ; Add the registry keys for allowed certificates.
   568     ${AddMaintCertKeys}
   569   ${EndIf}
   570 !endif
   571 SectionEnd
   573 ; Cleanup operations to perform at the end of the installation.
   574 Section "-InstallEndCleanup"
   575   SetDetailsPrint both
   576   DetailPrint "$(STATUS_CLEANUP)"
   577   SetDetailsPrint none
   579   ${Unless} ${Silent}
   580     ${MUI_INSTALLOPTIONS_READ} $0 "summary.ini" "Field 4" "State"
   581     ${If} "$0" == "1"
   582       ${LogHeader} "Setting as the default browser"
   583       ClearErrors
   584       ${GetParameters} $0
   585       ${GetOptions} "$0" "/UAC:" $0
   586       ${If} ${Errors}
   587         Call SetAsDefaultAppUserHKCU
   588       ${Else}
   589         GetFunctionAddress $0 SetAsDefaultAppUserHKCU
   590         UAC::ExecCodeSegment $0
   591       ${EndIf}
   592     ${EndIf}
   593     ; Adds a pinned Task Bar shortcut (see MigrateTaskBarShortcut for details).
   594     ${MigrateTaskBarShortcut}
   595   ${EndUnless}
   597   ${GetShortcutsLogPath} $0
   598   WriteIniStr "$0" "TASKBAR" "Migrated" "true"
   600   ; Refresh desktop icons
   601   System::Call "shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_DWORDFLUSH}, i 0, i 0)"
   603   ${InstallEndCleanupCommon}
   605   ${If} $PreventRebootRequired == "true"
   606     SetRebootFlag false
   607   ${EndIf}
   609   ${If} ${RebootFlag}
   610     ; When a reboot is required give SHChangeNotify time to finish the
   611     ; refreshing the icons so the OS doesn't display the icons from helper.exe
   612     Sleep 10000
   613     ${LogHeader} "Reboot Required To Finish Installation"
   614     ; ${FileMainEXE}.moz-upgrade should never exist but just in case...
   615     ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
   616       Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-upgrade"
   617     ${EndUnless}
   619     ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
   620       ClearErrors
   621       Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-delete"
   622       ${Unless} ${Errors}
   623         Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
   624       ${EndUnless}
   625     ${EndIf}
   627     ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
   628       CopyFiles /SILENT "$INSTDIR\uninstall\helper.exe" "$INSTDIR"
   629       FileOpen $0 "$INSTDIR\${FileMainEXE}" w
   630       FileWrite $0 "Will be deleted on restart"
   631       Rename /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}"
   632       FileClose $0
   633       Delete "$INSTDIR\${FileMainEXE}"
   634       Rename "$INSTDIR\helper.exe" "$INSTDIR\${FileMainEXE}"
   635     ${EndUnless}
   636   ${EndIf}
   637 SectionEnd
   639 ################################################################################
   640 # Install Abort Survey Functions
   642 Function CustomAbort
   643   ${If} "${AB_CD}" == "en-US"
   644   ${AndIf} "$PageName" != ""
   645   ${AndIf} ${FileExists} "$EXEDIR\core\distribution\distribution.ini"
   646     ReadINIStr $0 "$EXEDIR\core\distribution\distribution.ini" "Global" "about"
   647     ClearErrors
   648     ${WordFind} "$0" "Funnelcake" "E#" $1
   649     ${Unless} ${Errors}
   650       ; Yes = fill out the survey and exit, No = don't fill out survey and exit,
   651       ; Cancel = don't exit.
   652       MessageBox MB_YESNO|MB_ICONEXCLAMATION \
   653                  "Would you like to tell us why you are canceling this installation?" \
   654                  IDYes +1 IDNO CustomAbort_finish
   655       ${If} "$PageName" == "Welcome"
   656           GetFunctionAddress $0 AbortSurveyWelcome
   657       ${ElseIf} "$PageName" == "Options"
   658           GetFunctionAddress $0 AbortSurveyOptions
   659       ${ElseIf} "$PageName" == "Directory"
   660           GetFunctionAddress $0 AbortSurveyDirectory
   661       ${ElseIf} "$PageName" == "Shortcuts"
   662           GetFunctionAddress $0 AbortSurveyShortcuts
   663       ${ElseIf} "$PageName" == "Summary"
   664           GetFunctionAddress $0 AbortSurveySummary
   665       ${EndIf}
   666       ClearErrors
   667       ${GetParameters} $1
   668       ${GetOptions} "$1" "/UAC:" $2
   669       ${If} ${Errors}
   670         Call $0
   671       ${Else}
   672         UAC::ExecCodeSegment $0
   673       ${EndIf}
   675       CustomAbort_finish:
   676       Return
   677     ${EndUnless}
   678   ${EndIf}
   680   MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(MOZ_MUI_TEXT_ABORTWARNING)" \
   681              IDYES +1 IDNO +2
   682   Return
   683   Abort
   684 FunctionEnd
   686 Function AbortSurveyWelcome
   687   ExecShell "open" "${AbortSurveyURL}step1"
   688 FunctionEnd
   690 Function AbortSurveyOptions
   691   ExecShell "open" "${AbortSurveyURL}step2"
   692 FunctionEnd
   694 Function AbortSurveyDirectory
   695   ExecShell "open" "${AbortSurveyURL}step3"
   696 FunctionEnd
   698 Function AbortSurveyShortcuts
   699   ExecShell "open" "${AbortSurveyURL}step4"
   700 FunctionEnd
   702 Function AbortSurveySummary
   703   ExecShell "open" "${AbortSurveyURL}step5"
   704 FunctionEnd
   706 ################################################################################
   707 # Helper Functions
   709 Function AddQuickLaunchShortcut
   710   CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}"
   711   ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
   712     ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \
   713                                            "$INSTDIR"
   714   ${EndIf}
   715 FunctionEnd
   717 Function CheckExistingInstall
   718   ; If there is a pending file copy from a previous upgrade don't allow
   719   ; installing until after the system has rebooted.
   720   IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
   721   MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
   722   Reboot
   723   Quit
   725   ; If there is a pending file deletion from a previous uninstall don't allow
   726   ; installing until after the system has rebooted.
   727   IfFileExists "$INSTDIR\${FileMainEXE}.moz-delete" +1 +4
   728   MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UNINSTALL)" IDNO +2
   729   Reboot
   730   Quit
   732   ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
   733     ; Disable the next, cancel, and back buttons
   734     GetDlgItem $0 $HWNDPARENT 1 ; Next button
   735     EnableWindow $0 0
   736     GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
   737     EnableWindow $0 0
   738     GetDlgItem $0 $HWNDPARENT 3 ; Back button
   739     EnableWindow $0 0
   741     Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
   743     ${If} "$TmpVal" == "FoundMessageWindow"
   744       Sleep 5000
   745     ${EndIf}
   747     ${PushFilesToCheck}
   749     ; Store the return value in $TmpVal so it is less likely to be accidentally
   750     ; overwritten elsewhere.
   751     ${CheckForFilesInUse} $TmpVal
   753     Banner::destroy
   755     ; Enable the next, cancel, and back buttons
   756     GetDlgItem $0 $HWNDPARENT 1 ; Next button
   757     EnableWindow $0 1
   758     GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
   759     EnableWindow $0 1
   760     GetDlgItem $0 $HWNDPARENT 3 ; Back button
   761     EnableWindow $0 1
   763     ${If} "$TmpVal" == "true"
   764       StrCpy $TmpVal "FoundMessageWindow"
   765       ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
   766       StrCpy $TmpVal "true"
   767     ${EndIf}
   768   ${EndIf}
   769 FunctionEnd
   771 Function LaunchApp
   772   ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_LAUNCH)"
   774   ClearErrors
   775   ${GetParameters} $0
   776   ${GetOptions} "$0" "/UAC:" $1
   777   ${If} ${Errors}
   778     StrCpy $1 "0"
   779     StrCpy $2 "0"
   780 !ifdef MOZ_METRO
   781     ; Check to see if this install location is currently set as the
   782     ; default browser.
   783     AppAssocReg::QueryAppIsDefaultAll "${AppRegName}" "effective"
   784     Pop $1
   785     ; Check for a last run type to see if metro was the last browser
   786     ; front end in use.
   787     ReadRegDWORD $2 HKCU "Software\Mozilla\Firefox" "MetroLastAHE"
   788 !endif
   789     ${If} $1 == "1"
   790     ${AndIf} $2 == "1" ; 1 equals AHE_IMMERSIVE
   791       ; Launch into metro
   792       Exec "$\"$INSTDIR\CommandExecuteHandler.exe$\" --launchmetro"
   793     ${Else}
   794       ; Launch into desktop
   795       Exec "$\"$INSTDIR\${FileMainEXE}$\""
   796     ${EndIf}
   797   ${Else}
   798     GetFunctionAddress $0 LaunchAppFromElevatedProcess
   799     UAC::ExecCodeSegment $0
   800   ${EndIf}
   801 FunctionEnd
   803 Function LaunchAppFromElevatedProcess
   804   ; Find the installation directory when launching using GetFunctionAddress
   805   ; from an elevated installer since $INSTDIR will not be set in this installer
   806   ${StrFilter} "${FileMainEXE}" "+" "" "" $R9
   807   ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
   808   ${GetPathFromString} "$0" $0
   809   ${GetParent} "$0" $1
   810   ; Set our current working directory to the application's install directory
   811   ; otherwise the 7-Zip temp directory will be in use and won't be deleted.
   812   SetOutPath "$1"
   813   StrCpy $2 "0"
   814   StrCpy $3 "0"
   815 !ifdef MOZ_METRO
   816   ; Check to see if this install location is currently set as the
   817   ; default browser.
   818   AppAssocReg::QueryAppIsDefaultAll "${AppRegName}" "effective"
   819   Pop $2
   820   ; Check for a last run type to see if metro was the last browser
   821   ; front end in use.
   822   ReadRegDWORD $3 HKCU "Software\Mozilla\Firefox" "MetroLastAHE"
   823 !endif
   824   ${If} $2 == "1"
   825   ${AndIf} $3 == "1" ; 1 equals AHE_IMMERSIVE
   826     ; Launch into metro
   827     Exec "$\"$1\CommandExecuteHandler.exe$\" --launchmetro"
   828   ${Else}
   829     ; Launch into desktop
   830     Exec "$\"$0$\""
   831   ${EndIf}
   832 FunctionEnd
   834 ################################################################################
   835 # Language
   837 !insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
   838 !verbose push
   839 !verbose 3
   840 !include "overrideLocale.nsh"
   841 !include "customLocale.nsh"
   842 !verbose pop
   844 ; Set this after the locale files to override it if it is in the locale
   845 ; using " " for BrandingText will hide the "Nullsoft Install System..." branding
   846 BrandingText " "
   848 ################################################################################
   849 # Page pre, show, and leave functions
   851 Function preWelcome
   852   StrCpy $PageName "Welcome"
   853   ${If} ${FileExists} "$EXEDIR\core\distribution\modern-wizard.bmp"
   854     Delete "$PLUGINSDIR\modern-wizard.bmp"
   855     CopyFiles /SILENT "$EXEDIR\core\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
   856   ${EndIf}
   857 FunctionEnd
   859 Function preOptions
   860   StrCpy $PageName "Options"
   861   ${If} ${FileExists} "$EXEDIR\core\distribution\modern-header.bmp"
   862   ${AndIf} $hHeaderBitmap == ""
   863     Delete "$PLUGINSDIR\modern-header.bmp"
   864     CopyFiles /SILENT "$EXEDIR\core\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
   865     ${ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
   866   ${EndIf}
   867   !insertmacro MUI_HEADER_TEXT "$(OPTIONS_PAGE_TITLE)" "$(OPTIONS_PAGE_SUBTITLE)"
   868   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "options.ini"
   869 FunctionEnd
   871 Function leaveOptions
   872   ${MUI_INSTALLOPTIONS_READ} $0 "options.ini" "Settings" "State"
   873   ${If} $0 != 0
   874     Abort
   875   ${EndIf}
   876   ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 2" "State"
   877   StrCmp $R0 "1" +1 +2
   878   StrCpy $InstallType ${INSTALLTYPE_BASIC}
   879   ${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"
   880   StrCmp $R0 "1" +1 +2
   881   StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
   883   ${LeaveOptionsCommon}
   885   ${If} $InstallType == ${INSTALLTYPE_BASIC}
   886     Call CheckExistingInstall
   887   ${EndIf}
   888 FunctionEnd
   890 Function preDirectory
   891   StrCpy $PageName "Directory"
   892   ${PreDirectoryCommon}
   893 FunctionEnd
   895 Function leaveDirectory
   896   ${If} $InstallType == ${INSTALLTYPE_BASIC}
   897     Call CheckExistingInstall
   898   ${EndIf}
   899   ${LeaveDirectoryCommon} "$(WARN_DISK_SPACE)" "$(WARN_WRITE_ACCESS)"
   900 FunctionEnd
   902 Function preShortcuts
   903   StrCpy $PageName "Shortcuts"
   904   ${CheckCustomCommon}
   905   !insertmacro MUI_HEADER_TEXT "$(SHORTCUTS_PAGE_TITLE)" "$(SHORTCUTS_PAGE_SUBTITLE)"
   906   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "shortcuts.ini"
   907 FunctionEnd
   909 Function leaveShortcuts
   910   ${MUI_INSTALLOPTIONS_READ} $0 "shortcuts.ini" "Settings" "State"
   911   ${If} $0 != 0
   912     Abort
   913   ${EndIf}
   914   ${MUI_INSTALLOPTIONS_READ} $AddDesktopSC "shortcuts.ini" "Field 2" "State"
   916   ; If we have a Metro browser and are Win8, then we don't have a Field 3
   917 !ifdef MOZ_METRO
   918   ${Unless} ${AtLeastWin8}
   919 !endif
   920     ${MUI_INSTALLOPTIONS_READ} $AddStartMenuSC "shortcuts.ini" "Field 3" "State"
   921 !ifdef MOZ_METRO
   922   ${EndIf}
   923 !endif
   925   ; Don't install the quick launch shortcut on Windows 7
   926   ${Unless} ${AtLeastWin7}
   927     ${MUI_INSTALLOPTIONS_READ} $AddQuickLaunchSC "shortcuts.ini" "Field 4" "State"
   928   ${EndUnless}
   930   ${If} $InstallType == ${INSTALLTYPE_CUSTOM}
   931     Call CheckExistingInstall
   932   ${EndIf}
   933 FunctionEnd
   935 !ifdef MOZ_MAINTENANCE_SERVICE
   936 Function preComponents
   937   ; If the service already exists, don't show this page
   938   ServicesHelper::IsInstalled "MozillaMaintenance"
   939   Pop $R9
   940   ${If} $R9 == 1
   941     ; The service already exists so don't show this page.
   942     Abort
   943   ${EndIf}
   945   ; On Windows 2000 we do not install the maintenance service.
   946   ${Unless} ${AtLeastWinXP}
   947     Abort
   948   ${EndUnless}
   950   ; Don't show the custom components page if the
   951   ; user is not an admin
   952   Call IsUserAdmin
   953   Pop $R9
   954   ${If} $R9 != "true"
   955     Abort
   956   ${EndIf}
   958   ; Only show the maintenance service page if we have write access to HKLM
   959   ClearErrors
   960   WriteRegStr HKLM "Software\Mozilla" \
   961               "${BrandShortName}InstallerTest" "Write Test"
   962   ${If} ${Errors}
   963     ClearErrors
   964     Abort
   965   ${Else}
   966     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
   967   ${EndIf}
   969   StrCpy $PageName "Components"
   970   ${CheckCustomCommon}
   971   !insertmacro MUI_HEADER_TEXT "$(COMPONENTS_PAGE_TITLE)" "$(COMPONENTS_PAGE_SUBTITLE)"
   972   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "components.ini"
   973 FunctionEnd
   975 Function leaveComponents
   976   ${MUI_INSTALLOPTIONS_READ} $0 "components.ini" "Settings" "State"
   977   ${If} $0 != 0
   978     Abort
   979   ${EndIf}
   980   ${MUI_INSTALLOPTIONS_READ} $InstallMaintenanceService "components.ini" "Field 2" "State"
   981   ${If} $InstallType == ${INSTALLTYPE_CUSTOM}
   982     Call CheckExistingInstall
   983   ${EndIf}
   984 FunctionEnd
   985 !endif
   987 Function preSummary
   988   StrCpy $PageName "Summary"
   989   ; Setup the summary.ini file for the Custom Summary Page
   990   WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "3"
   992   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Type   "label"
   993   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Text   "$(SUMMARY_INSTALLED_TO)"
   994   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Left   "0"
   995   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Right  "-1"
   996   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Top    "5"
   997   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Bottom "15"
   999   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Type   "text"
  1000   ; The contents of this control must be set as follows in the pre function
  1001   ; ${MUI_INSTALLOPTIONS_READ} $1 "summary.ini" "Field 2" "HWND"
  1002   ; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
  1003   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" state  ""
  1004   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Left   "0"
  1005   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Right  "-1"
  1006   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Top    "17"
  1007   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Bottom "30"
  1008   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" flags  "READONLY"
  1010   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Type   "label"
  1011   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Left   "0"
  1012   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Right  "-1"
  1013   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Top    "130"
  1014   WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Bottom "150"
  1016   ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
  1017     WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Text "$(SUMMARY_UPGRADE_CLICK)"
  1018     WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NextButtonText "$(UPGRADE_BUTTON)"
  1019   ${Else}
  1020     WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Text "$(SUMMARY_INSTALL_CLICK)"
  1021     DeleteINIStr "$PLUGINSDIR\summary.ini" "Settings" NextButtonText
  1022   ${EndIf}
  1025   ; Remove the "Field 4" ini section in case the user hits back and changes the
  1026   ; installation directory which could change whether the make default checkbox
  1027   ; should be displayed.
  1028   DeleteINISec "$PLUGINSDIR\summary.ini" "Field 4"
  1030   ; Check if it is possible to write to HKLM
  1031   ClearErrors
  1032   WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
  1033   ${Unless} ${Errors}
  1034     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
  1035     ; Check if Firefox is the http handler for this user.
  1036     SetShellVarContext current ; Set SHCTX to the current user
  1037     ${IsHandlerForInstallDir} "http" $R9
  1038     ${If} $TmpVal == "HKLM"
  1039       SetShellVarContext all ; Set SHCTX to all users
  1040     ${EndIf}
  1041     ; If Firefox isn't the http handler for this user show the option to set
  1042     ; Firefox as the default browser.
  1043     ${If} "$R9" != "true"
  1044     ${AndIf} ${AtMostWin2008R2}
  1045       WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "4"
  1046       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Type   "checkbox"
  1047       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Text   "$(SUMMARY_TAKE_DEFAULTS)"
  1048       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Left   "0"
  1049       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Right  "-1"
  1050       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" State  "1"
  1051       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Top    "32"
  1052       WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Bottom "53"
  1053     ${EndIf}
  1054   ${EndUnless}
  1056   ${If} "$TmpVal" == "true"
  1057     ; If there is already a Type entry in the "Field 4" section with a value of
  1058     ; checkbox then the set as the default browser checkbox is displayed and
  1059     ; this text must be moved below it.
  1060     ReadINIStr $0 "$PLUGINSDIR\summary.ini" "Field 4" "Type"
  1061     ${If} "$0" == "checkbox"
  1062       StrCpy $0 "5"
  1063       WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top    "53"
  1064       WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "68"
  1065     ${Else}
  1066       StrCpy $0 "4"
  1067       WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top    "35"
  1068       WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "50"
  1069     ${EndIf}
  1070     WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "$0"
  1072     WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Type   "label"
  1073     WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Text   "$(SUMMARY_REBOOT_REQUIRED_INSTALL)"
  1074     WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Left   "0"
  1075     WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Right  "-1"
  1076   ${EndIf}
  1078   !insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
  1080   ; The Summary custom page has a textbox that will automatically receive
  1081   ; focus. This sets the focus to the Install button instead.
  1082   !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "summary.ini"
  1083   GetDlgItem $0 $HWNDPARENT 1
  1084   System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
  1085   ${MUI_INSTALLOPTIONS_READ} $1 "summary.ini" "Field 2" "HWND"
  1086   SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
  1087   !insertmacro MUI_INSTALLOPTIONS_SHOW
  1088 FunctionEnd
  1090 Function leaveSummary
  1091   ; Try to delete the app executable and if we can't delete it try to find the
  1092   ; app's message window and prompt the user to close the app. This allows
  1093   ; running an instance that is located in another directory. If for whatever
  1094   ; reason there is no message window we will just rename the app's files and
  1095   ; then remove them on restart.
  1096   ClearErrors
  1097   ${DeleteFile} "$INSTDIR\${FileMainEXE}"
  1098   ${If} ${Errors}
  1099     ${ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
  1100   ${EndIf}
  1101 FunctionEnd
  1103 ; When we add an optional action to the finish page the cancel button is
  1104 ; enabled. This disables it and leaves the finish button as the only choice.
  1105 Function preFinish
  1106   StrCpy $PageName ""
  1107   ${EndInstallLog} "${BrandFullName}"
  1108   !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
  1109 FunctionEnd
  1111 ################################################################################
  1112 # Initialization Functions
  1114 Function .onInit
  1115   ; Remove the current exe directory from the search order.
  1116   ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
  1117   System::Call 'kernel32::SetDllDirectoryW(w "")'
  1119   StrCpy $PageName ""
  1120   StrCpy $LANGUAGE 0
  1121   ${SetBrandNameVars} "$EXEDIR\core\distribution\setup.ini"
  1123   ${InstallOnInitCommon} "$(WARN_MIN_SUPPORTED_OS_MSG)"
  1125 ; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be
  1126 ; removed after we require NSIS 3.0a2 or greater.
  1127 !ifndef NSIS_PACKEDVERSION
  1128   ${If} ${AtLeastWinVista}
  1129     System::Call 'user32::SetProcessDPIAware()'
  1130   ${EndIf}
  1131 !endif
  1133   !insertmacro InitInstallOptionsFile "options.ini"
  1134   !insertmacro InitInstallOptionsFile "shortcuts.ini"
  1135   !insertmacro InitInstallOptionsFile "components.ini"
  1136   !insertmacro InitInstallOptionsFile "summary.ini"
  1138   WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
  1140   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type   "label"
  1141   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text   "$(OPTIONS_SUMMARY)"
  1142   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Left   "0"
  1143   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Right  "-1"
  1144   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Top    "0"
  1145   WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Bottom "10"
  1147   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Type   "RadioButton"
  1148   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Text   "$(OPTION_STANDARD_RADIO)"
  1149   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Left   "0"
  1150   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Right  "-1"
  1151   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Top    "25"
  1152   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Bottom "35"
  1153   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" State  "1"
  1154   WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Flags  "GROUP"
  1156   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Type   "RadioButton"
  1157   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Text   "$(OPTION_CUSTOM_RADIO)"
  1158   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Left   "0"
  1159   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Right  "-1"
  1160   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Top    "55"
  1161   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
  1162   WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" State  "0"
  1164   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type   "label"
  1165   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text   "$(OPTION_STANDARD_DESC)"
  1166   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left   "15"
  1167   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Right  "-1"
  1168   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Top    "37"
  1169   WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Bottom "57"
  1171   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Type   "label"
  1172   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Text   "$(OPTION_CUSTOM_DESC)"
  1173   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Left   "15"
  1174   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Right  "-1"
  1175   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top    "67"
  1176   WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
  1178   ; Setup the shortcuts.ini file for the Custom Shortcuts Page
  1179   ; Don't offer to install the quick launch shortcut on Windows 7
  1180   ${If} ${AtLeastWin7}
  1181     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "3"
  1182   ${Else}
  1183     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "4"
  1184   ${EndIf}
  1186   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Type   "label"
  1187   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Text   "$(CREATE_ICONS_DESC)"
  1188   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Left   "0"
  1189   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Right  "-1"
  1190   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Top    "5"
  1191   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Bottom "15"
  1193   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Type   "checkbox"
  1194   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Text   "$(ICONS_DESKTOP)"
  1195   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Left   "0"
  1196   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Right  "-1"
  1197   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Top    "20"
  1198   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Bottom "30"
  1199   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" State  "1"
  1200   WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Flags  "GROUP"
  1202   ; Don't offer to install the start menu shortcut on Windows 8
  1203   ; for Metro builds.
  1204 !ifdef MOZ_METRO
  1205   ${Unless} ${AtLeastWin8}
  1206 !endif
  1207     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Type   "checkbox"
  1208     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Text   "$(ICONS_STARTMENU)"
  1209     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Left   "0"
  1210     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Right  "-1"
  1211     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Top    "40"
  1212     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Bottom "50"
  1213     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" State  "1"
  1214 !ifdef MOZ_METRO
  1215   ${EndIf}
  1216 !endif
  1218   ; Don't offer to install the quick launch shortcut on Windows 7
  1219   ${Unless} ${AtLeastWin7}
  1220     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Type   "checkbox"
  1221     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Text   "$(ICONS_QUICKLAUNCH)"
  1222     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Left   "0"
  1223     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Right  "-1"
  1224     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Top    "60"
  1225     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Bottom "70"
  1226     WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" State  "1"
  1227   ${EndUnless}
  1229   ; Setup the components.ini file for the Components Page
  1230   WriteINIStr "$PLUGINSDIR\components.ini" "Settings" NumFields "2"
  1232   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Type   "label"
  1233   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Text   "$(OPTIONAL_COMPONENTS_DESC)"
  1234   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Left   "0"
  1235   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Right  "-1"
  1236   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Top    "5"
  1237   WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Bottom "25"
  1239   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Type   "checkbox"
  1240   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Text   "$(MAINTENANCE_SERVICE_CHECKBOX_DESC)"
  1241   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Left   "0"
  1242   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Right  "-1"
  1243   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Top    "27"
  1244   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Bottom "37"
  1245   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" State  "1"
  1246   WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Flags  "GROUP"
  1248   ; There must always be a core directory.
  1249   ${GetSize} "$EXEDIR\core\" "/S=0K" $R5 $R7 $R8
  1250   SectionSetSize ${APP_IDX} $R5
  1252   ; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
  1253   ; the user clicks the back button
  1254   StrCpy $hHeaderBitmap ""
  1255 FunctionEnd
  1257 Function .onGUIEnd
  1258   ${OnEndCommon}
  1259 FunctionEnd

mercurial