Bug 1774082 - Make installer and uninstaller add/remove Toast Notification to/from registry. r=bhearsum,nrishel

Differential Revision: https://phabricator.services.mozilla.com/D152145
This commit is contained in:
Nick Alexander 2022-07-31 21:59:30 +00:00
Родитель 4f7f512a84
Коммит 590ff33177
5 изменённых файлов: 86 добавлений и 0 удалений

Просмотреть файл

@ -10,6 +10,9 @@ DEFINES["MOZ_APP_NAME"] = CONFIG["MOZ_APP_NAME"]
DEFINES["MOZ_APP_DISPLAYNAME"] = CONFIG["MOZ_APP_DISPLAYNAME"]
DEFINES["MOZILLA_VERSION"] = CONFIG["MOZILLA_VERSION"]
# Turn `firefox` into `Firefox`.
DEFINES["MOZ_TOAST_APP_NAME"] = "%s" % CONFIG["MOZ_APP_NAME"].title()
DEFINES["MOZ_HANDLER_CLSID"] = "{%s}" % CONFIG["MOZ_HANDLER_CLSID"]
if CONFIG["MOZ_DEFAULT_BROWSER_AGENT"]:

Просмотреть файл

@ -31,6 +31,7 @@
!define DialogWindowClass "MozillaDialogClass"
!define DDEApplication "Firefox"
!define AppRegName "Firefox"
!define ToastAumidPrefix "@MOZ_TOAST_APP_NAME@Toast-"
!define BrandProductName "Firefox"
!ifndef DEV_EDITION

Просмотреть файл

@ -535,6 +535,10 @@ Section "-Application" APP_IDX
WriteRegDWORD HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Telemetry" 1
!endif
${If} ${AtLeastWin10}
${WriteToastNotificationRegistration} $TmpVal
${EndIf}
; Create shortcuts
${LogHeader} "Adding Shortcuts"

Просмотреть файл

@ -168,6 +168,10 @@
${ResetLauncherProcessDefaults}
!endif
${If} ${AtLeastWin10}
${WriteToastNotificationRegistration} $TmpVal
${EndIf}
; Make sure the scheduled task registration for the default browser agent gets
; updated, but only if we're not the instance of PostUpdate that was started
; by the service, because this needs to run as the actual user. Also, don't do
@ -1781,3 +1785,41 @@ FunctionEnd
!macroend
!define ResetLauncherProcessDefaults "!insertmacro ResetLauncherProcessDefaults"
!endif
!macro WriteToastNotificationRegistration RegKey
; Find or create a GUID to use for this installation. For simplicity, We
; always update our registration.
ClearErrors
ReadRegStr $0 SHCTX "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator"
${If} "$0" == ""
; Create a GUID.
System::Call "rpcrt4::UuidCreate(g . r0)i"
; StringFromGUID2 (which is what System::Call uses internally to stringify
; GUIDs) includes braces in its output. In this case, we want the braces.
${EndIf}
; Check if this is an ESR release.
ClearErrors
${WordFind} "${UpdateChannel}" "esr" "E#" $1
${If} ${Errors}
StrCpy $1 ""
${Else}
StrCpy $1 " ESR"
${EndIf}
; Write the following keys and values to the registry.
; HKEY_CURRENT_USER\Software\Classes\AppID\{GUID} DllSurrogate : REG_SZ = ""
; \AppUserModelId\{ToastAumidPrefix}{install hash} CustomActivator : REG_SZ = {GUID}
; DisplayName : REG_EXPAND_SZ = {display name}
; IconUri : REG_EXPAND_SZ = {icon path}
; \CLSID\{GUID} AppID : REG_SZ = {GUID}
; \InprocServer32 (Default) : REG_SZ = {notificationserver.dll path}
${WriteRegStr2} ${RegKey} "Software\Classes\AppID\$0" "DllSurrogate" "" 0
${WriteRegStr2} ${RegKey} "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator" "$0" 0
${WriteRegStr2} ${RegKey} "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "DisplayName" "${BrandFullNameInternal}$1" 0
; Sadly, we can't use embedded resources like `firefox.exe,1`.
${WriteRegStr2} ${RegKey} "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "IconUri" "$INSTDIR\browser\VisualElements\VisualElements_70.png" 0
${WriteRegStr2} ${RegKey} "Software\Classes\CLSID\$0" "AppID" "$0" 0
${WriteRegStr2} ${RegKey} "Software\Classes\CLSID\$0\InProcServer32" "" "$INSTDIR\notificationserver.dll" 0
!macroend
!define WriteToastNotificationRegistration "!insertmacro WriteToastNotificationRegistration"

Просмотреть файл

@ -607,6 +607,42 @@ Section "Uninstall"
DeleteRegValue HKCU ${MOZ_LAUNCHER_SUBKEY} "$INSTDIR\${FileMainEXE}|Telemetry"
!endif
; Remove Toast Notification registration.
${If} ${AtLeastWin10}
; Find any GUID used for this installation.
ClearErrors
ReadRegStr $0 HKLM "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator"
DeleteRegValue HKLM "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator"
DeleteRegValue HKLM "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "DisplayName"
DeleteRegValue HKLM "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "IconUri"
DeleteRegKey HKLM "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID"
${If} "$0" != ""
DeleteRegValue HKLM "Software\Classes\AppID\$0" "DllSurrogate"
DeleteRegKey HKLM "Software\Classes\AppID\$0"
DeleteRegValue HKLM "Software\Classes\CLSID\$0" "AppID"
DeleteRegValue HKLM "Software\Classes\CLSID\$0\InProcServer32" ""
DeleteRegKey HKLM "Software\Classes\CLSID\$0\InProcServer32"
DeleteRegKey HKLM "Software\Classes\CLSID\$0"
${EndIf}
ClearErrors
ReadRegStr $0 HKCU "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator"
DeleteRegValue HKCU "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "CustomActivator"
DeleteRegValue HKCU "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "DisplayName"
DeleteRegValue HKCU "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID" "IconUri"
DeleteRegKey HKCU "Software\Classes\AppUserModelId\${ToastAumidPrefix}$AppUserModelID"
${If} "$0" != ""
DeleteRegValue HKCU "Software\Classes\AppID\$0" "DllSurrogate"
DeleteRegKey HKCU "Software\Classes\AppID\$0"
DeleteRegValue HKCU "Software\Classes\CLSID\$0" "AppID"
DeleteRegValue HKCU "Software\Classes\CLSID\$0\InProcServer32" ""
DeleteRegKey HKCU "Software\Classes\CLSID\$0\InProcServer32"
DeleteRegKey HKCU "Software\Classes\CLSID\$0"
${EndIf}
${EndIf}
; Uninstall the default browser agent scheduled task and all other scheduled
; tasks registered by Firefox.
; This also removes the registry entries that the WDBA creates.