Skip to content

Feature: WebView2 settings #3056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/NETworkManager/Controls/WebConsoleControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
</Rectangle>
</Button>
</Grid>
<webview:WebView2 Grid.Row="2" x:Name="Browser2">
<webview:WebView2 Grid.Row="2" x:Name="Browser">
<webview:WebView2.Style>
<Style TargetType="{x:Type webview:WebView2}">
<Style.Triggers>
Expand Down
35 changes: 23 additions & 12 deletions Source/NETworkManager/Controls/WebConsoleControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ public WebConsoleControl(Guid tabId, WebConsoleSessionInfo sessionInfo)
_tabId = tabId;
_sessionInfo = sessionInfo;

Browser2.NavigationStarting += Browser2_NavigationStarting;
Browser2.NavigationCompleted += Browser2_NavigationCompleted;
Browser2.SourceChanged += Browser2_SourceChanged;
Browser.NavigationStarting += Browser2_NavigationStarting;
Browser.NavigationCompleted += Browser2_NavigationCompleted;
Browser.SourceChanged += Browser2_SourceChanged;

Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}

private void Browser2_SourceChanged(object sender, CoreWebView2SourceChangedEventArgs e)
{
Url = Browser2.Source.ToString();
Url = Browser.Source.ToString();
}

private async void UserControl_Loaded(object sender, RoutedEventArgs e)
Expand All @@ -98,7 +98,16 @@ private async void UserControl_Loaded(object sender, RoutedEventArgs e)
// Set user data folder - Fix #382
var webView2Environment =
await CoreWebView2Environment.CreateAsync(null, GlobalStaticConfiguration.WebConsole_Cache);
await Browser2.EnsureCoreWebView2Async(webView2Environment);

await Browser.EnsureCoreWebView2Async(webView2Environment);

//await Browser.CoreWebView2.Profile.ClearBrowsingDataAsync();

// Set the default settings
Browser.CoreWebView2.Settings.IsStatusBarEnabled = true;
Browser.CoreWebView2.Settings.AreDevToolsEnabled = false;
Browser.CoreWebView2.Settings.IsGeneralAutofillEnabled = true;
Browser.CoreWebView2.Settings.IsPasswordAutosaveEnabled = true;

Navigate(_sessionInfo.Url);

Expand Down Expand Up @@ -142,31 +151,31 @@ private bool ReloadCommand_CanExecute(object obj)

private void ReloadAction()
{
Browser2.Reload();
Browser.Reload();
}

private bool GoBackCommand_CanExecute(object obj)
{
return !IsLoading && Browser2.CanGoBack;
return !IsLoading && Browser.CanGoBack;
}

public ICommand GoBackCommand => new RelayCommand(_ => GoBackAction(), GoBackCommand_CanExecute);

private void GoBackAction()
{
Browser2.GoBack();
Browser.GoBack();
}

private bool GoForwardCommand_CanExecute(object obj)
{
return !IsLoading && Browser2.CanGoForward;
return !IsLoading && Browser.CanGoForward;
}

public ICommand GoForwardCommand => new RelayCommand(_ => GoForwardAction(), GoForwardCommand_CanExecute);

private void GoForwardAction()
{
Browser2.GoForward();
Browser.GoForward();
}

#endregion
Expand All @@ -175,12 +184,14 @@ private void GoForwardAction()

private void Navigate(string url)
{
Browser2.Source = new Uri(url);
Browser.Source = new Uri(url);
}

private void Stop()
{
Browser2.Stop();
Browser.Stop();


}

public void CloseTab()
Expand Down