mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 23:51:44 +08:00
[v2, webview2loader] Prevent env and registry overrides when using the go loader (#2668)
This commit is contained in:
parent
c1a0e1338f
commit
22b53192e6
@ -4,6 +4,7 @@ package webviewloader
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -14,6 +15,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
fmt.Println("DEB | Using go webview2loader")
|
fmt.Println("DEB | Using go webview2loader")
|
||||||
|
preventEnvAndRegistryOverrides()
|
||||||
}
|
}
|
||||||
|
|
||||||
type webView2RunTimeType int32
|
type webView2RunTimeType int32
|
||||||
@ -104,6 +106,8 @@ func createWebViewEnvironmentWithClientDll(lpLibFileName string, runtimeType web
|
|||||||
envCompletedCom := combridge.New[iCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler](envCompletedHandler)
|
envCompletedCom := combridge.New[iCoreWebView2CreateCoreWebView2EnvironmentCompletedHandler](envCompletedHandler)
|
||||||
defer envCompletedCom.Close()
|
defer envCompletedCom.Close()
|
||||||
|
|
||||||
|
preventEnvAndRegistryOverrides()
|
||||||
|
|
||||||
const unknown = 1
|
const unknown = 1
|
||||||
hr, _, err := createProc.Call(
|
hr, _, err := createProc.Call(
|
||||||
uintptr(unknown),
|
uintptr(unknown),
|
||||||
@ -157,3 +161,16 @@ func (r *environmentCreatedHandler) EnvironmentCompleted(errorCode HRESULT, crea
|
|||||||
|
|
||||||
return HRESULT(windows.S_OK)
|
return HRESULT(windows.S_OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func preventEnvAndRegistryOverrides() {
|
||||||
|
// Setting these env variables to empty string also prevents registry overrides because webview2
|
||||||
|
// checks for existence and not for empty value
|
||||||
|
os.Setenv("WEBVIEW2_PIPE_FOR_SCRIPT_DEBUGGER", "")
|
||||||
|
os.Setenv("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "")
|
||||||
|
os.Setenv("WEBVIEW2_RELEASE_CHANNEL_PREFERENCE", "0")
|
||||||
|
|
||||||
|
// The following seems not be be required because those are only used by the webview2loader which
|
||||||
|
// in this case is implemented on our own. But nevertheless set them to empty to be consistent.
|
||||||
|
os.Setenv("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", "")
|
||||||
|
os.Setenv("WEBVIEW2_USER_DATA_FOLDER", "")
|
||||||
|
}
|
||||||
|
@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- The Go WebView2Loader allowed env variable and registry overrides to change the behaviour of WebView2. This is not possible when using the native WebView2Loader with Wails and should not be possible according to [PR](https://github.com/wailsapp/wails/pull/1771). Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2668)
|
||||||
|
|
||||||
## v2.5.0 - 2023-05-13
|
## v2.5.0 - 2023-05-13
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
Loading…
Reference in New Issue
Block a user