Bug 737833 - Metro style enabled desktop browser installer registration. r=rstrong

This commit is contained in:
Brian R. Bondy 2012-09-11 14:58:58 -04:00
parent 4c7deba14e
commit 3a2cf3d366
4 changed files with 135 additions and 8 deletions

View File

@ -76,6 +76,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro CleanUpdatesDir
!insertmacro CopyFilesFromDir
!insertmacro CreateRegKey
!insertmacro GetLongPath
!insertmacro GetPathFromString
!insertmacro GetParent
!insertmacro InitHashAppModelId
@ -90,6 +91,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro RegCleanAppHandler
!insertmacro RegCleanMain
!insertmacro RegCleanUninstall
!insertmacro RemoveDEHRegistrationIfMatching
!insertmacro SetAppLSPCategories
!insertmacro SetBrandNameVars
!insertmacro UpdateShortcutAppModelIDs
@ -324,10 +326,20 @@ Section "-Application" APP_IDX
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
StrCpy $2 "$\"$8$\" -osint -url $\"%1$\""
; In Win8, the delegate execute handler picks up the value in FirefoxURL and
; FirefoxHTML to launch the desktop browser when it needs to.
${AddDisabledDDEHandlerValues} "FirefoxHTML" "$2" "$8,1" \
"${AppRegName} Document" ""
${AddDisabledDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" \
"true"
${If} ${AtLeastWin8}
${CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID}
${AddMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
"$INSTDIR\CommandExecuteHandler.exe" \
$AppUserModelID \
"FirefoxURL" \
"FirefoxHTML"
${EndIf}
; The following keys should only be set if we can write to HKLM
${If} $TmpVal == "HKLM"
@ -444,7 +456,7 @@ Section "-Application" APP_IDX
"$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${LogMsg} "Added Shortcut: $SMPROGRAMS\${BrandFullName}.lnk"
${Else}
@ -459,7 +471,7 @@ Section "-Application" APP_IDX
"$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${LogMsg} "Added Shortcut: $DESKTOP\${BrandFullName}.lnk"
${Else}

View File

@ -2,6 +2,10 @@
# 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}
!macro PostUpdate
${CreateShortcutsLog}
@ -209,7 +213,7 @@
ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${Else}
SetShellVarContext current ; Set $DESKTOP to the current user's desktop
@ -220,7 +224,7 @@
"$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${EndIf}
${EndUnless}
@ -235,7 +239,7 @@
"$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${Else}
SetShellVarContext current ; Set $SMPROGRAMS to the current user's Start
@ -247,7 +251,7 @@
"$INSTDIR"
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID"
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "$AppUserModelID" "true"
${EndIf}
${EndIf}
${EndUnless}
@ -314,6 +318,14 @@
${AddDisabledDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" \
"true"
${If} ${AtLeastWin8}
${CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID}
${AddMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
"$INSTDIR\CommandExecuteHandler.exe" \
$AppUserModelID \
"FirefoxURL" \
"FirefoxHTML"
${EndIf}
; An empty string is used for the 4th & 5th params because the following
; protocol handlers already have a display name and the additional keys
@ -846,7 +858,7 @@
ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\$1" \
"$INSTDIR"
${If} "$AppUserModelID" != ""
ApplicationID::Set "$SMPROGRAMS\$1" "$AppUserModelID"
ApplicationID::Set "$SMPROGRAMS\$1" "$AppUserModelID" "true"
${EndIf}
${EndIf}
${EndUnless}
@ -931,7 +943,7 @@
${If} ${AtLeastWin7}
${AndIf} "$AppUserModelID" != ""
ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" \
"$AppUserModelID"
"$AppUserModelID" "true"
${EndIf}
${EndIf}
${EndIf}

View File

@ -76,6 +76,7 @@ VIAddVersionKey "OriginalFilename" "helper.exe"
!insertmacro RegCleanAppHandler
!insertmacro RegCleanMain
!insertmacro RegCleanUninstall
!insertmacro RemoveDEHRegistrationIfMatching
!insertmacro SetAppLSPCategories
!insertmacro SetBrandNameVars
!insertmacro UpdateShortcutAppModelIDs
@ -100,6 +101,7 @@ VIAddVersionKey "OriginalFilename" "helper.exe"
!insertmacro un.RegCleanMain
!insertmacro un.RegCleanUninstall
!insertmacro un.RegCleanProtocolHandler
!insertmacro un.RemoveDEHRegistrationIfMatching
!insertmacro un.RemoveQuotesFromPath
!insertmacro un.SetAppLSPCategories
!insertmacro un.SetBrandNameVars
@ -282,6 +284,10 @@ Section "Uninstall"
${un.SetAppLSPCategories}
${EndIf}
${If} ${AtLeastWin8}
${un.CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID}
${EndIf}
${un.RegCleanAppHandler} "FirefoxURL"
${un.RegCleanAppHandler} "FirefoxHTML"
${un.RegCleanProtocolHandler} "ftp"

View File

@ -6954,3 +6954,100 @@
!verbose pop
!endif
!macroend
; Removes the CEH registration if it's set to our installation directory.
; If it's set to some other installation directory, then it should be removed
; by that installation.
!macro RemoveDEHRegistrationIfMatchingCall un
Function ${un}RemoveDEHRegistrationIfMatchingCall
; Move the old $R0 on the stack and set it to DEH ID
Exch $R0
; Backup the old values of R8 and R7 on the stack
Push $R8
Push $R7
ReadRegStr $R8 HKCU "Software\Classes\CLSID\$R0\LocalServer32" ""
${${un}GetLongPath} "$INSTDIR" $R7
StrCmp "$R8" "" next +1
${${un}GetParent} "$R8" $R8
${${un}GetLongPath} "$R8" $R8
StrCmp "$R7" "$R8" +1 next
DeleteRegKey HKCU "Software\Classes\CLSID\$R0"
DeleteRegValue HKCU \
"Software\Classes\$AppUserModelID\.exe\shell\open\command" \
"DelegateExecute"
next:
ReadRegStr $R8 HKLM "Software\Classes\CLSID\$R0\LocalServer32" ""
${${un}GetLongPath} "$INSTDIR" $R7
StrCmp "$R8" "" done +1
${${un}GetParent} "$R8" $R8
${${un}GetLongPath} "$R8" $R8
StrCmp "$R7" "$R8" +1 done
DeleteRegKey HKLM "Software\Classes\CLSID\$R0"
DeleteRegValue HKLM \
"Software\Classes\$AppUserModelID\.exe\shell\open\command" \
"DelegateExecute"
done:
; Restore the stack back to its original state
Pop $R7
Pop $R8
Pop $R0
FunctionEnd
!macroend
!macro RemoveDEHRegistrationIfMatching
!insertmacro RemoveDEHRegistrationIfMatchingCall ""
!macroend
!macro un.RemoveDEHRegistrationIfMatching
!insertmacro RemoveDEHRegistrationIfMatchingCall "un."
!macroend
!macro CleanupMetroBrowserHandlerValues un DELEGATE_EXECUTE_HANDLER_ID
Push ${DELEGATE_EXECUTE_HANDLER_ID}
Call ${un}RemoveDEHRegistrationIfMatchingCall
!macroend
!define CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues ""'
!define un.CleanupMetroBrowserHandlerValues '!insertmacro CleanupMetroBrowserHandlerValues "un."'
!macro AddMetroBrowserHandlerValues DELEGATE_EXECUTE_HANDLER_ID \
DELEGATE_EXECUTE_HANDLER_PATH \
APP_USER_MODEL_ID \
PROTOCOL_ACTIVATION_ID \
FILE_ACTIVATION_ID
; Win8 doesn't use conventional progid command data to launch anymore.
; Instead it uses a delegate execute handler which is a light weight COM
; server for choosing the metro or desktop browser to launch depending
; on the current environment (metro/desktop) it was activated in.
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}" "" ""
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe" "" ""
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell" "" "open"
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open" "CommandId" "open"
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "" "$2"
WriteRegStr SHCTX "Software\Classes\${APP_USER_MODEL_ID}\.exe\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
; Augment the url handler registrations with additional data needed for Metro
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "AppUserModelID" "${APP_USER_MODEL_ID}"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationName" "$BrandShortName"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationIcon" "$INSTDIR\${FileMainEXE},0"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationCompany" "${CompanyName}"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\Application" "ApplicationDescription" "$(REG_APP_DESC)"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell" "" "open"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open" "CommandId" "open"
WriteRegStr SHCTX "Software\Classes\${PROTOCOL_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
; Augment the file handler registrations with additional data needed for Metro
WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}" "AppUserModelID" "${APP_USER_MODEL_ID}"
WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell" "" "open"
WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open" "CommandId" "open"
WriteRegStr SHCTX "Software\Classes\${FILE_ACTIVATION_ID}\shell\open\command" "DelegateExecute" "${DELEGATE_EXECUTE_HANDLER_ID}"
; Win8 Metro delegate execute handler registration
WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "" "$BrandShortName CommandExecuteHandler"
WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}" "AppId" "${DELEGATE_EXECUTE_HANDLER_ID}"
WriteRegStr SHCTX "Software\Classes\CLSID\${DELEGATE_EXECUTE_HANDLER_ID}\LocalServer32" "" "${DELEGATE_EXECUTE_HANDLER_PATH}"
!macroend
!define AddMetroBrowserHandlerValues "!insertmacro AddMetroBrowserHandlerValues"