Bug 645288 - Register Firefox as a webm capable player on Windows. r=rstrong
authorJim Mathies <jmathies@mozilla.com>
Sun, 10 Apr 2011 16:31:26 -0500
changeset 67803 09b605eb3e0d
parent 67802 6eaee284fdb9
child 67804 4d2da0c23ae2
push id19429
push userjmathies@mozilla.com
push date2011-04-10 21:31 +0000
treeherdermozilla-central@09b605eb3e0d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs645288
milestone2.2a1pre
first release with
nightly linux32
09b605eb3e0d / 4.2a1pre / 20110411030525 / files
nightly linux64
09b605eb3e0d / 4.2a1pre / 20110411030525 / files
nightly mac
09b605eb3e0d / 4.2a1pre / 20110411030525 / files
nightly win32
09b605eb3e0d / 4.2a1pre / 20110411030525 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 645288 - Register Firefox as a webm capable player on Windows. r=rstrong
browser/installer/windows/nsis/installer.nsi
browser/installer/windows/nsis/shared.nsh
browser/installer/windows/nsis/uninstaller.nsi
toolkit/mozapps/installer/windows/nsis/common.nsh
--- a/browser/installer/windows/nsis/installer.nsi
+++ b/browser/installer/windows/nsis/installer.nsi
@@ -118,16 +118,17 @@ VIAddVersionKey "OriginalFilename" "setu
 !insertmacro RegCleanMain
 !insertmacro RegCleanUninstall
 !insertmacro SetAppLSPCategories
 !insertmacro SetBrandNameVars
 !insertmacro UpdateShortcutAppModelIDs
 !insertmacro UnloadUAC
 !insertmacro WriteRegStr2
 !insertmacro WriteRegDWORD2
+!insertmacro CheckIfRegistryKeyExists
 
 !include shared.nsh
 
 ; Helper macros for ui callbacks. Insert these after shared.nsh
 !insertmacro CheckCustomCommon
 !insertmacro InstallEndCleanupCommon
 !insertmacro InstallOnInitCommon
 !insertmacro InstallStartCleanupCommon
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -274,16 +274,22 @@
     WriteRegStr SHCTX "$0\.xht"   "" "FirefoxHTML"
   ${EndIf}
 
   ReadRegStr $6 SHCTX "$0\.xhtml" ""
   ${If} "$6" != "FirefoxHTML"
     WriteRegStr SHCTX "$0\.xhtml" "" "FirefoxHTML"
   ${EndIf}
 
+  ; Only add webm if it's not present
+  ${CheckIfRegistryKeyExists} "$0" ".webm" $7
+  ${If} $7 == "false"
+    WriteRegStr SHCTX "$0\.webm"  "" "FirefoxHTML"
+  ${EndIf}
+
   StrCpy $3 "$\"%1$\",,0,0,,,,"
 
   ; 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/uninstaller.nsi
+++ b/browser/installer/windows/nsis/uninstaller.nsi
@@ -102,16 +102,17 @@ VIAddVersionKey "OriginalFilename" "help
 !insertmacro RegCleanMain
 !insertmacro RegCleanUninstall
 !insertmacro SetAppLSPCategories
 !insertmacro SetBrandNameVars
 !insertmacro UpdateShortcutAppModelIDs
 !insertmacro UnloadUAC
 !insertmacro WriteRegDWORD2
 !insertmacro WriteRegStr2
+!insertmacro CheckIfRegistryKeyExists
 
 !insertmacro un.ChangeMUIHeaderImage
 !insertmacro un.CheckForFilesInUse
 !insertmacro un.CleanUpdatesDir
 !insertmacro un.CleanVirtualStore
 !insertmacro un.DeleteRelativeProfiles
 !insertmacro un.DeleteShortcuts
 !insertmacro un.GetLongPath
@@ -261,16 +262,17 @@ Section "Uninstall"
   ; Don't clean up the file handlers if the FirefoxHTML key still exists since
   ; there should be a second installation that may be the default file handler
   ${If} ${Errors}
     ${un.RegCleanFileHandler}  ".htm"   "FirefoxHTML"
     ${un.RegCleanFileHandler}  ".html"  "FirefoxHTML"
     ${un.RegCleanFileHandler}  ".shtml" "FirefoxHTML"
     ${un.RegCleanFileHandler}  ".xht"   "FirefoxHTML"
     ${un.RegCleanFileHandler}  ".xhtml" "FirefoxHTML"
+    ${un.RegCleanFileHandler}  ".webm"  "FirefoxHTML"
   ${EndIf}
 
   SetShellVarContext all  ; Set SHCTX to HKLM
   ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   ${If} $R9 == "false"
     SetShellVarContext current  ; Set SHCTX to HKCU
     ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   ${EndIf}
--- a/toolkit/mozapps/installer/windows/nsis/common.nsh
+++ b/toolkit/mozapps/installer/windows/nsis/common.nsh
@@ -1115,16 +1115,77 @@
     !insertmacro CreateRegKey
 
     !undef _MOZFUNC_UN
     !define _MOZFUNC_UN
     !verbose pop
   !endif
 !macroend
 
+/**
+ * Helper for checking for the existence of a registry key.
+ * SHCTX is the root key to search.
+ *
+ * @param   _MAIN_KEY
+ *          Sub key to iterate for the key in question
+ * @param   _KEY
+ *          Key name to search for
+ * @return  _RESULT
+ *          'true' / 'false' result
+ */
+!macro CheckIfRegistryKeyExists
+  !ifndef CheckIfRegistryKeyExists
+    !verbose push
+    !verbose ${_MOZFUNC_VERBOSE}
+    !define CheckIfRegistryKeyExists "!insertmacro CheckIfRegistryKeyExistsCall"
+
+    Function CheckIfRegistryKeyExists
+      ; stack: main key, key
+      Exch $R9 ; main key
+      Exch 1
+      Exch $R8 ; key
+      Push $R7
+      Push $R6
+      Push $R5
+
+      StrCpy $R5 "false"
+      StrCpy $R7 "0" # loop index
+      ${Do}
+        EnumRegKey $R6 SHCTX "$R9" "$R7"
+        ${If} "$R6" == "$R8"
+          StrCpy $R5 "true"
+          ${Break}
+        ${EndIf}
+        IntOp $R7 $R7 + 1
+      ${LoopWhile} $R6 != ""
+      ClearErrors
+
+      StrCpy $R9 $R5
+
+      Pop $R5
+      Pop $R6
+      Pop $R7
+      Exch $R8
+      Exch 1
+      Exch $R9
+    FunctionEnd
+
+    !verbose pop
+  !endif
+!macroend
+
+!macro CheckIfRegistryKeyExistsCall _MAIN_KEY _KEY _RESULT
+  !verbose push
+  !verbose ${_MOZFUNC_VERBOSE}
+  Push "${_KEY}"
+  Push "${_MAIN_KEY}"
+  Call CheckIfRegistryKeyExists
+  Pop ${_RESULT}
+  !verbose pop
+!macroend
 
 ################################################################################
 # Macros for adding file and protocol handlers
 
 /**
  * Writes common registry values for a handler using SHCTX.
  *
  * @param   _KEY