Skip to content
Merged
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
10 changes: 5 additions & 5 deletions SampleApps/WebView2APISample/ProcessComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow)
//! [CrashReport]
// Query for the crash report (available when Crashpad handled
// the crash; nullptr for __fastfail / WER-only crashes).
auto experimentalArgs2 =
args.try_query<ICoreWebView2ExperimentalProcessFailedEventArgs2>();
if (experimentalArgs2)
auto processFailedArgs4 =
args.try_query<ICoreWebView2ProcessFailedEventArgs4>();
if (processFailedArgs4)
{
wil::com_ptr<ICoreWebView2ExperimentalCrashReport> crashReport;
CHECK_FAILURE(experimentalArgs2->get_CrashReport(&crashReport));
wil::com_ptr<ICoreWebView2CrashReport> crashReport;
CHECK_FAILURE(processFailedArgs4->get_CrashReport(&crashReport));
if (crashReport)
{
wil::unique_cotaskmem_string crashReportId;
Expand Down
4 changes: 2 additions & 2 deletions SampleApps/WebView2APISample/WebView2APISample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.4255-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.4255-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.4312-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.4312-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.4255-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.4255-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.4312-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.4312-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion SampleApps/WebView2APISample/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.4255-prerelease" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.4312-prerelease" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220201.1" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.4255-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.4312-prerelease" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
Expand Down
55 changes: 55 additions & 0 deletions SampleApps/WebView2WpfBrowser/ClusterEnvironmentDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Window x:Class="WebView2WpfBrowser.ClusterEnvironmentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WebView2WpfBrowser"
mc:Ignorable="d"
Title="Shared Cluster Environment"
SizeToContent="Height"
Width="440"
WindowStartupLocation="CenterOwner">
<StackPanel Margin="12">
<TextBlock TextWrapping="Wrap" Margin="0,0,0,10"
Text="Hosts that pass the same ClusterName and the same options share a single browser process. The first host to create the cluster pins these options; a later host that asks for a different set gets an options mismatch."/>

<TextBlock x:Name="ClusterNameLabel" Text="ClusterName"/>
<TextBox x:Name="ClusterNameInput" Margin="0,2,0,8"
AutomationProperties.LabeledBy="{Binding ElementName=ClusterNameLabel}"/>

<TextBlock x:Name="LanguageLabel" Text="Language"/>
<TextBox x:Name="LanguageInput" Margin="0,2,0,8"
AutomationProperties.LabeledBy="{Binding ElementName=LanguageLabel}"/>

<TextBlock x:Name="BrowserArgsLabel" Text="AdditionalBrowserArguments"/>
<TextBox x:Name="BrowserArgsInput" Margin="0,2,0,8"
AutomationProperties.LabeledBy="{Binding ElementName=BrowserArgsLabel}"/>

<TextBlock Text="Options" Margin="0,4,0,2"/>
<CheckBox x:Name="SingleSignOnInput" Content="AllowSingleSignOnUsingOSPrimaryAccount" Margin="0,2"/>
<CheckBox x:Name="TrackingPreventionInput" Content="EnableTrackingPrevention" Margin="0,2"/>
<CheckBox x:Name="BrowserExtensionsInput" Content="AreBrowserExtensionsEnabled" Margin="0,2"/>
<CheckBox x:Name="ProfileIsolationInput" Content="PerHostProfileIsolation" Margin="0,2,0,8"/>

<TextBlock Text="ReleaseChannels" Margin="0,4,0,2"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,8"
AutomationProperties.Name="ReleaseChannels">
<CheckBox x:Name="StableInput" Content="Stable" Margin="0,0,12,0"/>
<CheckBox x:Name="BetaInput" Content="Beta" Margin="0,0,12,0"/>
<CheckBox x:Name="DevInput" Content="Dev" Margin="0,0,12,0"/>
<CheckBox x:Name="CanaryInput" Content="Canary"/>
</StackPanel>

<TextBlock x:Name="SearchKindLabel" Text="ChannelSearchKind"/>
<ComboBox x:Name="SearchKindInput" Margin="0,2,0,12"
AutomationProperties.LabeledBy="{Binding ElementName=SearchKindLabel}">
<ComboBoxItem Content="MostStable"/>
<ComboBoxItem Content="LeastStable"/>
</ComboBox>

<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Click="ok_Clicked" IsDefault="True" Width="80" Margin="0,0,8,0">OK</Button>
<Button IsCancel="True" Width="80">Cancel</Button>
</StackPanel>
</StackPanel>
</Window>
92 changes: 92 additions & 0 deletions SampleApps/WebView2WpfBrowser/ClusterEnvironmentDialog.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System.Windows;

namespace WebView2WpfBrowser
{
/// <summary>
/// Collects the options used to create or join a shared cluster environment.
///
/// Exposes only plain CLR types rather than
/// CoreWebView2ClusterEnvironmentOptions, because those are experimental
/// APIs absent from the stable package, so naming them here would fail the
/// Stable configuration with CS0246. MainWindow converts inside its
/// USE_WEBVIEW2_EXPERIMENTAL block.
///
/// The defaults match the Win32 WebView2APISample so both samples pin an
/// identical option set and can join each other's clusters.
/// </summary>
public partial class ClusterEnvironmentDialog : Window
{
public ClusterEnvironmentDialog(string defaultClusterName)
{
InitializeComponent();

ClusterNameInput.Text = defaultClusterName;
LanguageInput.Text = string.Empty;
BrowserArgsInput.Text = string.Empty;

SingleSignOnInput.IsChecked = false;
TrackingPreventionInput.IsChecked = true;
BrowserExtensionsInput.IsChecked = false;
ProfileIsolationInput.IsChecked = true;

StableInput.IsChecked = true;
BetaInput.IsChecked = true;
DevInput.IsChecked = true;
CanaryInput.IsChecked = true;

// LeastStable so the loader prefers a Canary/Dev channel install over
// the stable Evergreen runtime, which predates the cluster feature.
SearchKindInput.SelectedIndex = 1;

ClusterNameInput.Focus();
ClusterNameInput.SelectAll();
}

// Trimmed because the cluster name becomes a folder name: the loader
// rejects control characters and a trailing space or dot.
public string ClusterName => ClusterNameInput.Text.Trim();

// Named ClusterLanguage rather than Language because FrameworkElement
// already defines a Language property, and the sample builds with
// TreatWarningsAsErrors so CS0108 would fail the build.
public string ClusterLanguage => LanguageInput.Text.Trim();

public string AdditionalBrowserArguments => BrowserArgsInput.Text.Trim();

public bool AllowSingleSignOnUsingOSPrimaryAccount => SingleSignOnInput.IsChecked == true;

public bool EnableTrackingPrevention => TrackingPreventionInput.IsChecked == true;

public bool AreBrowserExtensionsEnabled => BrowserExtensionsInput.IsChecked == true;

public bool PerHostProfileIsolation => ProfileIsolationInput.IsChecked == true;

public bool StableChannel => StableInput.IsChecked == true;

public bool BetaChannel => BetaInput.IsChecked == true;

public bool DevChannel => DevInput.IsChecked == true;

public bool CanaryChannel => CanaryInput.IsChecked == true;

/// <summary>
/// 0 = MostStable, 1 = LeastStable. Matches the values of
/// CoreWebView2ChannelSearchKind without naming the experimental enum.
/// </summary>
public int ChannelSearchKindIndex => SearchKindInput.SelectedIndex;

void ok_Clicked(object sender, RoutedEventArgs args)
{
if (string.IsNullOrWhiteSpace(ClusterNameInput.Text))
{
MessageBox.Show(this, "ClusterName is required.", "Shared Cluster Environment");
// Put the caret back in the field that needs fixing, rather
// than leaving a keyboard or screen reader user to find it.
ClusterNameInput.Focus();
ClusterNameInput.SelectAll();
return;
}
DialogResult = true;
}
}
}
8 changes: 8 additions & 0 deletions SampleApps/WebView2WpfBrowser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ found in the LICENSE file.
<CommandBinding Command="{x:Static local:MainWindow.NewBrowserVersionCommand}" Executed="NewBrowserVersionCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
<CommandBinding Command="{x:Static local:MainWindow.SwipeNavigationCommand}" Executed="SwipeNavigationCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
<!-- #if USE_WEBVIEW2_EXPERIMENTAL -->
<CommandBinding Command="{x:Static local:MainWindow.ClusterEnvironmentCreateOrJoinCommand}" Executed="ClusterEnvironmentCreateOrJoinExecuted"/>
<CommandBinding Command="{x:Static local:MainWindow.ClusterEnvironmentGetOptionsCommand}" Executed="ClusterEnvironmentGetOptionsExecuted"/>
<CommandBinding Command="{x:Static local:MainWindow.SetOriginFeaturesCommand}" Executed="SetOriginFeaturesCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
<CommandBinding Command="{x:Static local:MainWindow.GetEffectiveFeaturesForOriginCommand}" Executed="GetEffectiveFeaturesForOriginCmdExecuted" CanExecute="CoreWebView2RequiringCmdsCanExecute"/>
<!-- #endif -->
Expand Down Expand Up @@ -176,6 +178,12 @@ found in the LICENSE file.
<MenuItem Header="_New Window" Command="ApplicationCommands.New"/>
<MenuItem Header="_New Window With Options" Command="{x:Static local:MainWindow.NewWindowWithOptionsCommand}"/>
<MenuItem Header="_Create New Thread" Command="{x:Static local:MainWindow.CreateNewThreadCommand}"/>
<!-- #if USE_WEBVIEW2_EXPERIMENTAL -->
<MenuItem Header="Shared _Cluster Environment">
<MenuItem Header="_Create or Join Cluster" Command="{x:Static local:MainWindow.ClusterEnvironmentCreateOrJoinCommand}"/>
<MenuItem Header="_Get Cluster Options" Command="{x:Static local:MainWindow.ClusterEnvironmentGetOptionsCommand}"/>
</MenuItem>
<!-- #endif -->
<!---TODO-->
</MenuItem>
<MenuItem Header="_Process">
Expand Down
Loading
Loading