Skip to content

Commit

Permalink
Update projects to use latest WebView2 SDK 1.0.2164-prerelease (#220)
Browse files Browse the repository at this point in the history
* Updates for Win32, WPF and WinForms sample apps from 120.0.2164.0

* Updated package version for Win32, WPF and WinForms sample apps to 1.0.2164-prerelease

---------

Co-authored-by: WebView2 Github Bot <webview2github@microsoft.com>
  • Loading branch information
peiche-jessica and WebView2GithubBot committed Oct 18, 2023
1 parent a72e8b5 commit 8619209
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 52 deletions.
16 changes: 13 additions & 3 deletions SampleApps/WebView2APISample/ProcessComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow)
// needed.
ScheduleReloadIfSelectedByUser(
L"Browser render process exited unexpectedly. Reload page?",
L"Web page unresponsive");
L"Render process exited");
}
// Check the runtime event args implements the newer interface.
auto args2 = args.try_query<ICoreWebView2ProcessFailedEventArgs2>();
Expand Down Expand Up @@ -100,17 +100,27 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow)
COREWEBVIEW2_PROCESS_FAILED_REASON reason;
wil::unique_cotaskmem_string processDescription;
int exitCode;
wil::unique_cotaskmem_string failedModule;

CHECK_FAILURE(args2->get_Reason(&reason));
CHECK_FAILURE(args2->get_ProcessDescription(&processDescription));
CHECK_FAILURE(args2->get_ExitCode(&exitCode));

auto argFailedModule =
args.try_query<ICoreWebView2ExperimentalProcessFailedEventArgs>();
if (argFailedModule)
{
CHECK_FAILURE(
argFailedModule->get_FailureSourceModulePath(&failedModule));
}

std::wstringstream message;
message << L"Kind: " << ProcessFailedKindToString(kind) << L"\n"
<< L"Reason: " << ProcessFailedReasonToString(reason) << L"\n"
<< L"Exit code: " << exitCode << L"\n"
<< L"Process description: " << processDescription.get()
<< std::endl;
<< L"Process description: " << processDescription.get() << std::endl
<< (failedModule ? L"Failed module: " : L"")
<< (failedModule ? failedModule.get() : L"");
m_appWindow->AsyncMessageBox( std::move(message.str()), L"Child process failed");
}
return S_OK;
Expand Down
1 change: 0 additions & 1 deletion SampleApps/WebView2APISample/ScriptComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ bool ScriptComponent::HandleWindowMessage(
}
return false;
}

void ScriptComponent::AddBrowserExtension()
{

Expand Down
1 change: 0 additions & 1 deletion SampleApps/WebView2APISample/ScriptComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ScriptComponent : public ComponentBase
void AddBrowserExtension();
void RemoveOrDisableBrowserExtension(const bool remove);
~ScriptComponent() override;

void HandleIFrames();
std::wstring IFramesToString();
std::vector<wil::com_ptr<ICoreWebView2Frame>> m_frames;
Expand Down
26 changes: 13 additions & 13 deletions SampleApps/WebView2APISample/WebView2APISample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<LanguageStandard>stdcpp17</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -145,8 +145,8 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp17</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
Expand All @@ -162,8 +162,8 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>USE_WEBVIEW2_WIN10;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;shlwapi.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;urlmon.lib;Gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>onecoreuap.lib %(AdditionalOptions)</AdditionalOptions>
Expand All @@ -174,8 +174,8 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>USE_WEBVIEW2_WIN10;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;shlwapi.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;urlmon.lib;Gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>
Expand All @@ -188,8 +188,8 @@
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>USE_WEBVIEW2_WIN10;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;shlwapi.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;urlmon.lib;Gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>onecoreuap.lib %(AdditionalOptions)</AdditionalOptions>
Expand All @@ -201,7 +201,7 @@
<LanguageStandard>stdcpp17</LanguageStandard>
<PreprocessorDefinitions>USE_WEBVIEW2_WIN10;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;shlwapi.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;urlmon.lib;Gdiplus.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>onecoreuap.lib %(AdditionalOptions)</AdditionalOptions>
Expand Down Expand Up @@ -425,13 +425,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.2106-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2106-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2164-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2164-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.2106-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2106-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2164-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2164-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.2106-prerelease" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2164-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.2106-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2164-prerelease" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2106-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2164-prerelease" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function onHeaderClick() {
console.log("onHeaderClick+");
const header = document.getElementById('header');
document.getElementById('HeaderSpace').innerHTML = header.innerHTML;
document.getElementById('HeaderSpace').textContent = header.textContent;
console.log("onHeaderClick-");
}

Expand Down
25 changes: 0 additions & 25 deletions SampleApps/webview2_sample_uwp/Pages/Browser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
using System.Diagnostics;
using System.IO;
using webview2_sample_uwp;
#if USE_WEBVIEW2_SMOKETEST
using Windows.Storage;
#endif
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;

namespace WebView2_UWP.Pages
{
public sealed partial class Browser : BasePage
Expand All @@ -36,22 +32,11 @@ public Browser()
WebView2.Source = new Uri(AddressBar.Text);
}

#if USE_WEBVIEW2_SMOKETEST
private async void WebView2_CoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args)
#else
private void WebView2_CoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args)
#endif
{
if (args.Exception != null)
{
StatusUpdate($"Error initializing WebView2: {args.Exception.Message}");

#if USE_WEBVIEW2_SMOKETEST
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
StorageFile file = await localFolder.CreateFileAsync(@"Failure.txt", CreationCollisionOption.FailIfExists);
await FileIO.WriteTextAsync(file, args.Exception.ToString());
Environment.Exit(1);
#endif
}
else
{
Expand Down Expand Up @@ -152,11 +137,7 @@ private void WebView2_NavigationStarting(WebView2 sender, CoreWebView2Navigation
CancelButton.IsEnabled = true;
}

#if USE_WEBVIEW2_SMOKETEST
private async void WebView2_NavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
#else
private void WebView2_NavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args)
#endif
{
StatusUpdate("Navigation complete");

Expand All @@ -165,12 +146,6 @@ private void WebView2_NavigationCompleted(WebView2 sender, CoreWebView2Navigatio

// Update the address bar with the full URL that was navigated to.
AddressBar.Text = sender.Source.ToString();

#if USE_WEBVIEW2_SMOKETEST
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
await localFolder.CreateFileAsync(@"Success.txt", CreationCollisionOption.FailIfExists);
Environment.Exit(0);
#endif
}

private bool TryCreateUri(String potentialUri, out Uri result)
Expand Down
5 changes: 0 additions & 5 deletions SampleApps/webview2_sample_uwp/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ public Settings()
_localSettings[SettingsVersionKey] = SettingsVersion;
}

#if USE_WEBVIEW2_SMOKETEST
var webViewExecutableFolder = ApplicationData.Current.LocalFolder.Path + "\\EdgeBin";
Environment.SetEnvironmentVariable(WebViewExecutableFolderEnvKey, webViewExecutableFolder);
#else
InitializeEnvSetting(WebViewExecutableFolderKey, WebViewExecutableFolderEnvKey);
#endif
InitializeEnvSetting(WebViewUserDataFolderKey, WebViewUserDataFolderEnvKey);
InitializeEnvSetting(WebViewReleaseChannelPrefKey, WebViewReleaseChannelPrefEnvKey);
InitializeEnvSetting(WebViewAdditionalArgumentsKey, WebViewAdditionalArgumentsEnvKey);
Expand Down

0 comments on commit 8619209

Please sign in to comment.