${SegmentFile}
!define CUSTOM_CHROMEDIR '$AppDirectory\Chrome-bin'
!define CUSTOM_CFFLASHDIR '$PortableAppsDirectory\CommonFiles\Flash'
Var Custom_AdditionalParameters                  
Var Custom_bolNodeWrpNatMessgInstalled           
${SegmentPre}
	StrCpy $R9 '${CUSTOM_CFFLASHDIR}'
	${If} ${FileExists} "$R9\pepflashplayer.dll"
	StrCpy $Custom_AdditionalParameters '--ppapi-flash-path="$R9\pepflashplayer.dll"'
	${GetFileVersion} "$R9\pepflashplayer.dll" $0
	StrCpy $Custom_AdditionalParameters '$Custom_AdditionalParameters --ppapi-flash-version=$0'
	${Else}
	StrCpy $R9 '${CUSTOM_CHROMEDIR}\plugins'
	${If} ${FileExists} "$R9\pepflashplayer.dll"
	StrCpy $Custom_AdditionalParameters '--ppapi-flash-path="$R9\pepflashplayer.dll"'
	${GetFileVersion} "$R9\pepflashplayer.dll" $0
	StrCpy $Custom_AdditionalParameters '$Custom_AdditionalParameters --ppapi-flash-version=$0'
	${Endif}
	${Endif}
!macroend
${SegmentPreExec}
        ${If} ${FileExists} '$LOCALAPPDATA\com.add0n.native_client\*.*'
	StrCpy $Custom_bolNodeWrpNatMessgInstalled true
	${Else}
	StrCpy $Custom_bolNodeWrpNatMessgInstalled false
	SetOutPath '$AppDirectory\Chrome-bin\windows-native-client'
	nsExec::ExecToStack `"$AppDirectory\Chrome-bin\windows-native-client\install.bat"`
	SetOutPath '$EXEDIR'
	${EndIf}
!macroend
${SegmentPostPrimary}
	${If} $Custom_bolNodeWrpNatMessgInstalled != true
	SetOutPath '$AppDirectory\Chrome-bin\windows-native-client'
	nsExec::ExecToStack `"$AppDirectory\Chrome-bin\windows-native-client\uninstall.bat"`
	SetOutPath '$EXEDIR'
	${EndIf}
        DeleteRegKey /ifempty HKCU SOFTWARE\Google\Chrome\NativeMessagingHosts
	DeleteRegKey /ifempty HKCU SOFTWARE\Google\Chrome
	DeleteRegKey /ifempty HKCU SOFTWARE\Google
        DeleteRegKey /ifempty HKCU SOFTWARE\Mozilla\NativeMessagingHosts
	DeleteRegKey /ifempty HKCU SOFTWARE\Mozilla
        DeleteRegKey /ifempty HKLM SOFTWARE\Wow6432Node\Google
        RMDir /r '$DataDirectory\Chrome\User Data\PepperFlash'
	RMDir /r '$DataDirectory\Chrome\User Data\Default\Pepper Data'
	RMDir /r '$DataDirectory\Chrome\User Data\Default\Cache'
	RMDir /r '$DataDirectory\Chrome\User Data\Default\Media Cache'
	RMDir /r '$LOCALAPPDATA\Google\Chrome Cleanup Tool'
        RMDir /r '$LOCALAPPDATA\Google'
!macroend
