Source code

Revision control

Other Tools

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/.
4
5
# Required Plugins:
12
# ServicesHelper Mozilla specific plugin that is located in /other-licenses/nsis
13
14
; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
15
!verbose 3
16
17
; 7-Zip provides better compression than the lzma from NSIS so we add the files
18
; uncompressed and use 7-Zip to create a SFX archive of it
19
SetDatablockOptimize on
20
SetCompress off
21
CRCCheck on
22
23
RequestExecutionLevel user
24
25
Unicode true
26
ManifestSupportedOS all
27
ManifestDPIAware true
28
29
!addplugindir ./
30
31
Var TmpVal
32
Var InstallType
33
Var AddStartMenuSC
34
Var AddTaskbarSC
35
Var AddQuickLaunchSC
36
Var AddDesktopSC
37
Var InstallMaintenanceService
38
Var InstallOptionalExtensions
39
Var ExtensionRecommender
40
Var PageName
41
Var PreventRebootRequired
42
Var RegisterDefaultAgent
43
44
; Telemetry ping fields
45
Var SetAsDefault
46
Var HadOldInstall
47
Var DefaultInstDir
48
Var IntroPhaseStart
49
Var OptionsPhaseStart
50
Var InstallPhaseStart
51
Var FinishPhaseStart
52
Var FinishPhaseEnd
53
Var InstallResult
54
Var LaunchedNewApp
55
56
; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
57
; an application's Start Menu PROGRAMS directory and doesn't define the
58
; StartMenuDir variable can use the common InstallOnInitCommon macro.
59
!define NO_STARTMENU_DIR
60
61
; Attempt to elevate Standard Users in addition to users that
62
; are a member of the Administrators group.
63
!define NONADMIN_ELEVATE
64
66
67
; Other included files may depend upon these includes!
68
; The following includes are provided by NSIS.
69
!include FileFunc.nsh
70
!include LogicLib.nsh
71
!include MUI.nsh
72
!include WinMessages.nsh
73
!include WinVer.nsh
74
!include WordFunc.nsh
75
76
!insertmacro GetOptions
77
!insertmacro GetParameters
78
!insertmacro GetSize
79
!insertmacro StrFilter
80
!insertmacro WordFind
81
!insertmacro WordReplace
82
83
; The following includes are custom.
84
!include branding.nsi
85
!include defines.nsi
86
!include common.nsh
87
!include locales.nsi
88
89
VIAddVersionKey "FileDescription" "${BrandShortName} Installer"
90
VIAddVersionKey "OriginalFilename" "setup.exe"
91
92
; Must be inserted before other macros that use logging
93
!insertmacro _LoggingCommon
94
95
!insertmacro AddDisabledDDEHandlerValues
96
!insertmacro ChangeMUIHeaderImage
97
!insertmacro ChangeMUISidebarImage
98
!insertmacro CheckForFilesInUse
99
!insertmacro CleanUpdateDirectories
100
!insertmacro CopyFilesFromDir
101
!insertmacro CreateRegKey
102
!insertmacro GetFirstInstallPath
103
!insertmacro GetLongPath
104
!insertmacro GetPathFromString
105
!insertmacro GetParent
106
!insertmacro InitHashAppModelId
107
!insertmacro IsHandlerForInstallDir
108
!insertmacro IsPinnedToTaskBar
109
!insertmacro IsUserAdmin
110
!insertmacro LogDesktopShortcut
111
!insertmacro LogQuickLaunchShortcut
112
!insertmacro LogStartMenuShortcut
113
!insertmacro ManualCloseAppPrompt
114
!insertmacro PinnedToStartMenuLnkCount
115
!insertmacro RegCleanAppHandler
116
!insertmacro RegCleanMain
117
!insertmacro RegCleanUninstall
118
!insertmacro RemovePrecompleteEntries
119
!insertmacro SetAppLSPCategories
120
!insertmacro SetBrandNameVars
121
!insertmacro UpdateShortcutAppModelIDs
122
!insertmacro UnloadUAC
123
!insertmacro WriteRegStr2
124
!insertmacro WriteRegDWORD2
125
126
; This needs to be inserted after InitHashAppModelId because it uses
127
; $AppUserModelID and the compiler can't handle using variables lexically before
128
; they've been declared.
129
!insertmacro GetInstallerRegistryPref
130
131
!include shared.nsh
132
133
; Helper macros for ui callbacks. Insert these after shared.nsh
134
!insertmacro CheckCustomCommon
135
!insertmacro InstallEndCleanupCommon
136
!insertmacro InstallOnInitCommon
137
!insertmacro InstallStartCleanupCommon
138
!insertmacro LeaveDirectoryCommon
139
!insertmacro LeaveOptionsCommon
140
!insertmacro OnEndCommon
141
!insertmacro PreDirectoryCommon
142
143
Name "${BrandFullName}"
144
OutFile "setup.exe"
145
!ifdef HAVE_64BIT_BUILD
146
InstallDir "$PROGRAMFILES64\${BrandFullName}\"
147
!else
148
InstallDir "$PROGRAMFILES32\${BrandFullName}\"
149
!endif
150
ShowInstDetails nevershow
151
152
################################################################################
153
# Modern User Interface - MUI
154
155
!define MOZ_MUI_CUSTOM_ABORT
156
!define MUI_CUSTOMFUNCTION_ABORT "CustomAbort"
157
!define MUI_ICON setup.ico
158
!define MUI_UNICON setup.ico
159
!define MUI_WELCOMEPAGE_TITLE_3LINES
160
!define MUI_HEADERIMAGE
161
!define MUI_HEADERIMAGE_RIGHT
162
!define MUI_WELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
163
; By default MUI_BGCOLOR is hardcoded to FFFFFF, which is only correct if the
164
; Windows theme or high-contrast mode hasn't changed it, so we need to
165
; override that with GetSysColor(COLOR_WINDOW) (this string ends up getting
166
; passed to SetCtlColors, which uses this custom syntax to mean that).
167
!define MUI_BGCOLOR SYSCLR:WINDOW
168
169
; Use a right to left header image when the language is right to left
170
!ifdef ${AB_CD}_rtl
171
!define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
172
!else
173
!define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
174
!endif
175
176
/**
177
* Installation Pages
178
*/
179
; Welcome Page
180
!define MUI_PAGE_CUSTOMFUNCTION_PRE preWelcome
181
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showWelcome
182
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveWelcome
183
!insertmacro MUI_PAGE_WELCOME
184
185
; Custom Options Page
186
Page custom preOptions leaveOptions
187
188
; Select Install Directory Page
189
!define MUI_PAGE_CUSTOMFUNCTION_PRE preDirectory
190
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDirectory
191
!define MUI_DIRECTORYPAGE_VERIFYONLEAVE
192
!insertmacro MUI_PAGE_DIRECTORY
193
194
; Custom Components Page
195
!ifdef MOZ_MAINTENANCE_SERVICE
196
Page custom preComponents leaveComponents
197
!endif
198
199
; Custom Shortcuts Page
200
Page custom preShortcuts leaveShortcuts
201
202
; Custom Extensions Page
203
!ifdef MOZ_OPTIONAL_EXTENSIONS
204
Page custom preExtensions leaveExtensions
205
!endif
206
207
; Custom Summary Page
208
Page custom preSummary leaveSummary
209
210
; Install Files Page
211
!insertmacro MUI_PAGE_INSTFILES
212
213
; Finish Page
214
!define MUI_FINISHPAGE_TITLE_3LINES
215
!define MUI_FINISHPAGE_RUN
216
!define MUI_FINISHPAGE_RUN_FUNCTION LaunchApp
217
!define MUI_FINISHPAGE_RUN_TEXT $(LAUNCH_TEXT)
218
!define MUI_PAGE_CUSTOMFUNCTION_PRE preFinish
219
!define MUI_PAGE_CUSTOMFUNCTION_SHOW showFinish
220
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE postFinish
221
!insertmacro MUI_PAGE_FINISH
222
223
; Use the default dialog for IDD_VERIFY for a simple Banner
224
ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
225
226
################################################################################
227
# Install Sections
228
229
; Cleanup operations to perform at the start of the installation.
230
Section "-InstallStartCleanup"
231
System::Call "kernel32::GetTickCount()l .s"
232
Pop $InstallPhaseStart
233
234
SetDetailsPrint both
235
DetailPrint $(STATUS_CLEANUP)
236
SetDetailsPrint none
237
238
SetOutPath "$INSTDIR"
239
${StartInstallLog} "${BrandFullName}" "${AB_CD}" "${AppVersion}" "${GREVersion}"
240
241
StrCpy $R9 "true"
242
StrCpy $PreventRebootRequired "false"
243
${GetParameters} $R8
244
${GetOptions} "$R8" "/INI=" $R7
245
${Unless} ${Errors}
246
; The configuration file must also exist
247
${If} ${FileExists} "$R7"
248
ReadINIStr $R9 $R7 "Install" "RemoveDistributionDir"
249
ReadINIStr $R8 $R7 "Install" "PreventRebootRequired"
250
${If} $R8 == "true"
251
StrCpy $PreventRebootRequired "true"
252
${EndIf}
253
${EndIf}
254
${EndUnless}
255
256
${GetParameters} $R8
257
${InstallGetOption} $R8 "RemoveDistributionDir" $R9
258
${If} $R9 == "0"
259
StrCpy $R9 "false"
260
${EndIf}
261
${InstallGetOption} $R8 "PreventRebootRequired" $PreventRebootRequired
262
${If} $PreventRebootRequired == "1"
263
StrCpy $PreventRebootRequired "true"
264
${EndIf}
265
266
; Remove directories and files we always control before parsing the uninstall
267
; log so empty directories can be removed.
268
${If} ${FileExists} "$INSTDIR\updates"
269
RmDir /r "$INSTDIR\updates"
270
${EndIf}
271
${If} ${FileExists} "$INSTDIR\updated"
272
RmDir /r "$INSTDIR\updated"
273
${EndIf}
274
${If} ${FileExists} "$INSTDIR\defaults\shortcuts"
275
RmDir /r "$INSTDIR\defaults\shortcuts"
276
${EndIf}
277
${If} ${FileExists} "$INSTDIR\distribution"
278
${AndIf} $R9 != "false"
279
RmDir /r "$INSTDIR\distribution"
280
${EndIf}
281
282
; Delete the app exe if present to prevent launching the app while we are
283
; installing.
284
ClearErrors
285
${DeleteFile} "$INSTDIR\${FileMainEXE}"
286
${If} ${Errors}
287
; If the user closed the application it can take several seconds for it to
288
; shut down completely. If the application is being used by another user we
289
; can rename the file and then delete is when the system is restarted.
290
Sleep 5000
291
${DeleteFile} "$INSTDIR\${FileMainEXE}"
292
ClearErrors
293
${EndIf}
294
295
; setup the application model id registration value
296
${InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
297
298
; Remove the updates directory
299
${CleanUpdateDirectories} "Mozilla\Firefox" "Mozilla\updates"
300
301
${RemoveDeprecatedFiles}
302
${RemovePrecompleteEntries} "false"
303
304
${If} ${FileExists} "$INSTDIR\defaults\pref\channel-prefs.js"
305
Delete "$INSTDIR\defaults\pref\channel-prefs.js"
306
${EndIf}
307
${If} ${FileExists} "$INSTDIR\defaults\pref"
308
RmDir "$INSTDIR\defaults\pref"
309
${EndIf}
310
${If} ${FileExists} "$INSTDIR\defaults"
311
RmDir "$INSTDIR\defaults"
312
${EndIf}
313
${If} ${FileExists} "$INSTDIR\uninstall"
314
; Remove the uninstall directory that we control
315
RmDir /r "$INSTDIR\uninstall"
316
${EndIf}
317
${If} ${FileExists} "$INSTDIR\update-settings.ini"
318
Delete "$INSTDIR\update-settings.ini"
319
${EndIf}
320
321
; Explictly remove empty webapprt dir in case it exists (bug 757978).
322
RmDir "$INSTDIR\webapprt\components"
323
RmDir "$INSTDIR\webapprt"
324
325
${InstallStartCleanupCommon}
326
SectionEnd
327
328
Section "-Application" APP_IDX
329
${StartUninstallLog}
330
331
SetDetailsPrint both
332
DetailPrint $(STATUS_INSTALL_APP)
333
SetDetailsPrint none
334
335
${LogHeader} "Installing Main Files"
336
${CopyFilesFromDir} "$EXEDIR\core" "$INSTDIR" \
337
"$(ERROR_CREATE_DIRECTORY_PREFIX)" \
338
"$(ERROR_CREATE_DIRECTORY_SUFFIX)"
339
340
; Register DLLs
341
; XXXrstrong - AccessibleMarshal.dll can be used by multiple applications but
342
; is only registered for the last application installed. When the last
343
; application installed is uninstalled AccessibleMarshal.dll will no longer be
344
; registered. bug 338878
345
${LogHeader} "DLL Registration"
346
ClearErrors
347
${RegisterDLL} "$INSTDIR\AccessibleMarshal.dll"
348
${If} ${Errors}
349
${LogMsg} "** ERROR Registering: $INSTDIR\AccessibleMarshal.dll **"
350
${Else}
351
${LogUninstall} "DLLReg: \AccessibleMarshal.dll"
352
${LogMsg} "Registered: $INSTDIR\AccessibleMarshal.dll"
353
${EndIf}
354
355
ClearErrors
356
357
${RegisterDLL} "$INSTDIR\AccessibleHandler.dll"
358
${If} ${Errors}
359
${LogMsg} "** ERROR Registering: $INSTDIR\AccessibleHandler.dll **"
360
${Else}
361
${LogUninstall} "DLLReg: \AccessibleHandler.dll"
362
${LogMsg} "Registered: $INSTDIR\AccessibleHandler.dll"
363
${EndIf}
364
365
ClearErrors
366
367
; Default for creating Start Menu shortcut
368
; (1 = create, 0 = don't create)
369
${If} $AddStartMenuSC == ""
370
StrCpy $AddStartMenuSC "1"
371
${EndIf}
372
373
; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)
374
${If} $AddQuickLaunchSC == ""
375
; Don't install the quick launch shortcut on Windows 7
376
${If} ${AtLeastWin7}
377
StrCpy $AddQuickLaunchSC "0"
378
${Else}
379
StrCpy $AddQuickLaunchSC "1"
380
${EndIf}
381
${EndIf}
382
383
; Default for creating Desktop shortcut (1 = create, 0 = don't create)
384
${If} $AddDesktopSC == ""
385
StrCpy $AddDesktopSC "1"
386
${EndIf}
387
388
${CreateUpdateDir} "Mozilla"
389
${If} ${Errors}
390
Pop $0
391
${LogMsg} "** ERROR Failed to create update directory: $0"
392
${EndIf}
393
394
${LogHeader} "Adding Registry Entries"
395
SetShellVarContext current ; Set SHCTX to HKCU
396
${RegCleanMain} "Software\Mozilla"
397
${RegCleanUninstall}
398
${UpdateProtocolHandlers}
399
400
ClearErrors
401
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
402
${If} ${Errors}
403
StrCpy $TmpVal "HKCU" ; used primarily for logging
404
${Else}
405
SetShellVarContext all ; Set SHCTX to HKLM
406
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
407
StrCpy $TmpVal "HKLM" ; used primarily for logging
408
${RegCleanMain} "Software\Mozilla"
409
${RegCleanUninstall}
410
${UpdateProtocolHandlers}
411
412
ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
413
${If} "$0" != "${GREVersion}"
414
WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
415
${EndIf}
416
${EndIf}
417
418
${RemoveDeprecatedKeys}
419
${Set32to64DidMigrateReg}
420
421
; The previous installer adds several regsitry values to both HKLM and HKCU.
422
; We now try to add to HKLM and if that fails to HKCU
423
424
; The order that reg keys and values are added is important if you use the
425
; uninstall log to remove them on uninstall. When using the uninstall log you
426
; MUST add children first so they will be removed first on uninstall so they
427
; will be empty when the key is deleted. This allows the uninstaller to
428
; specify that only empty keys will be deleted.
429
${SetAppKeys}
430
431
${FixClassKeys}
432
433
; Uninstall keys can only exist under HKLM on some versions of windows. Since
434
; it doesn't cause problems always add them.
435
${SetUninstallKeys}
436
437
; On install always add the FirefoxHTML and FirefoxURL keys.
438
; An empty string is used for the 5th param because FirefoxHTML is not a
439
; protocol handler.
440
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
441
StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
442
443
; In Win8, the delegate execute handler picks up the value in FirefoxURL and
444
; FirefoxHTML to launch the desktop browser when it needs to.
445
${AddDisabledDDEHandlerValues} "FirefoxHTML-$AppUserModelID" "$2" "$8,1" \
446
"${AppRegName} Document" ""
447
${AddDisabledDDEHandlerValues} "FirefoxURL-$AppUserModelID" "$2" "$8,1" \
448
"${AppRegName} URL" "true"
449
450
; For pre win8, the following keys should only be set if we can write to HKLM.
451
; For post win8, the keys below can be set in HKCU if needed.
452
${If} $TmpVal == "HKLM"
453
; Set the Start Menu Internet and Registered App HKLM registry keys.
454
${SetStartMenuInternet} "HKLM"
455
${FixShellIconHandler} "HKLM"
456
${ElseIf} ${AtLeastWin8}
457
; Set the Start Menu Internet and Registered App HKCU registry keys.
458
${SetStartMenuInternet} "HKCU"
459
${FixShellIconHandler} "HKCU"
460
${EndIf}
461
462
!ifdef MOZ_MAINTENANCE_SERVICE
463
; If the maintenance service page was displayed then a value was already
464
; explicitly selected for installing the maintenance service and
465
; and so InstallMaintenanceService will already be 0 or 1.
466
; If the maintenance service page was not displayed then
467
; InstallMaintenanceService will be equal to "".
468
${If} $InstallMaintenanceService == ""
469
Call IsUserAdmin
470
Pop $R0
471
${If} $R0 == "true"
472
; Only proceed if we have HKLM write access
473
${AndIf} $TmpVal == "HKLM"
474
; The user is an admin, so we should default to installing the service.
475
StrCpy $InstallMaintenanceService "1"
476
${Else}
477
; The user is not admin, so we can't install the service.
478
StrCpy $InstallMaintenanceService "0"
479
${EndIf}
480
${EndIf}
481
482
${If} $InstallMaintenanceService == "1"
483
; The user wants to install the maintenance service, so execute
484
; the pre-packaged maintenance service installer.
485
; This option can only be turned on if the user is an admin so there
486
; is no need to use ExecShell w/ verb runas to enforce elevated.
487
nsExec::Exec "$\"$INSTDIR\maintenanceservice_installer.exe$\""
488
${EndIf}
489
!endif
490
491
!ifdef MOZ_UPDATE_AGENT
492
${PushRegisterUpdateAgentTaskCommand} "register"
493
Pop $0
494
${If} "$0" != ""
495
${LogMsg} "Registering update agent task: $0"
496
nsExec::Exec $0
497
Pop $0
498
${LogMsg} "nsExec::Exec returned $0"
499
${EndIf}
500
!endif
501
502
; These need special handling on uninstall since they may be overwritten by
503
; an install into a different location.
504
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
505
${WriteRegStr2} $TmpVal "$0" "" "$INSTDIR\${FileMainEXE}" 0
506
${WriteRegStr2} $TmpVal "$0" "Path" "$INSTDIR" 0
507
508
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\$R9"
509
${CreateRegKey} "$TmpVal" "$0" 0
510
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
511
${CreateRegKey} "$TmpVal" "$0" 0
512
513
${If} $TmpVal == "HKLM"
514
; Set the permitted LSP Categories
515
${SetAppLSPCategories} ${LSP_CATEGORIES}
516
${EndIf}
517
518
!ifdef MOZ_LAUNCHER_PROCESS
519
; Launcher telemetry is opt-out, so we always enable it by default in new
520
; installs. We always use HKCU because this value is a reflection of a pref
521
; from the user profile. While this is not a perfect abstraction (given the
522
; possibility of multiple Firefox profiles owned by the same Windows user), it
523
; is more accurate than a machine-wide setting, and should be accurate in the
524
; majority of cases.
525
WriteRegDWORD HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Telemetry" 1
526
!endif
527
528
; Create shortcuts
529
${LogHeader} "Adding Shortcuts"
530
531
; Remove the start menu shortcuts and directory if the SMPROGRAMS section
532
; exists in the shortcuts_log.ini and the SMPROGRAMS. The installer's shortcut
533
; creation code will create the shortcut in the root of the Start Menu
534
; Programs directory.
535
${RemoveStartMenuDir}
536
537
; Always add the application's shortcuts to the shortcuts log ini file. The
538
; DeleteShortcuts macro will do the right thing on uninstall if the
539
; shortcuts don't exist.
540
${LogStartMenuShortcut} "${BrandShortName}.lnk"
541
${LogQuickLaunchShortcut} "${BrandShortName}.lnk"
542
${LogDesktopShortcut} "${BrandShortName}.lnk"
543
544
; Best effort to update the Win7 taskbar and start menu shortcut app model
545
; id's. The possible contexts are current user / system and the user that
546
; elevated the installer.
547
Call FixShortcutAppModelIDs
548
; If the current context is all also perform Win7 taskbar and start menu link
549
; maintenance for the current user context.
550
${If} $TmpVal == "HKLM"
551
SetShellVarContext current ; Set SHCTX to HKCU
552
Call FixShortcutAppModelIDs
553
SetShellVarContext all ; Set SHCTX to HKLM
554
${EndIf}
555
556
; If running elevated also perform Win7 taskbar and start menu link
557
; maintenance for the unelevated user context in case that is different than
558
; the current user.
559
ClearErrors
560
${GetParameters} $0
561
${GetOptions} "$0" "/UAC:" $0
562
${Unless} ${Errors}
563
GetFunctionAddress $0 FixShortcutAppModelIDs
564
UAC::ExecCodeSegment $0
565
${EndUnless}
566
567
; UAC only allows elevating to an Admin account so there is no need to add
568
; the Start Menu or Desktop shortcuts from the original unelevated process
569
; since this will either add it for the user if unelevated or All Users if
570
; elevated.
571
${If} $AddStartMenuSC == 1
572
; See if there's an existing shortcut for this installation using the old
573
; name that we should just rename, instead of creating a new shortcut.
574
; We could do this renaming even when $AddStartMenuSC is false; the idea
575
; behind not doing that is to interpret "false" as "don't do anything
576
; involving start menu shortcuts at all." We could also try to do this for
577
; both shell contexts, but that won't typically accomplish anything.
578
${If} ${FileExists} "$SMPROGRAMS\${BrandFullName}.lnk"
579
ShellLink::GetShortCutTarget "$SMPROGRAMS\${BrandFullName}.lnk"
580
Pop $0
581
${GetLongPath} "$0" $0
582
${If} $0 == "$INSTDIR\${FileMainEXE}"
583
${AndIfNot} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
584
Rename "$SMPROGRAMS\${BrandFullName}.lnk" \
585
"$SMPROGRAMS\${BrandShortName}.lnk"
586
${LogMsg} "Renamed existing shortcut to $SMPROGRAMS\${BrandShortName}.lnk"
587
${EndIf}
588
${Else}
589
CreateShortCut "$SMPROGRAMS\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
590
${If} ${FileExists} "$SMPROGRAMS\${BrandShortName}.lnk"
591
ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandShortName}.lnk" \
592
"$INSTDIR"
593
${If} "$AppUserModelID" != ""
594
ApplicationID::Set "$SMPROGRAMS\${BrandShortName}.lnk" \
595
"$AppUserModelID" "true"
596
${EndIf}
597
${LogMsg} "Added Shortcut: $SMPROGRAMS\${BrandShortName}.lnk"
598
${Else}
599
${LogMsg} "** ERROR Adding Shortcut: $SMPROGRAMS\${BrandShortName}.lnk"
600
${EndIf}
601
${EndIf}
602
${EndIf}
603
604
; Update lastwritetime of the Start Menu shortcut to clear the tile cache.
605
; Do this for both shell contexts in case the user has shortcuts in multiple
606
; locations, then restore the previous context at the end.
607
${If} ${AtLeastWin8}
608
SetShellVarContext all
609
${TouchStartMenuShortcut}
610
SetShellVarContext current
611
${TouchStartMenuShortcut}
612
${If} $TmpVal == "HKLM"
613
SetShellVarContext all
614
${ElseIf} $TmpVal == "HKCU"
615
SetShellVarContext current
616
${EndIf}
617
${EndIf}
618
619
${If} $AddDesktopSC == 1
620
${If} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
621
ShellLink::GetShortCutTarget "$DESKTOP\${BrandFullName}.lnk"
622
Pop $0
623
${GetLongPath} "$0" $0
624
${If} $0 == "$INSTDIR\${FileMainEXE}"
625
${AndIfNot} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
626
Rename "$DESKTOP\${BrandFullName}.lnk" "$DESKTOP\${BrandShortName}.lnk"
627
${LogMsg} "Renamed existing shortcut to $DESKTOP\${BrandShortName}.lnk"
628
${EndIf}
629
${Else}
630
CreateShortCut "$DESKTOP\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
631
${If} ${FileExists} "$DESKTOP\${BrandShortName}.lnk"
632
ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandShortName}.lnk" \
633
"$INSTDIR"
634
${If} "$AppUserModelID" != ""
635
ApplicationID::Set "$DESKTOP\${BrandShortName}.lnk" \
636
"$AppUserModelID" "true"
637
${EndIf}
638
${LogMsg} "Added Shortcut: $DESKTOP\${BrandShortName}.lnk"
639
${Else}
640
${LogMsg} "** ERROR Adding Shortcut: $DESKTOP\${BrandShortName}.lnk"
641
${EndIf}
642
${EndIf}
643
${EndIf}
644
645
; If elevated the Quick Launch shortcut must be added from the unelevated
646
; original process.
647
${If} $AddQuickLaunchSC == 1
648
${Unless} ${AtLeastWin7}
649
ClearErrors
650
${GetParameters} $0
651
${GetOptions} "$0" "/UAC:" $0
652
${If} ${Errors}
653
Call AddQuickLaunchShortcut
654
${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandShortName}.lnk"
655
${Else}
656
; It is not possible to add a log entry from the unelevated process so
657
; add the log entry without the path since there is no simple way to
658
; know the correct full path.
659
${LogMsg} "Added Quick Launch Shortcut: ${BrandShortName}.lnk"
660
GetFunctionAddress $0 AddQuickLaunchShortcut
661
UAC::ExecCodeSegment $0
662
${EndIf}
663
${EndUnless}
664
${EndIf}
665
666
!ifdef MOZ_OPTIONAL_EXTENSIONS
667
${If} ${FileExists} "$INSTDIR\distribution\optional-extensions"
668
${LogHeader} "Installing optional extensions if requested"
669
670
${If} $InstallOptionalExtensions != "0"
671
${AndIf} ${FileExists} "$INSTDIR\distribution\setup.ini"
672
${Unless} ${FileExists} "$INSTDIR\distribution\extensions"
673
CreateDirectory "$INSTDIR\distribution\extensions"
674
${EndUnless}
675
676
StrCpy $0 0
677
${Do}
678
ClearErrors
679
ReadINIStr $1 "$INSTDIR\distribution\setup.ini" "OptionalExtensions" \
680
"extension.$0.id"
681
${If} ${Errors}
682
${ExitDo}
683
${EndIf}
684
685
ReadINIStr $2 "$INSTDIR\distribution\setup.ini" "OptionalExtensions" \
686
"extension.$0.checked"
687
${If} $2 != ${BST_UNCHECKED}
688
${LogMsg} "Installing optional extension: $1"
689
CopyFiles /SILENT "$INSTDIR\distribution\optional-extensions\$1.xpi" \
690
"$INSTDIR\distribution\extensions"
691
${EndIf}
692
693
IntOp $0 $0 + 1
694
${Loop}
695
${EndIf}
696
697
${LogMsg} "Removing the optional-extensions directory"
698
RMDir /r /REBOOTOK "$INSTDIR\distribution\optional-extensions"
699
${EndIf}
700
!endif
701
702
!ifdef MOZ_MAINTENANCE_SERVICE
703
${If} $TmpVal == "HKLM"
704
; Add the registry keys for allowed certificates.
705
${AddMaintCertKeys}
706
${EndIf}
707
!endif
708
709
!ifdef MOZ_DEFAULT_BROWSER_AGENT
710
${If} $RegisterDefaultAgent != "0"
711
Exec '"$INSTDIR\default-browser-agent.exe" register-task $AppUserModelID'
712
${If} $RegisterDefaultAgent == ""
713
; If the variable was unset, force it to a good value.
714
StrCpy $RegisterDefaultAgent 1
715
${EndIf}
716
${EndIf}
717
; Remember whether we were told to skip registering the agent, so that updates
718
; won't try to create a registration when they don't find an existing one.
719
WriteRegDWORD HKCU "Software\Mozilla\${AppName}\Installer\$AppUserModelID" \
720
"DidRegisterDefaultBrowserAgent" $RegisterDefaultAgent
721
!endif
722
SectionEnd
723
724
; Cleanup operations to perform at the end of the installation.
725
Section "-InstallEndCleanup"
726
SetDetailsPrint both
727
DetailPrint "$(STATUS_CLEANUP)"
728
SetDetailsPrint none
729
730
${Unless} ${Silent}
731
ClearErrors
732
${MUI_INSTALLOPTIONS_READ} $0 "summary.ini" "Field 4" "State"
733
${If} "$0" == "1"
734
StrCpy $SetAsDefault true
735
; For data migration in the app, we want to know what the default browser
736
; value was before we changed it. To do so, we read it here and store it
737
; in our own registry key.
738
StrCpy $0 ""
739
AppAssocReg::QueryCurrentDefault "http" "protocol" "effective"
740
Pop $1
741
; If the method hasn't failed, $1 will contain the progid. Check:
742
${If} "$1" != "method failed"
743
${AndIf} "$1" != "method not available"
744
; Read the actual command from the progid
745
ReadRegStr $0 HKCR "$1\shell\open\command" ""
746
${EndIf}
747
; If using the App Association Registry didn't happen or failed, fall back
748
; to the effective http default:
749
${If} "$0" == ""
750
ReadRegStr $0 HKCR "http\shell\open\command" ""
751
${EndIf}
752
; If we have something other than empty string now, write the value.
753
${If} "$0" != ""
754
ClearErrors
755
WriteRegStr HKCU "Software\Mozilla\Firefox" "OldDefaultBrowserCommand" "$0"
756
${EndIf}
757
758
${LogHeader} "Setting as the default browser"
759
ClearErrors
760
${GetParameters} $0
761
${GetOptions} "$0" "/UAC:" $0
762
${If} ${Errors}
763
Call SetAsDefaultAppUserHKCU
764
${Else}
765
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
766
UAC::ExecCodeSegment $0
767
${EndIf}
768
${ElseIfNot} ${Errors}
769
StrCpy $SetAsDefault false
770
${LogHeader} "Writing default-browser opt-out"
771
ClearErrors
772
WriteRegStr HKCU "Software\Mozilla\Firefox" "DefaultBrowserOptOut" "True"
773
${If} ${Errors}
774
${LogMsg} "Error writing default-browser opt-out"
775
${EndIf}
776
${EndIf}
777
${EndUnless}
778
779
; Adds a pinned Task Bar shortcut (see MigrateTaskBarShortcut for details).
780
${MigrateTaskBarShortcut}
781
782
; Add the Firewall entries during install
783
Call AddFirewallEntries
784
785
; Refresh desktop icons
786
${RefreshShellIcons}
787
788
${InstallEndCleanupCommon}
789
790
${If} $PreventRebootRequired == "true"
791
SetRebootFlag false
792
${EndIf}
793
794
${If} ${RebootFlag}
795
; Admin is required to delete files on reboot so only add the moz-delete if
796
; the user is an admin. After calling UAC::IsAdmin $0 will equal 1 if the
797
; user is an admin.
798
UAC::IsAdmin
799
${If} "$0" == "1"
800
; When a reboot is required give RefreshShellIcons time to finish the
801
; refreshing the icons so the OS doesn't display the icons from helper.exe
802
Sleep 10000
803
${LogHeader} "Reboot Required To Finish Installation"
804
; ${FileMainEXE}.moz-upgrade should never exist but just in case...
805
${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-upgrade"
806
Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-upgrade"
807
${EndUnless}
808
809
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
810
ClearErrors
811
Rename "$INSTDIR\${FileMainEXE}" "$INSTDIR\${FileMainEXE}.moz-delete"
812
${Unless} ${Errors}
813
Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
814
${EndUnless}
815
${EndIf}
816
817
${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}"
818
CopyFiles /SILENT "$INSTDIR\uninstall\helper.exe" "$INSTDIR"
819
FileOpen $0 "$INSTDIR\${FileMainEXE}" w
820
FileWrite $0 "Will be deleted on restart"
821
Rename /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-upgrade" "$INSTDIR\${FileMainEXE}"
822
FileClose $0
823
Delete "$INSTDIR\${FileMainEXE}"
824
Rename "$INSTDIR\helper.exe" "$INSTDIR\${FileMainEXE}"
825
${EndUnless}
826
${EndIf}
827
${EndIf}
828
829
StrCpy $InstallResult "success"
830
831
; When we're using the GUI, .onGUIEnd sends the ping, but of course that isn't
832
; invoked when we're running silently.
833
${If} ${Silent}
834
Call SendPing
835
${EndIf}
836
SectionEnd
837
838
################################################################################
839
# Install Abort Survey Functions
840
841
Function CustomAbort
842
${If} "${AB_CD}" == "en-US"
843
${AndIf} "$PageName" != ""
844
${AndIf} ${FileExists} "$EXEDIR\core\distribution\distribution.ini"
845
ReadINIStr $0 "$EXEDIR\core\distribution\distribution.ini" "Global" "about"
846
ClearErrors
847
${WordFind} "$0" "Funnelcake" "E#" $1
848
${Unless} ${Errors}
849
; Yes = fill out the survey and exit, No = don't fill out survey and exit,
850
; Cancel = don't exit.
851
MessageBox MB_YESNO|MB_ICONEXCLAMATION \
852
"Would you like to tell us why you are canceling this installation?" \
853
IDYes +1 IDNO CustomAbort_finish
854
${If} "$PageName" == "Welcome"
855
GetFunctionAddress $0 AbortSurveyWelcome
856
${ElseIf} "$PageName" == "Options"
857
GetFunctionAddress $0 AbortSurveyOptions
858
${ElseIf} "$PageName" == "Directory"
859
GetFunctionAddress $0 AbortSurveyDirectory
860
${ElseIf} "$PageName" == "Shortcuts"
861
GetFunctionAddress $0 AbortSurveyShortcuts
862
${ElseIf} "$PageName" == "Summary"
863
GetFunctionAddress $0 AbortSurveySummary
864
${EndIf}
865
ClearErrors
866
${GetParameters} $1
867
${GetOptions} "$1" "/UAC:" $2
868
${If} ${Errors}
869
Call $0
870
${Else}
871
UAC::ExecCodeSegment $0
872
${EndIf}
873
874
CustomAbort_finish:
875
Return
876
${EndUnless}
877
${EndIf}
878
879
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(MOZ_MUI_TEXT_ABORTWARNING)" \
880
IDYES +1 IDNO +2
881
Return
882
Abort
883
FunctionEnd
884
885
Function AbortSurveyWelcome
886
ExecShell "open" "${AbortSurveyURL}step1"
887
FunctionEnd
888
889
Function AbortSurveyOptions
890
ExecShell "open" "${AbortSurveyURL}step2"
891
FunctionEnd
892
893
Function AbortSurveyDirectory
894
ExecShell "open" "${AbortSurveyURL}step3"
895
FunctionEnd
896
897
Function AbortSurveyShortcuts
898
ExecShell "open" "${AbortSurveyURL}step4"
899
FunctionEnd
900
901
Function AbortSurveySummary
902
ExecShell "open" "${AbortSurveyURL}step5"
903
FunctionEnd
904
905
################################################################################
906
# Helper Functions
907
908
Function AddQuickLaunchShortcut
909
CreateShortCut "$QUICKLAUNCH\${BrandShortName}.lnk" "$INSTDIR\${FileMainEXE}"
910
${If} ${FileExists} "$QUICKLAUNCH\${BrandShortName}.lnk"
911
ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandShortName}.lnk" \
912
"$INSTDIR"
913
${EndIf}
914
FunctionEnd
915
916
Function CheckExistingInstall
917
; If there is a pending file copy from a previous upgrade don't allow
918
; installing until after the system has rebooted.
919
IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
920
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
921
Reboot
922
Quit
923
924
; If there is a pending file deletion from a previous uninstall don't allow
925
; installing until after the system has rebooted.
926
IfFileExists "$INSTDIR\${FileMainEXE}.moz-delete" +1 +4
927
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(WARN_RESTART_REQUIRED_UNINSTALL)" IDNO +2
928
Reboot
929
Quit
930
931
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
932
; Disable the next, cancel, and back buttons
933
GetDlgItem $0 $HWNDPARENT 1 ; Next button
934
EnableWindow $0 0
935
GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
936
EnableWindow $0 0
937
GetDlgItem $0 $HWNDPARENT 3 ; Back button
938
EnableWindow $0 0
939
940
Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
941
942
${If} "$TmpVal" == "FoundAppWindow"
943
Sleep 5000
944
${EndIf}
945
946
${PushFilesToCheck}
947
948
; Store the return value in $TmpVal so it is less likely to be accidentally
949
; overwritten elsewhere.
950
${CheckForFilesInUse} $TmpVal
951
952
Banner::destroy
953
954
; Enable the next, cancel, and back buttons
955
GetDlgItem $0 $HWNDPARENT 1 ; Next button
956
EnableWindow $0 1
957
GetDlgItem $0 $HWNDPARENT 2 ; Cancel button
958
EnableWindow $0 1
959
GetDlgItem $0 $HWNDPARENT 3 ; Back button
960
EnableWindow $0 1
961
962
; If there are files in use $TmpVal will be "true"
963
${If} "$TmpVal" == "true"
964
; If it finds a window of the right class, then ManualCloseAppPrompt will
965
; abort leaving the value of $TmpVal set to "FoundAppWindow".
966
StrCpy $TmpVal "FoundAppWindow"
967
${ManualCloseAppPrompt} "${MainWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
968
${ManualCloseAppPrompt} "${DialogWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
969
StrCpy $TmpVal "true"
970
${EndIf}
971
${EndIf}
972
FunctionEnd
973
974
Function LaunchApp
975
ClearErrors
976
${GetParameters} $0
977
${GetOptions} "$0" "/UAC:" $1
978
${If} ${Errors}
979
${ExecAndWaitForInputIdle} "$\"$INSTDIR\${FileMainEXE}$\" -first-startup"
980
${Else}
981
GetFunctionAddress $0 LaunchAppFromElevatedProcess
982
UAC::ExecCodeSegment $0
983
${EndIf}
984
985
StrCpy $LaunchedNewApp true
986
FunctionEnd
987
988
Function LaunchAppFromElevatedProcess
989
; Set our current working directory to the application's install directory
990
; otherwise the 7-Zip temp directory will be in use and won't be deleted.
991
SetOutPath "$INSTDIR"
992
${ExecAndWaitForInputIdle} "$\"$INSTDIR\${FileMainEXE}$\" -first-startup"
993
FunctionEnd
994
995
Function SendPing
996
${GetParameters} $0
997
${GetOptions} $0 "/LaunchedFromStub" $0
998
${IfNot} ${Errors}
999
Return
1000
${EndIf}
1001
1002
; Create a GUID to use as the unique document ID.
1003
System::Call "rpcrt4::UuidCreate(g . r0)i"
1004
; StringFromGUID2 (which is what System::Call uses internally to stringify
1005
; GUIDs) includes braces in its output, and we don't want those.
1006
StrCpy $0 $0 -1 1
1007
1008
; Configure the HTTP request for the ping
1009
nsJSON::Set /tree ping /value "{}"
1010
nsJSON::Set /tree ping "Url" /value \
1011
'"${TELEMETRY_BASE_URL}/${TELEMETRY_NAMESPACE}/${TELEMETRY_INSTALL_PING_DOCTYPE}/${TELEMETRY_INSTALL_PING_VERSION}/$0"'
1012
nsJSON::Set /tree ping "Verb" /value '"POST"'
1013
nsJSON::Set /tree ping "DataType" /value '"JSON"'
1014
nsJSON::Set /tree ping "AccessType" /value '"PreConfig"'
1015
1016
; Fill in the ping payload
1017
nsJSON::Set /tree ping "Data" /value "{}"
1018
nsJSON::Set /tree ping "Data" "installer_type" /value '"full"'
1019
nsJSON::Set /tree ping "Data" "installer_version" /value '"${AppVersion}"'
1020
nsJSON::Set /tree ping "Data" "build_channel" /value '"${Channel}"'
1021
nsJSON::Set /tree ping "Data" "update_channel" /value '"${UpdateChannel}"'
1022
nsJSON::Set /tree ping "Data" "locale" /value '"${AB_CD}"'
1023
1024
ReadINIStr $0 "$INSTDIR\application.ini" "App" "Version"
1025
nsJSON::Set /tree ping "Data" "version" /value '"$0"'
1026
ReadINIStr $0 "$INSTDIR\application.ini" "App" "BuildID"
1027
nsJSON::Set /tree ping "Data" "build_id" /value '"$0"'
1028
1029
${GetParameters} $0
1030
${GetOptions} $0 "/LaunchedFromMSI" $0
1031
${IfNot} ${Errors}
1032
nsJSON::Set /tree ping "Data" "from_msi" /value true
1033
${EndIf}
1034
1035
!ifdef HAVE_64BIT_BUILD
1036
nsJSON::Set /tree ping "Data" "64bit_build" /value true
1037
!else
1038
nsJSON::Set /tree ping "Data" "64bit_build" /value false
1039
!endif
1040
1041
${If} ${RunningX64}
1042
nsJSON::Set /tree ping "Data" "64bit_os" /value true
1043
${Else}
1044
nsJSON::Set /tree ping "Data" "64bit_os" /value false
1045
${EndIf}
1046
1047
; Though these values are sometimes incorrect due to bug 444664 it happens
1048
; so rarely it isn't worth working around it by reading the registry values.
1049
${WinVerGetMajor} $0
1050
${WinVerGetMinor} $1
1051
${WinVerGetBuild} $2
1052
nsJSON::Set /tree ping "Data" "os_version" /value '"$0.$1.$2"'
1053
${If} ${IsServerOS}
1054
nsJSON::Set /tree ping "Data" "server_os" /value true
1055
${Else}
1056
nsJSON::Set /tree ping "Data" "server_os" /value false
1057
${EndIf}
1058
1059
ClearErrors
1060
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" \
1061
"Write Test"
1062
${If} ${Errors}
1063
nsJSON::Set /tree ping "Data" "admin_user" /value false
1064
${Else}
1065
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
1066
nsJSON::Set /tree ping "Data" "admin_user" /value true
1067
${EndIf}
1068
1069
${If} $DefaultInstDir == $INSTDIR
1070
nsJSON::Set /tree ping "Data" "default_path" /value true
1071
${Else}
1072
nsJSON::Set /tree ping "Data" "default_path" /value false
1073
${EndIf}
1074
1075
nsJSON::Set /tree ping "Data" "set_default" /value "$SetAsDefault"
1076
1077
nsJSON::Set /tree ping "Data" "new_default" /value false
1078
nsJSON::Set /tree ping "Data" "old_default" /value false
1079
1080
AppAssocReg::QueryCurrentDefault "http" "protocol" "effective"
1081
Pop $0
1082
ReadRegStr $0 HKCR "$0\shell\open\command" ""
1083
${If} $0 != ""
1084
${GetPathFromString} "$0" $0
1085
${GetParent} "$0" $1
1086
${GetLongPath} "$1" $1
1087
${If} $1 == $INSTDIR
1088
nsJSON::Set /tree ping "Data" "new_default" /value true
1089
${Else}
1090
StrCpy $0 "$0" "" -11 # 11 == length of "firefox.exe"
1091
${If} "$0" == "${FileMainEXE}"
1092
nsJSON::Set /tree ping "Data" "old_default" /value true
1093
${EndIf}
1094
${EndIf}
1095
${EndIf}
1096
1097
nsJSON::Set /tree ping "Data" "had_old_install" /value "$HadOldInstall"
1098
1099
${If} ${Silent}
1100
; In silent mode, only the install phase is executed, and the GUI events
1101
; that initialize most of the phase times are never called; only
1102
; $InstallPhaseStart and $FinishPhaseStart have usable values.
1103
${GetSecondsElapsed} $InstallPhaseStart $FinishPhaseStart $0
1104
1105
nsJSON::Set /tree ping "Data" "intro_time" /value 0
1106
nsJSON::Set /tree ping "Data" "options_time" /value 0
1107
nsJSON::Set /tree ping "Data" "install_time" /value "$0"
1108
nsJSON::Set /tree ping "Data" "finish_time" /value 0
1109
${Else}
1110
; In GUI mode, all we can be certain of is that the intro phase has started;
1111
; the user could have canceled at any time and phases after that won't
1112
; have run at all. So we have to be prepared for anything after
1113
; $IntroPhaseStart to be uninitialized. For anything that isn't filled in
1114
; yet we'll use the current tick count. That means that any phases that
1115
; weren't entered at all will get 0 for their times because the start and
1116
; end tick counts will be the same.
1117
System::Call "kernel32::GetTickCount()l .s"
1118
Pop $0
1119
1120
${If} $OptionsPhaseStart == 0
1121
StrCpy $OptionsPhaseStart $0
1122
${EndIf}
1123
${GetSecondsElapsed} $IntroPhaseStart $OptionsPhaseStart $1
1124
nsJSON::Set /tree ping "Data" "intro_time" /value "$1"
1125
1126
${If} $InstallPhaseStart == 0
1127
StrCpy $InstallPhaseStart $0
1128
${EndIf}
1129
${GetSecondsElapsed} $OptionsPhaseStart $InstallPhaseStart $1
1130
nsJSON::Set /tree ping "Data" "options_time" /value "$1"
1131
1132
${If} $FinishPhaseStart == 0
1133
StrCpy $FinishPhaseStart $0
1134
${EndIf}
1135
${GetSecondsElapsed} $InstallPhaseStart $FinishPhaseStart $1
1136
nsJSON::Set /tree ping "Data" "install_time" /value "$1"
1137
1138
${If} $FinishPhaseEnd == 0
1139
StrCpy $FinishPhaseEnd $0
1140
${EndIf}
1141
${GetSecondsElapsed} $FinishPhaseStart $FinishPhaseEnd $1
1142
nsJSON::Set /tree ping "Data" "finish_time" /value "$1"
1143
${EndIf}
1144
1145
nsJSON::Set /tree ping "Data" "new_launched" /value "$LaunchedNewApp"
1146
1147
nsJSON::Set /tree ping "Data" "succeeded" /value false
1148
${If} $InstallResult == "cancel"
1149
nsJSON::Set /tree ping "Data" "user_cancelled" /value true
1150
${ElseIf} $InstallResult == "success"
1151
nsJSON::Set /tree ping "Data" "succeeded" /value true
1152
${EndIf}
1153
1154
${If} ${Silent}
1155
nsJSON::Set /tree ping "Data" "silent" /value true
1156
${Else}
1157
nsJSON::Set /tree ping "Data" "silent" /value false
1158
${EndIf}
1159
1160
; Send the ping request. This call will block until a response is received,
1161
; but we shouldn't have any windows still open, so we won't jank anything.
1162
nsJSON::Set /http ping
1163
FunctionEnd
1164
1165
################################################################################
1166
# Language
1167
1168
!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
1169
!verbose push
1170
!verbose 3
1171
!include "overrideLocale.nsh"
1172
!include "customLocale.nsh"
1173
!ifdef MOZ_OPTIONAL_EXTENSIONS
1174
!include "extensionsLocale.nsh"
1175
!endif
1176
!verbose pop
1177
1178
; Set this after the locale files to override it if it is in the locale
1179
; using " " for BrandingText will hide the "Nullsoft Install System..." branding
1180
BrandingText " "
1181
1182
################################################################################
1183
# Page pre, show, and leave functions
1184
1185
Function preWelcome
1186
StrCpy $PageName "Welcome"
1187
${If} ${FileExists} "$EXEDIR\core\distribution\modern-wizard.bmp"
1188
Delete "$PLUGINSDIR\modern-wizard.bmp"
1189
CopyFiles /SILENT "$EXEDIR\core\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
1190
${EndIf}
1191
1192
; We don't want the header bitmap showing on the welcome page.
1193
GetDlgItem $0 $HWNDPARENT 1046
1194
ShowWindow $0 ${SW_HIDE}
1195
1196
System::Call "kernel32::GetTickCount()l .s"
1197
Pop $IntroPhaseStart
1198
FunctionEnd
1199
1200
Function showWelcome
1201
; The welcome and finish pages don't get the correct colors for their labels
1202
; like the other pages do, presumably because they're built by filling in an
1203
; InstallOptions .ini file instead of from a dialog resource like the others.
1204
; Field 2 is the header and Field 3 is the body text.
1205
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 2" "HWND"
1206
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1207
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 3" "HWND"
1208
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1209
1210
; We need to overwrite the sidebar image so that we get it drawn with proper
1211
; scaling if the display is scaled at anything above 100%.
1212
${ChangeMUISidebarImage} "$PLUGINSDIR\modern-wizard.bmp"
1213
FunctionEnd
1214
1215
Function leaveWelcome
1216
; Bring back the header bitmap for the next pages.
1217
GetDlgItem $0 $HWNDPARENT 1046
1218
ShowWindow $0 ${SW_SHOW}
1219
FunctionEnd
1220
1221
Function preOptions
1222
System::Call "kernel32::GetTickCount()l .s"
1223
Pop $OptionsPhaseStart
1224
1225
; The header and subheader on the wizard pages don't get the correct text
1226
; color by default for some reason, even though the other controls do.
1227
GetDlgItem $0 $HWNDPARENT 1037
1228
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1229
GetDlgItem $0 $HWNDPARENT 1038
1230
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1231
1232
StrCpy $PageName "Options"
1233
${If} ${FileExists} "$EXEDIR\core\distribution\modern-header.bmp"
1234
Delete "$PLUGINSDIR\modern-header.bmp"
1235
CopyFiles /SILENT "$EXEDIR\core\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
1236
${EndIf}
1237
${ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
1238
!insertmacro MUI_HEADER_TEXT "$(OPTIONS_PAGE_TITLE)" "$(OPTIONS_PAGE_SUBTITLE)"
1239
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "options.ini"
1240
FunctionEnd
1241
1242
Function leaveOptions
1243
${MUI_INSTALLOPTIONS_READ} $0 "options.ini" "Settings" "State"
1244
${If} $0 != 0
1245
Abort
1246
${EndIf}
1247
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 2" "State"
1248
StrCmp $R0 "1" +1 +2
1249
StrCpy $InstallType ${INSTALLTYPE_BASIC}
1250
${MUI_INSTALLOPTIONS_READ} $R0 "options.ini" "Field 3" "State"
1251
StrCmp $R0 "1" +1 +2
1252
StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
1253
1254
${LeaveOptionsCommon}
1255
1256
${If} $InstallType == ${INSTALLTYPE_BASIC}
1257
Call CheckExistingInstall
1258
${EndIf}
1259
FunctionEnd
1260
1261
Function preDirectory
1262
StrCpy $PageName "Directory"
1263
${PreDirectoryCommon}
1264
1265
StrCpy $DefaultInstDir $INSTDIR
1266
FunctionEnd
1267
1268
Function leaveDirectory
1269
${If} $InstallType == ${INSTALLTYPE_BASIC}
1270
Call CheckExistingInstall
1271
${EndIf}
1272
${LeaveDirectoryCommon} "$(WARN_DISK_SPACE)" "$(WARN_WRITE_ACCESS)"
1273
FunctionEnd
1274
1275
Function preShortcuts
1276
StrCpy $PageName "Shortcuts"
1277
${CheckCustomCommon}
1278
!insertmacro MUI_HEADER_TEXT "$(SHORTCUTS_PAGE_TITLE)" "$(SHORTCUTS_PAGE_SUBTITLE)"
1279
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "shortcuts.ini"
1280
FunctionEnd
1281
1282
Function leaveShortcuts
1283
${MUI_INSTALLOPTIONS_READ} $0 "shortcuts.ini" "Settings" "State"
1284
${If} $0 != 0
1285
Abort
1286
${EndIf}
1287
${MUI_INSTALLOPTIONS_READ} $AddDesktopSC "shortcuts.ini" "Field 2" "State"
1288
${MUI_INSTALLOPTIONS_READ} $AddStartMenuSC "shortcuts.ini" "Field 3" "State"
1289
1290
; Don't install the quick launch shortcut on Windows 7
1291
${Unless} ${AtLeastWin7}
1292
${MUI_INSTALLOPTIONS_READ} $AddQuickLaunchSC "shortcuts.ini" "Field 4" "State"
1293
${EndUnless}
1294
1295
${If} $InstallType == ${INSTALLTYPE_CUSTOM}
1296
Call CheckExistingInstall
1297
${EndIf}
1298
FunctionEnd
1299
1300
!ifdef MOZ_MAINTENANCE_SERVICE
1301
Function preComponents
1302
; If the service already exists, don't show this page
1303
ServicesHelper::IsInstalled "MozillaMaintenance"
1304
Pop $R9
1305
${If} $R9 == 1
1306
; The service already exists so don't show this page.
1307
Abort
1308
${EndIf}
1309
1310
; Don't show the custom components page if the
1311
; user is not an admin
1312
Call IsUserAdmin
1313
Pop $R9
1314
${If} $R9 != "true"
1315
Abort
1316
${EndIf}
1317
1318
; Only show the maintenance service page if we have write access to HKLM
1319
ClearErrors
1320
WriteRegStr HKLM "Software\Mozilla" \
1321
"${BrandShortName}InstallerTest" "Write Test"
1322
${If} ${Errors}
1323
ClearErrors
1324
Abort
1325
${Else}
1326
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
1327
${EndIf}
1328
1329
StrCpy $PageName "Components"
1330
${CheckCustomCommon}
1331
!insertmacro MUI_HEADER_TEXT "$(COMPONENTS_PAGE_TITLE)" "$(COMPONENTS_PAGE_SUBTITLE)"
1332
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "components.ini"
1333
FunctionEnd
1334
1335
Function leaveComponents
1336
${MUI_INSTALLOPTIONS_READ} $0 "components.ini" "Settings" "State"
1337
${If} $0 != 0
1338
Abort
1339
${EndIf}
1340
${MUI_INSTALLOPTIONS_READ} $InstallMaintenanceService "components.ini" "Field 2" "State"
1341
${If} $InstallType == ${INSTALLTYPE_CUSTOM}
1342
Call CheckExistingInstall
1343
${EndIf}
1344
FunctionEnd
1345
!endif
1346
1347
!ifdef MOZ_OPTIONAL_EXTENSIONS
1348
Function preExtensions
1349
StrCpy $PageName "Extensions"
1350
${CheckCustomCommon}
1351
1352
; Abort if no optional extensions configured in distribution/setup.ini
1353
${If} ${FileExists} "$EXEDIR\core\distribution\setup.ini"
1354
ClearErrors
1355
ReadINIStr $ExtensionRecommender "$EXEDIR\core\distribution\setup.ini" \
1356
"OptionalExtensions" "Recommender.${AB_CD}"
1357
${If} ${Errors}
1358
ClearErrors
1359
ReadINIStr $ExtensionRecommender "$EXEDIR\core\distribution\setup.ini" \
1360
"OptionalExtensions" "Recommender"
1361
${EndIf}
1362
1363
${If} ${Errors}
1364
ClearErrors
1365
Abort
1366
${EndIf}
1367
${Else}
1368
Abort
1369
${EndIf}
1370
1371
!insertmacro MUI_HEADER_TEXT "$(EXTENSIONS_PAGE_TITLE)" "$(EXTENSIONS_PAGE_SUBTITLE)"
1372
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "extensions.ini"
1373
FunctionEnd
1374
1375
Function leaveExtensions
1376
${MUI_INSTALLOPTIONS_READ} $0 "extensions.ini" "Settings" "NumFields"
1377
${MUI_INSTALLOPTIONS_READ} $1 "extensions.ini" "Settings" "State"
1378
1379
; $0 is count of checkboxes
1380
IntOp $0 $0 - 1
1381
1382
${If} $1 > $0
1383
Abort
1384
${ElseIf} $1 == 0
1385
; $1 is count of selected optional extension(s)
1386
StrCpy $1 0
1387
1388
StrCpy $2 2
1389
${Do}
1390
${MUI_INSTALLOPTIONS_READ} $3 "extensions.ini" "Field $2" "State"
1391
${If} $3 == ${BST_CHECKED}
1392
IntOp $1 $1 + 1
1393
${EndIf}
1394
1395
IntOp $4 $2 - 2
1396
WriteINIStr "$EXEDIR\core\distribution\setup.ini" \
1397
"OptionalExtensions" "extension.$4.checked" "$3"
1398
1399
${If} $0 == $2
1400
${ExitDo}
1401
${Else}
1402
IntOp $2 $2 + 1
1403
${EndIf}
1404
${Loop}
1405
1406
; Different from state of field 1, "0" means no optional extensions selected
1407
${If} $1 > 0
1408
StrCpy $InstallOptionalExtensions "1"
1409
${Else}
1410
StrCpy $InstallOptionalExtensions "0"
1411
${EndIf}
1412
1413
${If} $InstallType == ${INSTALLTYPE_CUSTOM}
1414
Call CheckExistingInstall
1415
${EndIf}
1416
${ElseIf} $1 == 1
1417
; Check/uncheck all optional extensions with field 1
1418
${MUI_INSTALLOPTIONS_READ} $1 "extensions.ini" "Field 1" "State"
1419
1420
StrCpy $2 2
1421
${Do}
1422
${MUI_INSTALLOPTIONS_READ} $3 "extensions.ini" "Field $2" "HWND"
1423
SendMessage $3 ${BM_SETCHECK} $1 0
1424
1425
${If} $0 == $2
1426
${ExitDo}
1427
${Else}
1428
IntOp $2 $2 + 1
1429
${EndIf}
1430
${Loop}
1431
1432
Abort
1433
${ElseIf} $1 > 1
1434
StrCpy $1 ${BST_CHECKED}
1435
1436
StrCpy $2 2
1437
${Do}
1438
${MUI_INSTALLOPTIONS_READ} $3 "extensions.ini" "Field $2" "State"
1439
${If} $3 == ${BST_UNCHECKED}
1440
StrCpy $1 ${BST_UNCHECKED}
1441
${ExitDo}
1442
${EndIf}
1443
1444
${If} $0 == $2
1445
${ExitDo}
1446
${Else}
1447
IntOp $2 $2 + 1
1448
${EndIf}
1449
${Loop}
1450
1451
; Check field 1 only if all optional extensions are selected
1452
${MUI_INSTALLOPTIONS_READ} $3 "extensions.ini" "Field 1" "HWND"
1453
SendMessage $3 ${BM_SETCHECK} $1 0
1454
1455
Abort
1456
${EndIf}
1457
FunctionEnd
1458
!endif
1459
1460
Function preSummary
1461
StrCpy $PageName "Summary"
1462
; Setup the summary.ini file for the Custom Summary Page
1463
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "3"
1464
1465
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Type "label"
1466
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Text "$(SUMMARY_INSTALLED_TO)"
1467
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Left "0"
1468
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Right "-1"
1469
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Top "5"
1470
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 1" Bottom "15"
1471
1472
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Type "text"
1473
; The contents of this control must be set as follows in the pre function
1474
; ${MUI_INSTALLOPTIONS_READ} $1 "summary.ini" "Field 2" "HWND"
1475
; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
1476
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" state ""
1477
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Left "0"
1478
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Right "-1"
1479
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Top "17"
1480
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" Bottom "30"
1481
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 2" flags "READONLY"
1482
1483
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Type "label"
1484
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Left "0"
1485
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Right "-1"
1486
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Top "130"
1487
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Bottom "150"
1488
1489
${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
1490
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Text "$(SUMMARY_UPGRADE_CLICK)"
1491
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NextButtonText "$(UPGRADE_BUTTON)"
1492
${Else}
1493
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 3" Text "$(SUMMARY_INSTALL_CLICK)"
1494
DeleteINIStr "$PLUGINSDIR\summary.ini" "Settings" NextButtonText
1495
${EndIf}
1496
1497
1498
; Remove the "Field 4" ini section in case the user hits back and changes the
1499
; installation directory which could change whether the make default checkbox
1500
; should be displayed.
1501
DeleteINISec "$PLUGINSDIR\summary.ini" "Field 4"
1502
1503
; Check if it is possible to write to HKLM
1504
ClearErrors
1505
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
1506
${Unless} ${Errors}
1507
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
1508
; Check if Firefox is the http handler for this user.
1509
SetShellVarContext current ; Set SHCTX to the current user
1510
${IsHandlerForInstallDir} "http" $R9
1511
; If Firefox isn't the http handler for this user show the option to set
1512
; Firefox as the default browser.
1513
${If} "$R9" != "true"
1514
${AndIf} ${AtMostWin2008R2}
1515
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "4"
1516
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Type "checkbox"
1517
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Text "$(SUMMARY_TAKE_DEFAULTS)"
1518
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Left "0"
1519
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Right "-1"
1520
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" State "1"
1521
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Top "32"
1522
WriteINIStr "$PLUGINSDIR\summary.ini" "Field 4" Bottom "53"
1523
${EndIf}
1524
${EndUnless}
1525
1526
${If} "$TmpVal" == "true"
1527
; If there is already a Type entry in the "Field 4" section with a value of
1528
; checkbox then the set as the default browser checkbox is displayed and
1529
; this text must be moved below it.
1530
ReadINIStr $0 "$PLUGINSDIR\summary.ini" "Field 4" "Type"
1531
${If} "$0" == "checkbox"
1532
StrCpy $0 "5"
1533
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top "53"
1534
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "68"
1535
${Else}
1536
StrCpy $0 "4"
1537
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Top "35"
1538
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Bottom "50"
1539
${EndIf}
1540
WriteINIStr "$PLUGINSDIR\summary.ini" "Settings" NumFields "$0"
1541
1542
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Type "label"
1543
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Text "$(SUMMARY_REBOOT_REQUIRED_INSTALL)"
1544
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Left "0"
1545
WriteINIStr "$PLUGINSDIR\summary.ini" "Field $0" Right "-1"
1546
${EndIf}
1547
1548
!insertmacro MUI_HEADER_TEXT "$(SUMMARY_PAGE_TITLE)" "$(SUMMARY_PAGE_SUBTITLE)"
1549
1550
; The Summary custom page has a textbox that will automatically receive
1551
; focus. This sets the focus to the Install button instead.
1552
!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "summary.ini"
1553
GetDlgItem $0 $HWNDPARENT 1
1554
System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
1555
${MUI_INSTALLOPTIONS_READ} $1 "summary.ini" "Field 2" "HWND"
1556
SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
1557
!insertmacro MUI_INSTALLOPTIONS_SHOW
1558
FunctionEnd
1559
1560
Function leaveSummary
1561
; Try to delete the app executable and if we can't delete it try to find the
1562
; app's message window and prompt the user to close the app. This allows
1563
; running an instance that is located in another directory. If for whatever
1564
; reason there is no message window we will just rename the app's files and
1565
; then remove them on restart.
1566
ClearErrors
1567
${DeleteFile} "$INSTDIR\${FileMainEXE}"
1568
${If} ${Errors}
1569
${ManualCloseAppPrompt} "${MainWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
1570
${ManualCloseAppPrompt} "${DialogWindowClass}" "$(WARN_MANUALLY_CLOSE_APP_INSTALL)"
1571
${EndIf}
1572
FunctionEnd
1573
1574
; When we add an optional action to the finish page the cancel button is
1575
; enabled. This disables it and leaves the finish button as the only choice.
1576
Function preFinish
1577
System::Call "kernel32::GetTickCount()l .s"
1578
Pop $FinishPhaseStart
1579
1580
StrCpy $PageName ""
1581
${EndInstallLog} "${BrandFullName}"
1582
!insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
1583
1584
; We don't want the header bitmap showing on the finish page.
1585
GetDlgItem $0 $HWNDPARENT 1046
1586
ShowWindow $0 ${SW_HIDE}
1587
FunctionEnd
1588
1589
Function showFinish
1590
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 2" "HWND"
1591
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1592
1593
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 3" "HWND"
1594
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1595
1596
; We need to overwrite the sidebar image so that we get it drawn with proper
1597
; scaling if the display is scaled at anything above 100%.
1598
${ChangeMUISidebarImage} "$PLUGINSDIR\modern-wizard.bmp"
1599
1600
; Field 4 is the launch checkbox. Since it's a checkbox, we need to
1601
; clear the theme from it before we can set its background color.
1602
ReadINIStr $0 "$PLUGINSDIR\ioSpecial.ini" "Field 4" "HWND"
1603
System::Call 'uxtheme::SetWindowTheme(i $0, w " ", w " ")'
1604
SetCtlColors $0 SYSCLR:WINDOWTEXT SYSCLR:WINDOW
1605
FunctionEnd
1606
1607
Function postFinish
1608
System::Call "kernel32::GetTickCount()l .s"
1609
Pop $FinishPhaseEnd
1610
FunctionEnd
1611
1612
################################################################################
1613
# Initialization Functions
1614
1615
Function .onInit
1616
; Remove the current exe directory from the search order.
1617
; This only effects LoadLibrary calls and not implicitly loaded DLLs.
1618
System::Call 'kernel32::SetDllDirectoryW(w "")'
1619
1620
; Initialize the variables used for telemetry
1621
StrCpy $SetAsDefault true
1622
StrCpy $HadOldInstall false
1623
StrCpy $DefaultInstDir $INSTDIR
1624
StrCpy $IntroPhaseStart 0
1625
StrCpy $OptionsPhaseStart 0
1626
StrCpy $InstallPhaseStart 0
1627
StrCpy $FinishPhaseStart 0
1628
StrCpy $FinishPhaseEnd 0
1629
StrCpy $InstallResult "cancel"
1630
StrCpy $LaunchedNewApp false
1631
1632
StrCpy $PageName ""
1633
StrCpy $LANGUAGE 0
1634
${SetBrandNameVars} "$EXEDIR\core\distribution\setup.ini"
1635
1636
; Don't install on systems that don't support SSE2. The parameter value of
1637
; 10 is for PF_XMMI64_INSTRUCTIONS_AVAILABLE which will check whether the
1638
; SSE2 instruction set is available. Result returned in $R7.
1639
System::Call "kernel32::IsProcessorFeaturePresent(i 10)i .R7"
1640
1641
; Windows NT 6.0 (Vista/Server 2008) and lower are not supported.
1642
${Unless} ${AtLeastWin7}
1643
${If} "$R7" == "0"
1644
strCpy $R7 "$(WARN_MIN_SUPPORTED_OSVER_CPU_MSG)"
1645
${Else}
1646
strCpy $R7 "$(WARN_MIN_SUPPORTED_OSVER_MSG)"
1647
${EndIf}
1648
MessageBox MB_OKCANCEL|MB_ICONSTOP "$R7" IDCANCEL +2
1649
ExecShell "open" "${URLSystemRequirements}"
1650
Quit
1651
${EndUnless}
1652
1653
; SSE2 CPU support
1654
${If} "$R7" == "0"
1655
MessageBox MB_OKCANCEL|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_CPU_MSG)" IDCANCEL +2
1656
ExecShell "open" "${URLSystemRequirements}"
1657
Quit
1658
${EndIf}
1659
1660
!ifdef HAVE_64BIT_BUILD
1661
${If} "${ARCH}" == "AArch64"
1662
${IfNot} ${IsNativeARM64}
1663
${OrIfNot} ${AtLeastWin10}
1664
MessageBox MB_OKCANCEL|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OSVER_MSG)" IDCANCEL +2
1665
ExecShell "open" "${URLSystemRequirements}"
1666
Quit
1667
${EndIf}
1668
${ElseIfNot} ${RunningX64}
1669
MessageBox MB_OKCANCEL|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_OSVER_MSG)" IDCANCEL +2
1670
ExecShell "open" "${URLSystemRequirements}"
1671
Quit
1672
${EndIf}
1673
SetRegView 64
1674
!endif
1675
1676
SetShellVarContext all
1677
${GetFirstInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $0
1678
${If} "$0" == "false"
1679
SetShellVarContext current
1680
${GetFirstInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $0
1681
${If} "$0" == "false"
1682
StrCpy $HadOldInstall false
1683
${Else}
1684
StrCpy $HadOldInstall true
1685
${EndIf}
1686
${Else}
1687
StrCpy $HadOldInstall true
1688
${EndIf}
1689
1690
${InstallOnInitCommon} "$(WARN_MIN_SUPPORTED_OSVER_CPU_MSG)"
1691
1692
!insertmacro InitInstallOptionsFile "options.ini"
1693
!insertmacro InitInstallOptionsFile "shortcuts.ini"
1694
!insertmacro InitInstallOptionsFile "components.ini"
1695
!insertmacro InitInstallOptionsFile "extensions.ini"
1696
!insertmacro InitInstallOptionsFile "summary.ini"
1697
1698
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
1699
1700
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type "label"
1701
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text "$(OPTIONS_SUMMARY)"
1702
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Left "0"
1703
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Right "-1"
1704
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Top "0"
1705
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Bottom "10"
1706
1707
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Type "RadioButton"
1708
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Text "$(OPTION_STANDARD_RADIO)"
1709
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Left "0"
1710
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Right "-1"
1711
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Top "25"
1712
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Bottom "35"
1713
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" State "1"
1714
WriteINIStr "$PLUGINSDIR\options.ini" "Field 2" Flags "GROUP"
1715
1716
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Type "RadioButton"
1717
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Text "$(OPTION_CUSTOM_RADIO)"
1718
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Left "0"
1719
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Right "-1"
1720
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Top "55"
1721
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" Bottom "65"
1722
WriteINIStr "$PLUGINSDIR\options.ini" "Field 3" State "0"
1723
1724
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Type "label"
1725
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Text "$(OPTION_STANDARD_DESC)"
1726
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Left "15"
1727
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Right "-1"
1728
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Top "37"
1729
WriteINIStr "$PLUGINSDIR\options.ini" "Field 4" Bottom "57"
1730
1731
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Type "label"
1732
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Text "$(OPTION_CUSTOM_DESC)"
1733
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Left "15"
1734
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Right "-1"
1735
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top "67"
1736
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
1737
1738
; Setup the shortcuts.ini file for the Custom Shortcuts Page
1739
; Don't offer to install the quick launch shortcut on Windows 7
1740
${If} ${AtLeastWin7}
1741
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "3"
1742
${Else}
1743
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "4"
1744
${EndIf}
1745
1746
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Type "label"
1747
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Text "$(CREATE_ICONS_DESC)"
1748
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Left "0"
1749
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Right "-1"
1750
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Top "5"
1751
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 1" Bottom "15"
1752
1753
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Type "checkbox"
1754
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Text "$(ICONS_DESKTOP)"
1755
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Left "0"
1756
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Right "-1"
1757
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Top "20"
1758
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Bottom "30"
1759
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" State "1"
1760
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 2" Flags "GROUP"
1761
1762
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Type "checkbox"
1763
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Text "$(ICONS_STARTMENU)"
1764
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Left "0"
1765
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Right "-1"
1766
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Top "40"
1767
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" Bottom "50"
1768
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 3" State "1"
1769
1770
; Don't offer to install the quick launch shortcut on Windows 7
1771
${Unless} ${AtLeastWin7}
1772
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Type "checkbox"
1773
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Text "$(ICONS_QUICKLAUNCH)"
1774
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Left "0"
1775
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Right "-1"
1776
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Top "60"
1777
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" Bottom "70"
1778
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Field 4" State "1"
1779
${EndUnless}
1780
1781
; Setup the components.ini file for the Components Page
1782
WriteINIStr "$PLUGINSDIR\components.ini" "Settings" NumFields "2"
1783
1784
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Type "label"
1785
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Text "$(OPTIONAL_COMPONENTS_DESC)"
1786
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Left "0"
1787
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Right "-1"
1788
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Top "5"
1789
WriteINIStr "$PLUGINSDIR\components.ini" "Field 1" Bottom "25"
1790
1791
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Type "checkbox"
1792
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Text "$(MAINTENANCE_SERVICE_CHECKBOX_DESC)"
1793
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Left "0"
1794
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Right "-1"
1795
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Top "27"
1796
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Bottom "37"
1797
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" State "1"
1798
WriteINIStr "$PLUGINSDIR\components.ini" "Field 2" Flags "GROUP"
1799
1800
; Setup the extensions.ini file for the Custom Extensions Page
1801
StrCpy $R9 0
1802
StrCpy $R8 ${BST_CHECKED}
1803
1804
${If} ${FileExists} "$EXEDIR\core\distribution\setup.ini"
1805
${Do}
1806
IntOp $R7 $R9 + 2
1807
1808
ClearErrors
1809
ReadINIStr $R6 "$EXEDIR\core\distribution\setup.ini" \
1810
"OptionalExtensions" "extension.$R9.name.${AB_CD}"
1811
${If} ${Errors}
1812
ClearErrors
1813
ReadINIStr $R6 "$EXEDIR\core\distribution\setup.ini" \
1814
"OptionalExtensions" "extension.$R9.name"
1815
${EndIf}
1816
1817
${If} ${Errors}
1818
${ExitDo}
1819
${EndIf}
1820
1821
; Each row moves down by 13 DLUs
1822
IntOp $R2 $R9 * 13
1823
IntOp $R2 $R2 + 21
1824
IntOp $R1 $R2 + 10
1825
1826
ClearErrors
1827
ReadINIStr $R0 "$EXEDIR\core\distribution\setup.ini" \
1828
"OptionalExtensions" "extension.$R9.checked"
1829
${If} ${Errors}
1830
StrCpy $R0 ${BST_CHECKED}
1831
${ElseIf} $R0 == "0"
1832
StrCpy $R8 ${BST_UNCHECKED}
1833
${EndIf}
1834
1835
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Type "checkbox"
1836
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Text "$R6"
1837
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Left "11"
1838
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Right "-1"
1839
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Top "$R2"
1840
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Bottom "$R1"
1841
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" State "$R0"
1842
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R7" Flags "NOTIFY"
1843
1844
IntOp $R9 $R9 + 1
1845
${Loop}
1846
${EndIf}
1847
1848
IntOp $R9 $R9 + 2
1849
1850
WriteINIStr "$PLUGINSDIR\extensions.ini" "Settings" NumFields "$R9"
1851
1852
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Type "checkbox"
1853
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Text "$(OPTIONAL_EXTENSIONS_CHECKBOX_DESC)"
1854
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Left "0"
1855
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Right "-1"
1856
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Top "5"
1857
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Bottom "15"
1858
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" State "$R8"
1859
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field 1" Flags "GROUP|NOTIFY"
1860
1861
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Type "label"
1862
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Text "$(OPTIONAL_EXTENSIONS_DESC)"
1863
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Left "0"
1864
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Right "-1"
1865
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Top "-23"
1866
WriteINIStr "$PLUGINSDIR\extensions.ini" "Field $R9" Bottom "-5"
1867
1868
; There must always be a core directory.
1869
${GetSize} "$EXEDIR\core\" "/S=0K" $R5 $R7 $R8
1870
SectionSetSize ${APP_IDX} $R5
1871
1872
; Initialize $hHeaderBitmap to prevent redundant changing of the bitmap if
1873
; the user clicks the back button
1874
StrCpy $hHeaderBitmap ""
1875
FunctionEnd
1876
1877
Function .onGUIEnd
1878
${OnEndCommon}
1879
Call SendPing
1880
FunctionEnd