Bug 1049521 - Only register for types when there is no default in either of HKLM or HKCU. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Sat, 27 Sep 2014 21:35:06 -0400
changeset 223029 d574ca46990d846f71d99c6e4dbcc5bcf85720c0
parent 223028 76ab08438176ea4457544ce6bf92f4ec002fe0d9
child 223030 403c448fcd4d355c5a11ffb42f38d36811b4bc1f
push id7107
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 17:43:31 +0000
treeherdermozilla-aurora@b4b34e0acc75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs1049521
milestone35.0a1
Bug 1049521 - Only register for types when there is no default in either of HKLM or HKCU. r=rstrong
browser/installer/windows/nsis/shared.nsh
--- 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"