Bug 447928 - HKCU protocol / file handlers won't be updated after update or during an in place upgrade. r=jmathies
authorRobert Strong <robert.bugzilla@gmail.com>
Sun, 27 Jul 2008 18:58:27 -0700
changeset 16263 59ed47fea07dc84aa34e3991f063a530b86e2edc
parent 16262 45f11b174072544afb04d47ce256704e439116e8
child 16264 1f9c368b25e4d042efe248dc32e7d92d0da9f300
push idunknown
push userunknown
push dateunknown
reviewersjmathies
bugs447928
milestone1.9.1a2pre
Bug 447928 - HKCU protocol / file handlers won't be updated after update or during an in place upgrade. r=jmathies
browser/installer/windows/nsis/installer.nsi
browser/installer/windows/nsis/shared.nsh
toolkit/mozapps/installer/windows/nsis/common.nsh
--- a/browser/installer/windows/nsis/installer.nsi
+++ b/browser/installer/windows/nsis/installer.nsi
@@ -344,27 +344,29 @@ Section "-Application" APP_IDX
   ${If} $AddDesktopSC == ""
     StrCpy $AddDesktopSC "1"
   ${EndIf}
 
   ${LogHeader} "Adding Registry Entries"
   SetShellVarContext current  ; Set SHCTX to HKCU
   ${RegCleanMain} "Software\Mozilla"
   ${RegCleanUninstall}
+  ${UpdateProtocolHandlers}
 
   ClearErrors
   WriteRegStr HKLM "Software\Mozilla\InstallerTest" "InstallerTest" "Test"
   ${If} ${Errors}
     StrCpy $TmpVal "HKCU" ; used primarily for logging
   ${Else}
     SetShellVarContext all  ; Set SHCTX to HKLM
     DeleteRegKey HKLM "Software\Mozilla\InstallerTest"
     StrCpy $TmpVal "HKLM" ; used primarily for logging
     ${RegCleanMain} "Software\Mozilla"
     ${RegCleanUninstall}
+    ${UpdateProtocolHandlers}
 
     ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
     ${If} "$0" != "${GREVersion}"
       WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
     ${EndIf}
   ${EndIf}
 
   ${RemoveDeprecatedKeys}
@@ -380,17 +382,16 @@ Section "-Application" APP_IDX
   ${SetAppKeys}
 
   ; XXXrstrong - this should be set in shared.nsh along with "Create Quick
   ; Launch Shortcut" and Create Desktop Shortcut.
   StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Uninstall"
   ${WriteRegDWORD2} $TmpVal "$0" "Create Start Menu Shortcut" $AddStartMenuSC 0
 
   ${FixClassKeys}
-  ${UpdateProtocolHandlers}
 
   ; On install always add the FirefoxHTML and FirefoxURL keys.
   ; An empty string is used for the 5th param because FirefoxHTML is not a
   ; protocol handler.
   ${AddDDEHandlerValues} "FirefoxHTML" "$2" "$8,1" "${AppRegName} Document" "" \
                          "${DDEApplication}" "$3" "WWW_OpenURL"
 
   ${AddDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" "true" \
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -36,43 +36,44 @@
 
 !macro PostUpdate
   ; Remove registry entries for non-existent apps and for apps that point to our
   ; install location in the Software\Mozilla key and uninstall registry entries
   ; that point to our install location for both HKCU and HKLM.
   SetShellVarContext current  ; Set SHCTX to the current user (e.g. HKCU)
   ${RegCleanMain} "Software\Mozilla"
   ${RegCleanUninstall}
+  ${UpdateProtocolHandlers}
 
   ClearErrors
   WriteRegStr HKLM "Software\Mozilla\InstallerTest" "InstallerTest" "Test"
   ${If} ${Errors}
     StrCpy $TmpVal "HKCU" ; used primarily for logging
   ${Else}
     SetShellVarContext all    ; Set SHCTX to all users (e.g. HKLM)
     DeleteRegKey HKLM "Software\Mozilla\InstallerTest"
     StrCpy $TmpVal "HKLM" ; used primarily for logging
     ${RegCleanMain} "Software\Mozilla"
     ${RegCleanUninstall}
     ${SetStartMenuInternet}
     ${FixShellIconHandler}
     ${SetUninstallKeys}
+    ${UpdateProtocolHandlers}
 
     ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
     ${If} "$0" != "${GREVersion}"
       WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
     ${EndIf}
   ${EndIf}
 
   ${RemoveDeprecatedKeys}
 
   ; Add Software\Mozilla\ registry entries
   ${SetAppKeys}
   ${FixClassKeys}
-  ${UpdateProtocolHandlers}
 
   ; Remove files that may be left behind by the application in the
   ; VirtualStore directory.
   ${CleanVirtualStore}
 
   ; Remove talkback if it is present (remove after bug 386760 is fixed)
   ${If} ${FileExists} "$INSTDIR\extensions\talkback@mozilla.org\"
     RmDir /r "$INSTDIR\extensions\talkback@mozilla.org\"
@@ -103,27 +104,25 @@
 
   ${SetStartMenuInternet}
 
   setdefaultuser:
   SetShellVarContext all  ; Set SHCTX to all users (e.g. HKLM)
   ${FixShellIconHandler}
   WriteRegStr HKCU "Software\Clients\StartMenuInternet" "" "$R9"
 
-!ifdef ___WINVER__NSH___
   ${If} ${AtLeastWinVista}
     ClearErrors
     ReadRegStr $0 HKLM "Software\RegisteredApplications" "${AppRegName}"
     ; Only register as the handler on Vista if the app registry name exists
     ; under the RegisteredApplications registry key.
     ${Unless} ${Errors}
       AppAssocReg::SetAppAsDefaultAll "${AppRegName}"
     ${EndUnless}
   ${EndIf}
-!endif
 
   ${RemoveDeprecatedKeys}
 
   SetShellVarContext current  ; Set SHCTX to the current user (e.g. HKCU)
   ${SetHandlers}
 !macroend
 !define SetAsDefaultAppUser "!insertmacro SetAsDefaultAppUser"
 
@@ -152,34 +151,34 @@
   SetShellVarContext all  ; Set $DESKTOP to All Users
   ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
     SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
   ${EndUnless}
 
   ${If} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
     ShellLink::GetShortCutArgs "$DESKTOP\${BrandFullName}.lnk"
     Pop $0
-    ${If} $0 == ""
+    ${If} "$0" == ""
       ShellLink::GetShortCutTarget "$DESKTOP\${BrandFullName}.lnk"
       Pop $0
       ; Needs to handle short paths
-      ${If} $0 == "$INSTDIR\${FileMainEXE}"
+      ${If} "$0" == "$INSTDIR\${FileMainEXE}"
         Delete "$DESKTOP\${BrandFullName}.lnk"
       ${EndIf}
     ${EndIf}
   ${EndIf}
 
   ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
     ShellLink::GetShortCutArgs "$QUICKLAUNCH\${BrandFullName}.lnk"
     Pop $0
-    ${If} $0 == ""
+    ${If} "$0" == ""
       ShellLink::GetShortCutTarget "$QUICKLAUNCH\${BrandFullName}.lnk"
       Pop $0
       ; Needs to handle short paths
-      ${If} $0 == "$INSTDIR\${FileMainEXE}"
+      ${If} "$0" == "$INSTDIR\${FileMainEXE}"
         Delete "$QUICKLAUNCH\${BrandFullName}.lnk"
       ${EndIf}
     ${EndIf}
   ${EndIf}
 !macroend
 !define HideShortcuts "!insertmacro HideShortcuts"
 
 !macro ShowShortcuts
@@ -222,17 +221,17 @@
     WriteRegStr SHCTX "$0\.html"  "" "FirefoxHTML"
   ${EndIf}
 
   ReadRegStr $6 HKCR ".shtml" ""
   ${If} "$6" != "FirefoxHTML"
     WriteRegStr SHCTX "$0\.shtml" "" "FirefoxHTML"
   ${EndIf}
 
-  ReadRegStr $6 HKCR ".hht" ""
+  ReadRegStr $6 HKCR ".xht" ""
   ${If} "$6" != "FirefoxHTML"
     WriteRegStr SHCTX "$0\.xht"   "" "FirefoxHTML"
   ${EndIf}
 
   ReadRegStr $6 HKCR ".xhtml" ""
   ${If} "$6" != "FirefoxHTML"
     WriteRegStr SHCTX "$0\.xhtml" "" "FirefoxHTML"
   ${EndIf}
@@ -357,44 +356,44 @@
   SetShellVarContext all  ; Set $DESKTOP to All Users
   ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
     SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
   ${EndUnless}
 
   ${If} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
     ShellLink::GetShortCutArgs "$DESKTOP\${BrandFullName}.lnk"
     Pop $1
-    ${If} $1 == ""
+    ${If} "$1" == ""
       ShellLink::GetShortCutTarget "$DESKTOP\${BrandFullName}.lnk"
       Pop $1
       ${GetLongPath} "$1" $1
       ${If} "$1" == "$8\${FileMainEXE}"
         ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" 1 0
       ${Else}
         ${WriteRegDWORD2} $TmpVal "$0" "Create Desktop Shortcut" 0 0
       ${EndIf}
     ${EndIf}
   ${EndIf}
 
   ; XXXrstrong - need a cleaner way to prevent unsetting SHCTX from HKLM when
   ; trying to find the desktop shortcut.
-  ${If} $TmpVal == "HKCU"
+  ${If} "$TmpVal" == "HKCU"
     SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
   ${Else}
     SetShellVarContext all     ; Set SHCTX to all users (e.g. HKLM)
   ${EndIf}
 
   ${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
     ShellLink::GetShortCutArgs "$QUICKLAUNCH\${BrandFullName}.lnk"
     Pop $1
-    ${If} $1 == ""
+    ${If} "$1" == ""
       ShellLink::GetShortCutTarget "$QUICKLAUNCH\${BrandFullName}.lnk"
       Pop $1
       ${GetLongPath} "$1" $1
-      ${If} $1 == "$8\${FileMainEXE}"
+      ${If} "$1" == "$8\${FileMainEXE}"
         ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" 1 0
       ${Else}
         ${WriteRegDWORD2} $TmpVal "$0" "Create Quick Launch Shortcut" 0 0
       ${EndIf}
     ${EndIf}
   ${EndIf}
   ; XXXrstrong - "Create Start Menu Shortcut" and "Start Menu Folder" are only
   ; set in the installer and should also be set here for software update.
@@ -539,17 +538,17 @@
   ReadRegStr $2 HKLM "$0\Capabilities\URLAssociations" "gopher"
   ${Unless} ${Errors}
     DeleteRegValue HKLM "$0\Capabilities\URLAssociations" "gopher"
   ${EndUnless}
 
   ; Delete gopher from the user's UrlAssociations if it points to FirefoxURL.
   StrCpy $0 "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\gopher"
   ReadRegStr $2 HKCU "$0\UserChoice" "Progid"
-  ${If} $2 == "FirefoxURL"
+  ${If} "$2" == "FirefoxURL"
     DeleteRegKey HKCU "$0"
   ${EndIf}
 !macroend
 !define RemoveDeprecatedKeys "!insertmacro RemoveDeprecatedKeys"
 
 ; The files to check if they are in use during (un)install so the restart is
 ; required message is displayed. All files must be located in the $INSTDIR
 ; directory.
--- a/toolkit/mozapps/installer/windows/nsis/common.nsh
+++ b/toolkit/mozapps/installer/windows/nsis/common.nsh
@@ -3088,16 +3088,17 @@
     !undef _MOZFUNC_UN
     !define _MOZFUNC_UN
     !verbose pop
   !endif
 !macroend
 
 /**
  * Checks if a handler's open command points to this installation directory.
+ * Uses SHCTX to determine the registry hive (e.g. HKLM or HKCU) to check.
  *
  * @param   _HANDLER_NAME
  *          The registry name for the handler.
  * @param   _RESULT
  *          true if it is the handler's open command points to this
  *          installation directory and false if it does not.
  *
  * $R7 = stores the value of the open command and the path macros return values
@@ -3121,17 +3122,17 @@
 
     Function ${_MOZFUNC_UN}IsHandlerForInstallDir
       Exch $R9
       Push $R8
       Push $R7
 
       StrCpy $R8 "$R9"
       StrCpy $R9 "false"
-      ReadRegStr $R7 HKCR "$R8\shell\open\command" ""
+      ReadRegStr $R7 SHCTX "Software\Classes\$R8\shell\open\command" ""
       StrCmp "$R7" "" end
 
       ${GetPathFromString} "$R7" $R7
       ${GetParent} "$R7" $R7
       ${GetLongPath} "$R7" $R7
       StrCmp "$R7" "$INSTDIR" +1 end
       StrCpy $R9 "true"