Skip to content

Commit 7464bd6

Browse files
Update projects to use latest WebView2 SDK 1.0.1248-prerelease (#131)
* Updates for Win32, WPF and WinForms sample apps from 102.0.1248.0 * Updated package version for Win32, WPF and WinForms sample apps to 1.0.1248-prerelease Co-authored-by: WebView2 Github Bot <[email protected]>
1 parent 79fcca1 commit 7464bd6

File tree

9 files changed

+51
-42
lines changed

9 files changed

+51
-42
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "SettingsComponent.h"
4545
#include "TextInputDialog.h"
4646
#include "ViewComponent.h"
47-
4847
using namespace Microsoft::WRL;
4948
static constexpr size_t s_maxLoadString = 100;
5049
static constexpr UINT s_runAsyncWindowMessage = WM_APP;
@@ -716,20 +715,19 @@ bool AppWindow::ExecuteAppCommands(WPARAM wParam, LPARAM lParam)
716715
//! [ClearBrowsingData]
717716
bool AppWindow::ClearBrowsingData(COREWEBVIEW2_BROWSING_DATA_KINDS dataKinds)
718717
{
719-
auto webView2_12 = m_webView.try_query<ICoreWebView2_12>();
720-
CHECK_FEATURE_RETURN(webView2_12);
718+
auto webView2_13 = m_webView.try_query<ICoreWebView2_13>();
719+
CHECK_FEATURE_RETURN(webView2_13);
721720
wil::com_ptr<ICoreWebView2Profile> webView2Profile;
722-
CHECK_FAILURE(webView2_12->get_Profile(&webView2Profile));
721+
CHECK_FAILURE(webView2_13->get_Profile(&webView2Profile));
723722
CHECK_FEATURE_RETURN(webView2Profile);
724-
auto webView2ExperimentalProfile4 =
725-
webView2Profile.try_query<ICoreWebView2ExperimentalProfile4>();
726-
CHECK_FEATURE_RETURN(webView2ExperimentalProfile4);
723+
auto webView2Profile2 = webView2Profile.try_query<ICoreWebView2Profile2>();
724+
CHECK_FEATURE_RETURN(webView2Profile2);
727725
// Clear the browsing data from the last hour.
728726
double endTime = (double)std::time(nullptr);
729727
double startTime = endTime - 3600.0;
730-
CHECK_FAILURE(webView2ExperimentalProfile4->ClearBrowsingDataInTimeRange(
728+
CHECK_FAILURE(webView2Profile2->ClearBrowsingDataInTimeRange(
731729
dataKinds, startTime, endTime,
732-
Callback<ICoreWebView2ExperimentalClearBrowsingDataCompletedHandler>(
730+
Callback<ICoreWebView2ClearBrowsingDataCompletedHandler>(
733731
[this](HRESULT error) -> HRESULT {
734732
AsyncMessageBox(L"Completed", L"Clear Browsing Data");
735733
return S_OK;
@@ -874,6 +872,7 @@ void AppWindow::InitializeWebView()
874872
}
875873
#endif
876874
//! [CreateCoreWebView2EnvironmentWithOptions]
875+
877876
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
878877
CHECK_FAILURE(
879878
options->put_AllowSingleSignOnUsingOSPrimaryAccount(
@@ -1082,11 +1081,11 @@ HRESULT AppWindow::OnCreateCoreWebView2ControllerCompleted(HRESULT result, ICore
10821081
// available.
10831082
CHECK_FAILURE(m_webView->get_BrowserProcessId(&m_newestBrowserPid));
10841083
//! [CoreWebView2Profile]
1085-
auto webView2_12 = coreWebView2.try_query<ICoreWebView2_12>();
1086-
if (webView2_12)
1084+
auto webView2_13 = coreWebView2.try_query<ICoreWebView2_13>();
1085+
if (webView2_13)
10871086
{
10881087
wil::com_ptr<ICoreWebView2Profile> profile;
1089-
CHECK_FAILURE(webView2_12->get_Profile(&profile));
1088+
CHECK_FAILURE(webView2_13->get_Profile(&profile));
10901089
wil::unique_cotaskmem_string profile_name;
10911090
CHECK_FAILURE(profile->get_ProfileName(&profile_name));
10921091
m_profileName = profile_name.get();

SampleApps/WebView2APISample/ScenarioWebViewEventMonitor.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,21 @@ std::wstring DOMContentLoadedArgsToJsonString(
415415
return message;
416416
}
417417

418+
std::wstring WebResourceRequestedToJsonString(
419+
ICoreWebView2WebResourceRequest* webResourceRequest,
420+
const std::wstring& source = std::wstring())
421+
{
422+
std::wstring message = L"{ \"kind\": \"event\", \"name\": "
423+
L"\"WebResourceRequested\", \"args\": {"
424+
L"\"request\": " +
425+
RequestToJsonString(webResourceRequest) +
426+
L", "
427+
L"\"response\": null" +
428+
source + L"}";
429+
430+
return message;
431+
}
432+
418433
void ScenarioWebViewEventMonitor::EnableWebResourceResponseReceivedEvent(bool enable) {
419434
if (!enable && m_webResourceResponseReceivedToken.value != 0)
420435
{
@@ -482,13 +497,8 @@ void ScenarioWebViewEventMonitor::EnableWebResourceRequestedEvent(bool enable)
482497
CHECK_FAILURE(args->get_Request(&webResourceRequest));
483498
wil::com_ptr<ICoreWebView2WebResourceResponse> webResourceResponse;
484499
CHECK_FAILURE(args->get_Response(&webResourceResponse));
485-
486-
std::wstring message = L"{ \"kind\": \"event\", \"name\": "
487-
L"\"WebResourceRequested\", \"args\": {"
488-
L"\"request\": " + RequestToJsonString(webResourceRequest.get()) + L", "
489-
L"\"response\": null"
490-
L"}";
491-
500+
std::wstring message =
501+
WebResourceRequestedToJsonString(webResourceRequest.get());
492502
message += WebViewPropertiesToJsonString(m_webviewEventSource.get());
493503
message += L"}";
494504
PostEventMessage(message);

SampleApps/WebView2APISample/SettingsComponent.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ SettingsComponent::SettingsComponent(
3434
m_webView2_5 = m_webView.try_query<ICoreWebView2_5>();
3535
m_webView2_11 = m_webView.try_query<ICoreWebView2_11>();
3636
m_webView2_12 = m_webView.try_query<ICoreWebView2_12>();
37+
m_webView2_13 = m_webView.try_query<ICoreWebView2_13>();
38+
m_webView2_14 = m_webView.try_query<ICoreWebView2_14>();
3739
m_webViewExperimental5 = m_webView.try_query<ICoreWebView2Experimental5>();
3840
m_webViewExperimental12 = m_webView.try_query<ICoreWebView2Experimental12>();
39-
m_webViewExperimental15 = m_webView.try_query<ICoreWebView2Experimental15>();
4041
// Copy old settings if desired
4142
if (old)
4243
{
@@ -978,12 +979,11 @@ bool SettingsComponent::HandleWindowMessage(
978979
}
979980
case ID_CLEAR_SERVER_CERTIFICATE_ERROR_ACTIONS:
980981
{
981-
CHECK_FEATURE_RETURN(m_webViewExperimental15);
982+
CHECK_FEATURE_RETURN(m_webView2_14);
982983
// This example clears `AlwaysAllow` response that are added for proceeding with TLS
983984
// certificate errors.
984-
CHECK_FAILURE(m_webViewExperimental15->ClearServerCertificateErrorActions(
985-
Callback<
986-
ICoreWebView2ExperimentalClearServerCertificateErrorActionsCompletedHandler>(
985+
CHECK_FAILURE(m_webView2_14->ClearServerCertificateErrorActions(
986+
Callback<ICoreWebView2ClearServerCertificateErrorActionsCompletedHandler>(
987987
[this](HRESULT result) -> HRESULT {
988988
auto showDialog = [result] {
989989
MessageBox(
@@ -1353,7 +1353,7 @@ void SettingsComponent::EnableCustomClientCertificateSelection()
13531353

13541354
// Function to validate the server certificate for untrusted root or self-signed certificate.
13551355
// You may also choose to defer server certificate validation.
1356-
static bool ValidateServerCertificate(ICoreWebView2ExperimentalCertificate* certificate)
1356+
static bool ValidateServerCertificate(ICoreWebView2Certificate* certificate)
13571357
{
13581358
// You may want to validate certificates in different ways depending on your app and
13591359
// scenario. One way might be the following:
@@ -1376,20 +1376,19 @@ static bool ValidateServerCertificate(ICoreWebView2ExperimentalCertificate* cert
13761376
// continues the request to a server. Otherwise, cancel the request.
13771377
void SettingsComponent::ToggleCustomServerCertificateSupport()
13781378
{
1379-
if (m_webViewExperimental15)
1379+
if (m_webView2_14)
13801380
{
13811381
if (m_ServerCertificateErrorToken.value == 0)
13821382
{
1383-
CHECK_FAILURE(m_webViewExperimental15->add_ServerCertificateErrorDetected(
1384-
Callback<ICoreWebView2ExperimentalServerCertificateErrorDetectedEventHandler>(
1383+
CHECK_FAILURE(m_webView2_14->add_ServerCertificateErrorDetected(
1384+
Callback<ICoreWebView2ServerCertificateErrorDetectedEventHandler>(
13851385
[this](
13861386
ICoreWebView2* sender,
1387-
ICoreWebView2ExperimentalServerCertificateErrorDetectedEventArgs* args) {
1387+
ICoreWebView2ServerCertificateErrorDetectedEventArgs* args) {
13881388
COREWEBVIEW2_WEB_ERROR_STATUS errorStatus;
13891389
CHECK_FAILURE(args->get_ErrorStatus(&errorStatus));
13901390

1391-
wil::com_ptr<ICoreWebView2ExperimentalCertificate> certificate =
1392-
nullptr;
1391+
wil::com_ptr<ICoreWebView2Certificate> certificate = nullptr;
13931392
CHECK_FAILURE(args->get_ServerCertificate(&certificate));
13941393

13951394
// Continues the request to a server with a TLS certificate if the error
@@ -1417,7 +1416,7 @@ void SettingsComponent::ToggleCustomServerCertificateSupport()
14171416
}
14181417
else
14191418
{
1420-
CHECK_FAILURE(m_webViewExperimental15->remove_ServerCertificateErrorDetected(
1419+
CHECK_FAILURE(m_webView2_14->remove_ServerCertificateErrorDetected(
14211420
m_ServerCertificateErrorToken));
14221421
m_ServerCertificateErrorToken.value = 0;
14231422
}

SampleApps/WebView2APISample/SettingsComponent.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class SettingsComponent : public ComponentBase
5252
wil::com_ptr<ICoreWebView2_5> m_webView2_5;
5353
wil::com_ptr<ICoreWebView2_11> m_webView2_11;
5454
wil::com_ptr<ICoreWebView2_12> m_webView2_12;
55+
wil::com_ptr<ICoreWebView2_13> m_webView2_13;
56+
wil::com_ptr<ICoreWebView2_14> m_webView2_14;
5557
wil::com_ptr<ICoreWebView2Settings> m_settings;
5658
wil::com_ptr<ICoreWebView2Settings2> m_settings2;
5759
wil::com_ptr<ICoreWebView2Settings3> m_settings3;
@@ -64,7 +66,6 @@ class SettingsComponent : public ComponentBase
6466
wil::com_ptr<ICoreWebView2Environment> m_webViewEnvironment;
6567
wil::com_ptr<ICoreWebView2Experimental5> m_webViewExperimental5;
6668
wil::com_ptr<ICoreWebView2Experimental12> m_webViewExperimental12;
67-
wil::com_ptr<ICoreWebView2Experimental15> m_webViewExperimental15;
6869
wil::com_ptr<ICoreWebView2ContextMenuItem> m_displayPageUrlContextSubMenuItem;
6970

7071
bool m_blockImages = false;

SampleApps/WebView2APISample/ViewComponent.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,13 @@ bool ViewComponent::HandleWindowMessage(
407407
//! [SetPreferredColorScheme]
408408
void ViewComponent::SetPreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME value)
409409
{
410-
wil::com_ptr<ICoreWebView2_12> webView2_12;
411-
webView2_12 = m_webView.try_query<ICoreWebView2_12>();
410+
wil::com_ptr<ICoreWebView2_13> webView2_13;
411+
webView2_13 = m_webView.try_query<ICoreWebView2_13>();
412412

413-
if (webView2_12)
413+
if (webView2_13)
414414
{
415415
wil::com_ptr<ICoreWebView2Profile> profile;
416-
CHECK_FAILURE(webView2_12->get_Profile(&profile));
416+
CHECK_FAILURE(webView2_13->get_Profile(&profile));
417417
profile->put_PreferredColorScheme(value);
418418
}
419419
}

SampleApps/WebView2APISample/WebView2APISample.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,13 @@
545545
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
546546
<ImportGroup Label="ExtensionTargets">
547547
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
548-
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1222-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1222-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
548+
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
549549
</ImportGroup>
550550
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
551551
<PropertyGroup>
552552
<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>
553553
</PropertyGroup>
554554
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.191107.2\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
555-
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1222-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1222-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
555+
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.1248-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
556556
</Target>
557557
</Project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Microsoft.Web.WebView2" version="1.0.1222-prerelease" targetFramework="native" />
3+
<package id="Microsoft.Web.WebView2" version="1.0.1248-prerelease" targetFramework="native" />
44
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.191107.2" targetFramework="native" />
55
</packages>

SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<PlatformTarget>AnyCPU</PlatformTarget>
2020
</PropertyGroup>
2121
<ItemGroup>
22-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1222-prerelease" />
22+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1248-prerelease" />
2323
</ItemGroup>
2424
<ItemGroup>
2525
<None Update="assets\EdgeWebView2-80.jpg">

SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
</Content>
2626
</ItemGroup>
2727
<ItemGroup>
28-
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1222-prerelease" />
28+
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1248-prerelease" />
2929
</ItemGroup>
3030
</Project>

0 commit comments

Comments
 (0)