Bug 1279240 - save old default browser when setting as default on win7 and below from the installer, r=rstrong
☠☠ backed out by 016bf0339326 ☠ ☠
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 27 Sep 2016 11:41:24 +0100
changeset 315783 dc1b725b47d42a888c3cf88afbf0b73c6b291838
parent 315782 b9b87a4102da1a9857a89cfbc859a6bf23bfe0e5
child 315784 d0d5180dc062bda67da867ed501ea9e3d23af8e3
push id20634
push usercbook@mozilla.com
push dateFri, 30 Sep 2016 10:10:13 +0000
treeherderfx-team@afe79b010d13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1279240
milestone52.0a1
Bug 1279240 - save old default browser when setting as default on win7 and below from the installer, r=rstrong MozReview-Commit-ID: CmMI8bztpaL
browser/installer/windows/nsis/installer.nsi
browser/installer/windows/nsis/stub.nsi
--- a/browser/installer/windows/nsis/installer.nsi
+++ b/browser/installer/windows/nsis/installer.nsi
@@ -591,31 +591,58 @@ SectionEnd
 Section "-InstallEndCleanup"
   SetDetailsPrint both
   DetailPrint "$(STATUS_CLEANUP)"
   SetDetailsPrint none
 
   ${Unless} ${Silent}
     ${MUI_INSTALLOPTIONS_READ} $0 "summary.ini" "Field 4" "State"
     ${If} "$0" == "1"
+      ; NB: this code is duplicated in stub.nsi. Please keep in sync.
+      ; For data migration in the app, we want to know what the default browser
+      ; value was before we changed it. To do so, we read it here and store it
+      ; in our own registry key.
+      StrCpy $0 ""
+      ${If} ${AtLeastWinVista}
+        AppAssocReg::QueryCurrentDefault "http" "protocol" "effective"
+        Pop $1
+        ; If the method hasn't failed, $1 will contain the progid. Check:
+        ${If} "$1" != "method failed"
+        ${AndIf} "$1" != "method not available"
+          ; Read the actual command from the progid
+          ReadRegStr $0 HKCR "$1\shell\open\command" ""
+        ${EndIf}
+      ${EndIf}
+      ; If using the App Association Registry didn't happen or failed, fall back
+      ; to the effective http default:
+      ${If} "$0" == ""
+        ReadRegStr $0 HKCR "http\shell\open\command" ""
+      ${EndIf}
+      ; If we have something other than empty string now, write the value.
+      ${If} "$0" != ""
+        ClearErrors
+        WriteRegStr HKCU "Software\Mozilla\Firefox" "OldDefaultBrowserCommand" "$0"
+      ${EndIf}
+
       ${LogHeader} "Setting as the default browser"
       ClearErrors
       ${GetParameters} $0
       ${GetOptions} "$0" "/UAC:" $0
       ${If} ${Errors}
         Call SetAsDefaultAppUserHKCU
       ${Else}
         GetFunctionAddress $0 SetAsDefaultAppUserHKCU
         UAC::ExecCodeSegment $0
       ${EndIf}
     ${Else}
       ${LogHeader} "Writing default-browser opt-out"
+      ClearErrors
       WriteRegStr HKCU "Software\Mozilla\Firefox" "DefaultBrowserOptOut" "True"
       ${If} ${Errors}
-        ${LogHeader} "Error writing default-browser opt-out"
+        ${LogMsg} "Error writing default-browser opt-out"
       ${EndIf}
     ${EndIf}
   ${EndUnless}
 
   ; Adds a pinned Task Bar shortcut (see MigrateTaskBarShortcut for details).
   ${MigrateTaskBarShortcut}
 
   ; Add the Firewall entries during install
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -1743,16 +1743,42 @@ Function FinishInstall
   ${EndIf}
 
   ${NSD_KillTimer} FinishInstall
 
   StrCpy $ProgressCompleted "$ProgressTotal"
   Call SetProgressBars
 
   ${If} "$CheckboxSetAsDefault" == "1"
+    ; NB: this code is duplicated in installer.nsi. Please keep in sync.
+    ; For data migration in the app, we want to know what the default browser
+    ; value was before we changed it. To do so, we read it here and store it
+    ; in our own registry key.
+    StrCpy $0 ""
+    ${If} ${AtLeastWinVista}
+      AppAssocReg::QueryCurrentDefault "http" "protocol" "effective"
+      Pop $1
+      ; If the method hasn't failed, $1 will contain the progid. Check:
+      ${If} "$1" != "method failed"
+      ${AndIf} "$1" != "method not available"
+        ; Read the actual command from the progid
+        ReadRegStr $0 HKCR "$1\shell\open\command" ""
+      ${EndIf}
+    ${EndIf}
+    ; If using the App Association Registry didn't happen or failed, fall back
+    ; to the effective http default:
+    ${If} "$0" == ""
+      ReadRegStr $0 HKCR "http\shell\open\command" ""
+    ${EndIf}
+    ; If we have something other than empty string now, write the value.
+    ${If} "$0" != ""
+      ClearErrors
+      WriteRegStr HKCU "Software\Mozilla\Firefox" "OldDefaultBrowserCommand" "$0"
+    ${EndIf}
+
     ${GetParameters} $0
     ClearErrors
     ${GetOptions} "$0" "/UAC:" $0
     ${If} ${Errors} ; Not elevated
       Call ExecSetAsDefaultAppUser
     ${Else} ; Elevated - execute the function in the unelevated process
       GetFunctionAddress $0 ExecSetAsDefaultAppUser
       UAC::ExecCodeSegment $0