Windows stub installer only - Bug 848794 - Can't re-run Firefox stub installer after cancelling Install. r=bbondy, a=akeybl
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 08 Mar 2013 14:02:14 -0800
changeset 132324 327b2727c8fc7884c01b4370c200db49460b0403
parent 132323 688c4dd5262e9f42aa08effde2ccf4c0398319c8
child 132325 94b026146a99620e39ac38b6640d9366b7c6cdc1
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy, akeybl
bugs848794
milestone21.0a2
Windows stub installer only - Bug 848794 - Can't re-run Firefox stub installer after cancelling Install. r=bbondy, a=akeybl
browser/installer/windows/nsis/stub.nsi
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -435,42 +435,36 @@ Function .onGUIInit
   ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LAYOUTRTL}
   ${RemoveExStyle} $HWNDPARENT ${WS_EX_RTLREADING}
   ${RemoveExStyle} $HWNDPARENT ${WS_EX_RIGHT}
   ${NSD_AddExStyle} $HWNDPARENT ${WS_EX_LEFT}|${WS_EX_LTRREADING}
 FunctionEnd
 !endif
 
 Function .onGUIEnd
+  Delete "$PLUGINSDIR\_temp"
+  Delete "$PLUGINSDIR\download.exe"
+  Delete "$PLUGINSDIR\${CONFIG_INI}"
+
   ${UnloadUAC}
 FunctionEnd
 
 Function .onUserAbort
   ${NSD_KillTimer} StartDownload
   ${NSD_KillTimer} OnDownload
   ${NSD_KillTimer} StartInstall
   ${NSD_KillTimer} CheckInstall
   ${NSD_KillTimer} FinishInstall
   ${NSD_KillTimer} DisplayDownloadError
 
-  Delete "$PLUGINSDIR\_temp"
-  Delete "$PLUGINSDIR\download.exe"
-  Delete "$PLUGINSDIR\${CONFIG_INI}"
-  ${If} "$IsDownloadFinished" == ""
-  ${OrIf} $CheckboxSendPing != 1
-    ; When not sending a ping cancel the download if it is in progress and exit
-    ; the installer.
-    ${If} "$IsDownloadFinished" == "false"
-      HideWindow
-      InetBgDL::Get /RESET /END
-    ${EndIf}
-  ${Else}
-    Call SendPing
-    ; Aborting the abort will allow SendPing to hide the installer window and
-    ; close the installer after it sends the metrics ping.
+  ${If} "$IsDownloadFinished" != ""
+    Call DisplayDownloadError
+    ; Aborting the abort will allow SendPing which is called by
+    ; DisplayDownloadError to hide the installer window and close the installer
+    ; after it sends the metrics ping.
     Abort 
   ${EndIf}
 FunctionEnd
 
 Function SendPing
   HideWindow
   ; Try to send a ping if a download was attempted
   ${If} $CheckboxSendPing == 1
@@ -479,34 +473,35 @@ Function SendPing
     System::Call "kernel32::GetTickCount()l .s"
     Pop $EndFinishPhaseTickCount
 
     ; When the value of $IsDownloadFinished is false the download was started
     ; but didn't finish. In this case the tick count stored in
     ; $EndFinishPhaseTickCount is used to determine how long the download was
     ; in progress.
     ${If} "$IsDownloadFinished" == "false"
+    ${OrIf} "$EndDownloadPhaseTickCount" == ""
       StrCpy $EndDownloadPhaseTickCount "$EndFinishPhaseTickCount"
       ; Cancel the download in progress
       InetBgDL::Get /RESET /END
     ${EndIf}
 
 
     ; When $DownloadFirstTransferSeconds equals an empty string the download
     ; never successfully started so set the value to 0. It will be possible to
     ; determine that the download didn't successfully start from the seconds for
     ; the last download.
     ${If} "$DownloadFirstTransferSeconds" == ""
       StrCpy $DownloadFirstTransferSeconds "0"
     ${EndIf}
 
-    ; When $StartLastDownloadTickCount equals 0 the download never successfully
-    ; started so set the value to $EndDownloadPhaseTickCount to compute the
-    ; correct value.
-    ${If} $StartLastDownloadTickCount == "0"
+    ; When $StartLastDownloadTickCount equals an empty string the download never
+    ; successfully started so set the value to $EndDownloadPhaseTickCount to
+    ; compute the correct value.
+    ${If} $StartLastDownloadTickCount == ""
       ; This could happen if the download never successfully starts
       StrCpy $StartLastDownloadTickCount "$EndDownloadPhaseTickCount"
     ${EndIf}
 
     ; When $EndPreInstallPhaseTickCount equals 0 the installation phase was
     ; never completed so set its value to $EndFinishPhaseTickCount to compute
     ; the correct value.
     ${If} "$EndPreInstallPhaseTickCount" == "0"
@@ -600,41 +595,51 @@ Function SendPing
                       $\nBuild = $R4 \
                       $\nExit Code = $ExitCode \
                       $\nFirefox Launch Code = $FirefoxLaunchCode \
                       $\nDownload Retry Count = $DownloadRetryCount \
                       $\nDownloaded Bytes = $DownloadedBytes \
                       $\nIntroduction Phase Seconds = $IntroPhaseSeconds \
                       $\nOptions Phase Seconds = $OptionsPhaseSeconds \
                       $\nDownload Phase Seconds = $0 \
+                      $\nLast Download Seconds = $1 \
                       $\nDownload First Transfer Seconds = $DownloadFirstTransferSeconds \
-                      $\nLast Download Seconds = $1 \
                       $\nPreinstall Phase Seconds = $2 \
                       $\nInstall Phase Seconds = $3 \
                       $\nFinish Phase Seconds = $4 \
                       $\nIntro Page Shown Count = $IntroPageShownCount \
                       $\nOptions Page Shown Count = $OptionsPageShownCount \
                       $\nInitial Install Requirements Code = $InitialInstallRequirementsCode \
                       $\nOpened Download Page = $OpenedDownloadPage \
                       $\nExisting Profile = $ExistingProfile \
                       $\nExisting Version = $ExistingVersion \
                       $\nExisting Build ID = $ExistingBuildID \
                       $\nNew Version = $R5 \
                       $\nNew Build ID = $R6 \
                       $\nDefault Install Dir = $R7 \
                       $\nHas Admin = $R8 \
                       $\nDownload Server IP = $DownloadServerIP"
+    ; The following will exit the installer
+    SetAutoClose true
+    StrCpy $R9 "2"
+    Call RelativeGotoPage
 !else
     ${NSD_CreateTimer} OnPing ${DownloadIntervalMS}
     InetBgDL::Get "${BaseURLStubPing}/${StubURLVersion}/${Channel}/${UpdateChannel}/${AB_CD}/$R0/$R1/$R2/$R3/$R4/$ExitCode/$FirefoxLaunchCode/$DownloadRetryCount/$DownloadedBytes/$IntroPhaseSeconds/$OptionsPhaseSeconds/$0/$1/$DownloadFirstTransferSeconds/$2/$3/$4/$IntroPageShownCount/$OptionsPageShownCount/$InitialInstallRequirementsCode/$OpenedDownloadPage/$ExistingProfile/$ExistingVersion/$ExistingBuildID/$R5/$R6/$R7/$R8/$DownloadServerIP" \
                   "$PLUGINSDIR\_temp" /END
 !endif
-  ${ElseIf} "$IsDownloadFinished" == "false"
-    ; Cancel the download in progress
-    InetBgDL::Get /RESET /END
+  ${Else}
+    ${If} "$IsDownloadFinished" == "false"
+      ; Cancel the download in progress
+      InetBgDL::Get /RESET /END
+    ${EndIf}
+    ; The following will exit the installer
+    SetAutoClose true
+    StrCpy $R9 "2"
+    Call RelativeGotoPage
   ${EndIf}
 FunctionEnd
 
 Function createDummy
 FunctionEnd
 
 Function createIntro
   ; If Back is clicked on the options page reset variables
@@ -1172,17 +1177,19 @@ Function createInstall
   SendMessage $0 ${WM_SETFONT} $FontNormal 0
   SetCtlColors $0 ${FOOTER_CONTROL_TEXT_COLOR_FADED} ${FOOTER_BKGRD_COLOR}
   ShowWindow $0 ${SW_SHOW}
 
   ; Set $DownloadReset to true so the first download tick count is measured.
   StrCpy $DownloadReset "true"
   StrCpy $IsDownloadFinished "false"
   StrCpy $DownloadRetryCount "0"
-  StrCpy $StartLastDownloadTickCount "0"
+  StrCpy $DownloadedBytes "0"
+  StrCpy $StartLastDownloadTickCount ""
+  StrCpy $EndDownloadPhaseTickCount ""
   StrCpy $DownloadFirstTransferSeconds ""
   StrCpy $ExitCode "${ERR_DOWNLOAD_CANCEL}"
   StrCpy $OpenedDownloadPage "0"
 
   ClearErrors
   ReadINIStr $ExistingVersion "$INSTDIR\application.ini" "App" "Version"
   ${If} ${Errors}
     StrCpy $ExistingVersion "0"