Bug 1049521 - Only register for types when there is no default in either of HKLM or HKCU. r=rstrong
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -391,16 +391,25 @@ FunctionEnd
${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \
"$INSTDIR"
${EndIf}
${EndUnless}
!macroend
!define ShowShortcuts "!insertmacro ShowShortcuts"
+!macro AddAssociationIfNoneExist FILE_TYPE
+ ClearErrors
+ EnumRegKey $7 HKCR "${FILE_TYPE}" 0
+ ${If} ${Errors}
+ WriteRegStr SHCTX "SOFTWARE\Classes\${FILE_TYPE}" "" "FirefoxHTML"
+ ${EndIf}
+!macroend
+!define AddAssociationIfNoneExist "!insertmacro AddAssociationIfNoneExist"
+
; Adds the protocol and file handler registry entries for making Firefox the
; default handler (uses SHCTX).
!macro SetHandlers
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
StrCpy $0 "SOFTWARE\Classes"
StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
@@ -425,45 +434,22 @@ FunctionEnd
WriteRegStr SHCTX "$0\.xht" "" "FirefoxHTML"
${EndIf}
ReadRegStr $6 SHCTX "$0\.xhtml" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.xhtml" "" "FirefoxHTML"
${EndIf}
- ; Only add .oga if it's not present
- ${CheckIfRegistryKeyExists} "$0" ".oga" $7
- ${If} $7 == "false"
- WriteRegStr SHCTX "$0\.oga" "" "FirefoxHTML"
- ${EndIf}
-
- ; Only add .ogg if it's not present
- ${CheckIfRegistryKeyExists} "$0" ".ogg" $7
- ${If} $7 == "false"
- WriteRegStr SHCTX "$0\.ogg" "" "FirefoxHTML"
- ${EndIf}
-
- ; Only add .ogv if it's not present
- ${CheckIfRegistryKeyExists} "$0" ".ogv" $7
- ${If} $7 == "false"
- WriteRegStr SHCTX "$0\.ogv" "" "FirefoxHTML"
- ${EndIf}
-
- ; Only add .pdf if it's not present
- ${CheckIfRegistryKeyExists} "$0" ".pdf" $7
- ${If} $7 == "false"
- WriteRegStr SHCTX "$0\.pdf" "" "FirefoxHTML"
- ${EndIf}
-
- ; Only add webm if it's not present
- ${CheckIfRegistryKeyExists} "$0" ".webm" $7
- ${If} $7 == "false"
- WriteRegStr SHCTX "$0\.webm" "" "FirefoxHTML"
- ${EndIf}
+ ${AddAssociationIfNoneExist} ".pdf"
+ ${AddAssociationIfNoneExist} ".oga"
+ ${AddAssociationIfNoneExist} ".ogg"
+ ${AddAssociationIfNoneExist} ".ogv"
+ ${AddAssociationIfNoneExist} ".pdf"
+ ${AddAssociationIfNoneExist} ".webm"
; An empty string is used for the 5th param because FirefoxHTML is not a
; protocol handler
${AddDisabledDDEHandlerValues} "FirefoxHTML" "$2" "$8,1" \
"${AppRegName} HTML Document" ""
${AddDisabledDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" \
"true"