bug 1300738 - Remove old Metro cleanup code that causes Firefox post update to corrupt Windows 10 user profiles when using registry protection software. r=mhowell, a=rkothari
authorRobert Strong <robert.bugzilla@gmail.com>
Thu, 15 Sep 2016 12:59:04 -0700
changeset 350227 552d4e79ae73a8a6ef0249c7239acc8f6089df44
parent 350226 0d74830d451a85508c3e1f78eb264602cc51bdb8
child 350228 d73d2a4d9be2d8569658df1e1f5fe429d6dc2ac9
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell, rkothari
bugs1300738
milestone50.0a2
bug 1300738 - Remove old Metro cleanup code that causes Firefox post update to corrupt Windows 10 user profiles when using registry protection software. r=mhowell, a=rkothari
browser/installer/windows/nsis/installer.nsi
browser/installer/windows/nsis/shared.nsh
browser/installer/windows/nsis/uninstaller.nsi
--- a/browser/installer/windows/nsis/installer.nsi
+++ b/browser/installer/windows/nsis/installer.nsi
@@ -420,22 +420,16 @@ Section "-Application" APP_IDX
     StrCpy $0 "Software\Clients\StartMenuInternet\$R9\InstallInfo"
     ${If} $AddDesktopSC == 1
     ${OrIf} $AddStartMenuSC == 1
     ${OrIf} $AddTaskbarSC == 1
       WriteRegDWORD HKCU "$0" "IconsVisible" 1
     ${Else}
       WriteRegDWORD HKCU "$0" "IconsVisible" 0
     ${EndIf}
-  ${If} ${AtLeastWin8}
-    ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
-                             $AppUserModelID \
-                             "FirefoxURL" \
-                             "FirefoxHTML"
-  ${EndIf}
   ${EndIf}
 
 !ifdef MOZ_MAINTENANCE_SERVICE
   ; If the maintenance service page was displayed then a value was already 
   ; explicitly selected for installing the maintenance service and 
   ; and so InstallMaintenanceService will already be 0 or 1.
   ; If the maintenance service page was not displayed then 
   ; InstallMaintenanceService will be equal to "".
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -1,35 +1,13 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-; The registration ID of the COM server which is used for choosing wether
-; to launch the Win8 metro browser or desktop browser.
-!define DELEGATE_EXECUTE_HANDLER_ID {5100FEC1-212B-4BF5-9BF8-3E650FD794A3}
-;
-; Defines for adjust token privs and for enumerating keys
-!ifndef TOKEN_QUERY
-  !define TOKEN_QUERY             0x0008
-!endif
-!ifndef TOKEN_ADJUST_PRIVILEGES
-  !define TOKEN_ADJUST_PRIVILEGES 0x0020
-!endif
-!ifndef SE_RESTORE_NAME
-  !define SE_RESTORE_NAME         SeRestorePrivilege
-!endif
-!ifndef SE_PRIVILEGE_ENABLED
-  !define SE_PRIVILEGE_ENABLED    0x00000002
-!endif
-!ifndef HKEY_USERS
-  !define HKEY_USERS              0x80000003
-!endif
-
 !macro PostUpdate
-
   ; PostUpdate is called from both session 0 and from the user session
   ; for service updates, make sure that we only register with the user session
   ; Otherwise ApplicationID::Set can fail intermittently with a file in use error.
   System::Call "kernel32::GetCurrentProcessId() i.r0"
   System::Call "kernel32::ProcessIdToSessionId(i $0, *i ${NSIS_MAX_STRLEN} r9)"
 
   ; Determine if we're the protected UserChoice default or not. If so fix the
   ; start menu tile.  In case there are 2 Firefox installations, we only do
@@ -186,24 +164,16 @@
       ; based on the above checks, so attempt to just run the EXE.
       ; In the worst case, in case there is some edge case with the
       ; IsAdmin check and the permissions check, the maintenance service
       ; will just fail to be attempted to be installed.
       nsExec::Exec "$\"$INSTDIR\maintenanceservice_installer.exe$\""
     ${EndIf}
   ${EndIf}
 !endif
-
-; Register the DEH
-${If} ${AtLeastWin8}
-  ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
-                           $AppUserModelID \
-                           "FirefoxURL" \
-                           "FirefoxHTML"
-${EndIf}
 !macroend
 !define PostUpdate "!insertmacro PostUpdate"
 
 !macro SetAsDefaultAppGlobal
   ${RemoveDeprecatedKeys} ; Does not use SHCTX
 
   SetShellVarContext all      ; Set SHCTX to all users (e.g. HKLM)
   ${SetHandlers} ; Uses SHCTX
@@ -826,178 +796,16 @@
   StrCpy $0 "Software\Microsoft\Windows\Shell\Associations\UrlAssociations\gopher"
   ReadRegStr $2 HKCU "$0\UserChoice" "Progid"
   ${If} "$2" == "FirefoxURL"
     DeleteRegKey HKCU "$0"
   ${EndIf}
 !macroend
 !define RemoveDeprecatedKeys "!insertmacro RemoveDeprecatedKeys"
 
-; Resets Win8+ specific toast keys Windows sets. We call this on a
-; fresh install and on uninstall.
-!macro ResetWin8PromptKeys KEY PREFIX
-  ${If} ${AtLeastWin8}
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxHTML_.htm"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxHTML_.html"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxHTML_.xht"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxHTML_.xhtml"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxHTML_.shtml"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxURL_ftp"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxURL_http"
-    DeleteRegValue ${KEY} "${PREFIX}Software\Microsoft\Windows\CurrentVersion\ApplicationAssociationToasts" "FirefoxURL_https"
-  ${EndIf}
-!macroend
-!define ResetWin8PromptKeys "!insertmacro ResetWin8PromptKeys"
-
-; Adds SE_RESTORE_NAME privs
-!macro AcquireSERestoreName
-  StrCpy $R1 0
-
-  System::Call "kernel32::GetCurrentProcess() i .R0"
-  System::Call "advapi32::OpenProcessToken(i R0, i ${TOKEN_QUERY}|${TOKEN_ADJUST_PRIVILEGES}, \
-                                          *i R1R1) i .R0"
-  ${If} $R0 != 0
-    System::Call "advapi32::LookupPrivilegeValue(t n, t '${SE_RESTORE_NAME}', *l .R2) i .R0"
-    ${If} $R0 != 0
-      System::Call "*(i 1, l R2, i ${SE_PRIVILEGE_ENABLED}) i .R0"
-      System::Call "advapi32::AdjustTokenPrivileges(i R1, i 0, i R0, i 0, i 0, i 0)"
-      System::Free $R0
-    ${EndIf}
-    System::Call "kernel32::CloseHandle(i R1)"
-  ${EndIf}
-!macroend
-!define AcquireSERestoreName "!insertmacro AcquireSERestoreName"
-!define un.AcquireSERestoreName "!insertmacro AcquireSERestoreName"
-
-; Mounts all user ntuser.dat files into the registry as a subkey of HKU
-!macro MountRegistryIntoHKU
-  ; $0 is used as an index for HKEY_USERS enumeration
-  StrCpy $0 0
-  ${Do}
-    EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $0
-    ${If} $1 == ""
-      ${Break}
-    ${EndIf}
-    ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$1" "ProfileImagePath"
-    System::Call "advapi32::RegLoadKey(i ${HKEY_USERS}, t 'User-$0', t '$2\ntuser.dat')"
-    System::Call "advapi32::RegLoadKey(i ${HKEY_USERS}, t 'User-$0_Classes', t '$2\AppData\Local\Microsoft\Windows\UsrClass.dat')"
-    IntOp $0 $0 + 1
-  ${Loop}
-!macroend
-!define MountRegistryIntoHKU "!insertmacro MountRegistryIntoHKU"
-!define un.MountRegistryIntoHKU "!insertmacro MountRegistryIntoHKU"
-
-; Unmounts all user ntuser.dat files into the registry as a subkey of HKU
-!macro UnmountRegistryIntoHKU
-  ; $0 is used as an index for HKEY_USERS enumeration
-  StrCpy $0 0
-  ${Do}
-    EnumRegKey $1 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList" $0
-    ${If} $1 == ""
-      ${Break}
-    ${EndIf}
-    ReadRegStr $2 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$1" "ProfileImagePath"
-    System::Call "advapi32::RegUnLoadKey(i ${HKEY_USERS}, t 'User-$0')"
-    System::Call "advapi32::RegUnLoadKey(i ${HKEY_USERS}, t 'User-$0_Classes')"
-    IntOp $0 $0 + 1
-  ${Loop}
-!macroend
-!define UnmountRegistryIntoHKU "!insertmacro UnmountRegistryIntoHKU"
-!define un.UnmountRegistryIntoHKU "!insertmacro UnmountRegistryIntoHKU"
-
-; Unconditionally removes the delegate execute handler registration used to
-; launch the metro browser and misc. metro related registry values.
-!macro RemoveDEHRegistration DELEGATE_EXECUTE_HANDLER_ID \
-                             APP_USER_MODEL_ID \
-                             PROTOCOL_ACTIVATION_ID \
-                             FILE_ACTIVATION_ID
-  ${AcquireSERestoreName}
-  ${MountRegistryIntoHKU}
-
-  ; $0 is used as an index for HKEY_USERS enumeration
-  StrCpy $0 0
-
-  ${Do}
-    EnumRegKey $1 HKU "" $0
-    ${If} $1 == ""
-      ${Break}
-    ${EndIf}
-
-    ClearErrors
-    ${WordFind} "$1" "_Classes" "E#" $3
-    ${Unless} ${Errors}
-      ; remove the app user model id root registration. We don't need this
-      ; here anymore, we just use it for tray registrationdown in widget,
-      ; which we read out of the mozilla keys.
-      ${If} "${APP_USER_MODEL_ID}" != ""
-        ; The removal of this key intermittently fails, so do the best we can in cleanup
-        DeleteRegValue HKU "$1\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute"
-        DeleteRegKey HKU "$1\${APP_USER_MODEL_ID}\.exe\shell\open"
-        DeleteRegKey HKU "$1\${APP_USER_MODEL_ID}\.exe\shell"
-        DeleteRegKey HKU "$1\${APP_USER_MODEL_ID}\.exe"
-        DeleteRegKey HKU "$1\\${APP_USER_MODEL_ID}"
-      ${EndIf}
-      ;
-      ; Remove delegate execute handler clsid registration
-      DeleteRegKey HKU "$1\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}"
-
-      ; Remove protocol and file delegate execute handler id assoc
-      DeleteRegValue HKU "$1\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID"
-      DeleteRegValue HKU "$1\${FILE_ACTIVATION_ID}" "AppUserModelID"
-
-      ; Remove delegate execute application registry keys
-      DeleteRegKey HKU "$1\${PROTOCOL_ACTIVATION_ID}\Application"
-      DeleteRegKey HKU "$1\${FILE_ACTIVATION_ID}\Application"
-
-      ; Remove misc. shell open info
-      DeleteRegValue HKU "$1\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId"
-      DeleteRegValue HKU "$1\${FILE_ACTIVATION_ID}\shell\open" "CommandId"
-      DeleteRegValue HKU "$1\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute"
-      DeleteRegValue HKU "$1\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute"
-
-      ; remove metro browser splash image data
-      DeleteRegKey HKU "$1\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\SystemAppData\DefaultBrowser_NOPUBLISHERID\SplashScreen\DefaultBrowser_NOPUBLISHERID!${APP_USER_MODEL_ID}"
-    ${Else}
-      ; misc. Metro keys
-      DeleteRegKey HKU "$1\Software\Mozilla\Firefox\Metro"
-      DeleteRegValue HKU "$1\Software\Mozilla\Firefox" "CEHDump"
-      DeleteRegValue HKU "$1\Software\Mozilla\Firefox" "MetroD3DAvailable"
-      DeleteRegValue HKU "$1\Software\Mozilla\Firefox" "MetroLastAHE"
-      ${ResetWin8PromptKeys} "HKU" "$1\"
-    ${EndIf}
-    IntOp $0 $0 + 1
-  ${Loop}
-  ${UnmountRegistryIntoHKU}
-
-  ; The removal of this key intermittently fails, so do the best we can in cleanup
-  ${If} "${APP_USER_MODEL_ID}" != ""
-    DeleteRegValue HKLM "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute"
-    DeleteRegKey HKLM "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open"
-    DeleteRegKey HKLM "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell"
-    DeleteRegKey HKLM "Software\Classes\${APP_USER_MODEL_ID}\.exe"
-    DeleteRegKey HKLM "Software\Classes\${APP_USER_MODEL_ID}"
-  ${EndIf}
-
-  ; Remove HKLM entries
-  DeleteRegKey HKLM "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}"
-  DeleteRegKey HKLM "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application"
-  DeleteRegKey HKLM "Software\Classes\${FILE_ACTIVATION_ID}\Application"
-  DeleteRegValue HKLM "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute"
-  DeleteRegValue HKLM "Software\Classes\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute"
-  DeleteRegValue HKLM "Software\Classes\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID"
-  DeleteRegValue HKLM "Software\Classes\${FILE_ACTIVATION_ID}" "AppUserModelID"
-  DeleteRegValue HKLM "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId"
-  DeleteRegValue HKLM "Software\Classes\${FILE_ACTIVATION_ID}\shell\open" "CommandId"
-
-  ClearErrors
-!macroend
-
-!define RemoveDEHRegistration "!insertmacro RemoveDEHRegistration"
-!define un.RemoveDEHRegistration "!insertmacro RemoveDEHRegistration"
-
 ; Removes various directories and files for reasons noted below.
 !macro RemoveDeprecatedFiles
   ; Some users are ending up with unpacked chrome instead of omni.ja. This
   ; causes Firefox to break badly after upgrading from Firefox 31, see bug
   ; 1063052. Removing the chrome.manifest from the install directory causes
   ; Firefox to use the updated omni.ja so it won't crash.
   ${If} ${FileExists} "$INSTDIR\chrome.manifest"
     Delete "$INSTDIR\chrome.manifest"
--- a/browser/installer/windows/nsis/uninstaller.nsi
+++ b/browser/installer/windows/nsis/uninstaller.nsi
@@ -273,23 +273,16 @@ Section "Uninstall"
     DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
     StrCpy $TmpVal "HKLM" ; used primarily for logging
     ${un.RegCleanMain} "Software\Mozilla"
     ${un.RegCleanUninstall}
     ${un.DeleteShortcuts}
     ${un.SetAppLSPCategories}
   ${EndIf}
 
-  ${If} ${AtLeastWin8}
-    ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
-                             $AppUserModelID \
-                             "FirefoxURL" \
-                             "FirefoxHTML"
-  ${EndIf}
-
   ${un.RegCleanAppHandler} "FirefoxURL"
   ${un.RegCleanAppHandler} "FirefoxHTML"
   ${un.RegCleanProtocolHandler} "ftp"
   ${un.RegCleanProtocolHandler} "http"
   ${un.RegCleanProtocolHandler} "https"
 
   ClearErrors
   ReadRegStr $R9 HKCR "FirefoxHTML" ""