Custom Windows Webview2 Args (#4467)

* Adding the ability to pass custom args to windows webview2

---------

Co-authored-by: Jason Gibson <jason@harbingerinteractive.com>
Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Hudolus 2025-08-02 06:03:41 -05:00 committed by GitHub
commit 4c70d4501e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View file

@ -15,7 +15,9 @@ This file is automatically processed by the nightly release workflow.
After processing, the content will be moved to the main changelog and this file will be reset.
-->
### Added
## Added
<!-- New features, capabilities, or enhancements -->
- Added `AdditionalLaunchArgs` to `WindowsWindow` options to allow for additional command line arguments to be passed to the WebView2 browser. in [PR](https://github.com/wailsapp/wails/pull/4467)
- Added Run go mod tidy automatically after wails init [@triadmoko](https://github.com/triadmoko) in [PR](https://github.com/wailsapp/wails/pull/4286)
- Windows Snapassist feature by @leaanthony in [PR](https://github.dev/wailsapp/wails/pull/4463)

View file

@ -292,13 +292,15 @@ type WindowsWindow struct {
// PasswordAutosaveEnabled enables autosaving passwords
PasswordAutosaveEnabled bool
// EnabledFeatures and DisabledFeatures are used to enable or disable specific features in the WebView2 browser.
// EnabledFeatures, DisabledFeatures and AdditionalLaunchArgs are used to enable or disable specific features in the WebView2 browser.
// Available flags: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/webview-features-flags?tabs=dotnetcsharp#available-webview2-browser-flags
// WARNING: Apps in production shouldn't use WebView2 browser flags,
// because these flags might be removed or altered at any time,
// and aren't necessarily supported long-term.
EnabledFeatures []string
DisabledFeatures []string
// AdditionalLaunchArgs should always be preceded by "--"
EnabledFeatures []string
DisabledFeatures []string
AdditionalLaunchArgs []string
}
type Theme int

View file

@ -1798,6 +1798,10 @@ func (w *windowsWebviewWindow) setupChromium() {
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, arg)
}
if len(opts.AdditionalLaunchArgs) > 0 {
chromium.AdditionalBrowserArgs = append(chromium.AdditionalBrowserArgs, opts.AdditionalLaunchArgs...)
}
chromium.DataPath = globalApplication.options.Windows.WebviewUserDataPath
chromium.BrowserPath = globalApplication.options.Windows.WebviewBrowserPath