From 9131ae5db351a645160114379b91b65f9600a0be Mon Sep 17 00:00:00 2001 From: WebView2 Github Bot Date: Mon, 13 May 2024 17:43:08 +0000 Subject: [PATCH 1/2] Updates for Win32, WPF, WinForms, UWP and WinUI3 sample apps from 126.0.2584.0 --- SampleApps/WebView2APISample/AppWindow.cpp | 3 +- .../ScenarioScreenCapture.cpp | 12 ++++++ .../WebView2APISample/ScenarioScreenCapture.h | 11 +++++ .../ScenarioScreenCaptureIFrame2.html | 32 ++++++++++++++ .../WebView2APISample/SettingsComponent.cpp | 7 ++- .../WebView2APISample.vcxproj | 18 +++++++- .../assets/ScenarioScreenCapture.html | 43 +++++++++++++++++++ .../assets/ScenarioScreenCaptureIFrame1.html | 32 ++++++++++++++ .../assets/ScenarioScreenCaptureIFrame2.html | 32 ++++++++++++++ SampleApps/WebView2WpfBrowser/MainWindow.xaml | 2 +- .../WebView2WpfBrowser/MainWindow.xaml.cs | 1 + 11 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 SampleApps/WebView2APISample/ScenarioScreenCapture.cpp create mode 100644 SampleApps/WebView2APISample/ScenarioScreenCapture.h create mode 100644 SampleApps/WebView2APISample/ScenarioScreenCaptureIFrame2.html create mode 100644 SampleApps/WebView2APISample/assets/ScenarioScreenCapture.html create mode 100644 SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame1.html create mode 100644 SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame2.html diff --git a/SampleApps/WebView2APISample/AppWindow.cpp b/SampleApps/WebView2APISample/AppWindow.cpp index 97f63c78..283de405 100644 --- a/SampleApps/WebView2APISample/AppWindow.cpp +++ b/SampleApps/WebView2APISample/AppWindow.cpp @@ -1777,7 +1777,8 @@ void AppWindow::RegisterEventHandlers() static const wchar_t* browser_launching_domain = L"www.example.com"; wil::unique_bstr source_domain = GetDomainOfUri(source.get()); const wchar_t* source_domain_as_wchar = source_domain.get(); - if (wcscmp(browser_launching_domain, source_domain_as_wchar) == 0) + if (source_domain_as_wchar && + wcscmp(browser_launching_domain, source_domain_as_wchar) == 0) { // Open the URI in the default browser. wil::unique_cotaskmem_string target_uri; diff --git a/SampleApps/WebView2APISample/ScenarioScreenCapture.cpp b/SampleApps/WebView2APISample/ScenarioScreenCapture.cpp new file mode 100644 index 00000000..837590f9 --- /dev/null +++ b/SampleApps/WebView2APISample/ScenarioScreenCapture.cpp @@ -0,0 +1,12 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "stdafx.h" + +#include "ScenarioScreenCapture.h" + +#include "AppWindow.h" +#include "CheckFailure.h" + +using namespace Microsoft::WRL; diff --git a/SampleApps/WebView2APISample/ScenarioScreenCapture.h b/SampleApps/WebView2APISample/ScenarioScreenCapture.h new file mode 100644 index 00000000..273b918a --- /dev/null +++ b/SampleApps/WebView2APISample/ScenarioScreenCapture.h @@ -0,0 +1,11 @@ +// Copyright (C) Microsoft Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#pragma once +#include "stdafx.h" + +#include + +#include "AppWindow.h" +#include "ComponentBase.h" diff --git a/SampleApps/WebView2APISample/ScenarioScreenCaptureIFrame2.html b/SampleApps/WebView2APISample/ScenarioScreenCaptureIFrame2.html new file mode 100644 index 00000000..6c7f330f --- /dev/null +++ b/SampleApps/WebView2APISample/ScenarioScreenCaptureIFrame2.html @@ -0,0 +1,32 @@ + + + + ScenarioScreenCaptureIFrame2 + + +

Screen Capture Test From Top Level IFrame 2

+ + +
+ + + + diff --git a/SampleApps/WebView2APISample/SettingsComponent.cpp b/SampleApps/WebView2APISample/SettingsComponent.cpp index e3966fdf..5ffadad3 100644 --- a/SampleApps/WebView2APISample/SettingsComponent.cpp +++ b/SampleApps/WebView2APISample/SettingsComponent.cpp @@ -1814,7 +1814,12 @@ SettingsComponent::~SettingsComponent() wil::unique_bstr GetDomainOfUri(PWSTR uri) { wil::com_ptr uriObject; - CreateUri(uri, Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_DECODE_EXTRA_INFO, 0, &uriObject); + HRESULT hr = CreateUri( + uri, Uri_CREATE_CANONICALIZE | Uri_CREATE_NO_DECODE_EXTRA_INFO, 0, &uriObject); + if (FAILED(hr)) + { + return nullptr; + } wil::unique_bstr domain; uriObject->GetHost(&domain); return domain; diff --git a/SampleApps/WebView2APISample/WebView2APISample.vcxproj b/SampleApps/WebView2APISample/WebView2APISample.vcxproj index a8d8eed3..ffe82b32 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.vcxproj +++ b/SampleApps/WebView2APISample/WebView2APISample.vcxproj @@ -1,4 +1,4 @@ - + @@ -244,6 +244,7 @@ + @@ -295,6 +296,7 @@ + @@ -375,6 +377,15 @@ $(OutDir)\assets + + $(OutDir)\assets + + + $(OutDir)\assets + + + $(OutDir)\assets + $(OutDir)\assets @@ -451,6 +462,9 @@ $(OutDir)\assets + + $(OutDir)\assets + @@ -467,4 +481,4 @@ - + \ No newline at end of file diff --git a/SampleApps/WebView2APISample/assets/ScenarioScreenCapture.html b/SampleApps/WebView2APISample/assets/ScenarioScreenCapture.html new file mode 100644 index 00000000..f094b526 --- /dev/null +++ b/SampleApps/WebView2APISample/assets/ScenarioScreenCapture.html @@ -0,0 +1,43 @@ + + + + ScenarioScreenCapture + + +

ScenarioScreenCapture Sample Page

+

Screen Capture Test From Main Frame

+ + +
+ + + + + + + diff --git a/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame1.html b/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame1.html new file mode 100644 index 00000000..6d6ce82f --- /dev/null +++ b/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame1.html @@ -0,0 +1,32 @@ + + + + ScenarioScreenCaptureIFrame1 + + +

Screen Capture Test From Top Level IFrame1

+ + +
+ + + + diff --git a/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame2.html b/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame2.html new file mode 100644 index 00000000..0d901e5a --- /dev/null +++ b/SampleApps/WebView2APISample/assets/ScenarioScreenCaptureIFrame2.html @@ -0,0 +1,32 @@ + + + + ScenarioScreenCaptureIFrame2 + + +

Screen Capture Test From Top Level IFrame2

+ + +
+ + + + diff --git a/SampleApps/WebView2WpfBrowser/MainWindow.xaml b/SampleApps/WebView2WpfBrowser/MainWindow.xaml index a4dcfde3..f557cfe2 100644 --- a/SampleApps/WebView2WpfBrowser/MainWindow.xaml +++ b/SampleApps/WebView2WpfBrowser/MainWindow.xaml @@ -128,7 +128,7 @@ found in the LICENSE file. - + diff --git a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs index e7a3caa0..020fe8b6 100644 --- a/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs +++ b/SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs @@ -287,6 +287,7 @@ void CloseCmdExecuted(object sender, ExecutedRoutedEventArgs e) return; } } + webView.Dispose(); this.Close(); } From 75202cdb234020c48c255dccc553ca78ef18ed5b Mon Sep 17 00:00:00 2001 From: WebView2 Github Bot Date: Mon, 13 May 2024 17:43:50 +0000 Subject: [PATCH 2/2] Updated package version for Win32, WPF and WinForms sample apps to 1.0.2584-prerelease --- SampleApps/WebView2APISample/WebView2APISample.vcxproj | 8 ++++---- SampleApps/WebView2APISample/packages.config | 2 +- .../WebView2WindowsFormsBrowser.csproj | 2 +- SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SampleApps/WebView2APISample/WebView2APISample.vcxproj b/SampleApps/WebView2APISample/WebView2APISample.vcxproj index ffe82b32..cc977670 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.vcxproj +++ b/SampleApps/WebView2APISample/WebView2APISample.vcxproj @@ -1,4 +1,4 @@ - + @@ -472,13 +472,13 @@ - + 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}. - + - \ No newline at end of file + diff --git a/SampleApps/WebView2APISample/packages.config b/SampleApps/WebView2APISample/packages.config index 6ad4540c..8f9266a4 100644 --- a/SampleApps/WebView2APISample/packages.config +++ b/SampleApps/WebView2APISample/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj index 483fb461..bcefe844 100644 --- a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj +++ b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj @@ -25,7 +25,7 @@ AnyCPU - + diff --git a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj index ee5a5f0b..f8c02a1e 100644 --- a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj +++ b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj @@ -61,7 +61,7 @@ - +