Skip to content
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

Update projects to use latest WebView2 SDK 1.0.2584-prerelease #245

Merged
merged 2 commits into from
May 28, 2024
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
3 changes: 2 additions & 1 deletion SampleApps/WebView2APISample/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions SampleApps/WebView2APISample/ScenarioScreenCapture.cpp
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions SampleApps/WebView2APISample/ScenarioScreenCapture.h
Original file line number Diff line number Diff line change
@@ -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 <string>

#include "AppWindow.h"
#include "ComponentBase.h"
32 changes: 32 additions & 0 deletions SampleApps/WebView2APISample/ScenarioScreenCaptureIFrame2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>ScenarioScreenCaptureIFrame2</title>
</head>
<body>
<h1>Screen Capture Test From Top Level IFrame 2</h1>
<button onclick="testScreenCapture()">Screen Capture Test</button>
<button id="toggleButton" onclick="toggleStatus()">Disable</button>
<div id="statusDisplay"></div>
<script>
function testScreenCapture() {
navigator.mediaDevices.getDisplayMedia();
}

function toggleStatus() {
var button = document.getElementById('toggleButton');
var statusDisplay = document.getElementById('statusDisplay');
if (button.innerHTML === "Enable") {
chrome.webview.postMessage("EnableScreenCapture");
button.innerHTML = "Disable";
statusDisplay.innerHTML = "Status: Enabled";
} else {
chrome.webview.postMessage("DisableScreenCapture");
button.innerHTML = "Enable";
statusDisplay.innerHTML = "Status: Disabled";
}
}
</script>

</body>
</html>
7 changes: 6 additions & 1 deletion SampleApps/WebView2APISample/SettingsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,12 @@ SettingsComponent::~SettingsComponent()
wil::unique_bstr GetDomainOfUri(PWSTR uri)
{
wil::com_ptr<IUri> 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;
Expand Down
18 changes: 16 additions & 2 deletions SampleApps/WebView2APISample/WebView2APISample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@
<ClInclude Include="ScenarioNotificationReceived.h" />
<ClInclude Include="ScenarioPermissionManagement.h" />
<ClInclude Include="ScenarioSaveAs.h" />
<ClInclude Include="ScenarioScreenCapture.h" />
<ClInclude Include="ScenarioSharedBuffer.h" />
<ClInclude Include="ScenarioSharedWorkerWRR.h" />
<ClInclude Include="ScenarioThrottlingControl.h" />
Expand Down Expand Up @@ -295,6 +296,7 @@
<ClCompile Include="ScenarioNotificationReceived.cpp" />
<ClCompile Include="ScenarioPermissionManagement.cpp" />
<ClCompile Include="ScenarioSaveAs.cpp" />
<ClCompile Include="ScenarioScreenCapture.cpp" />
<ClCompile Include="ScenarioSharedBuffer.cpp" />
<ClCompile Include="ScenarioSharedWorkerWRR.cpp" />
<ClCompile Include="ScenarioThrottlingControl.cpp" />
Expand Down Expand Up @@ -375,6 +377,15 @@
<CopyFileToFolders Include="assets/ScenarioNotificationReceived.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="assets/ScenarioScreenCapture.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="assets/ScenarioScreenCaptureIFrame1.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="assets/ScenarioScreenCaptureIFrame2.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="assets/ScenarioSharedBuffer.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
Expand Down Expand Up @@ -451,20 +462,23 @@
<CopyFileToFolders Include="assets\ScenarioTestingFocus.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
<CopyFileToFolders Include="ScenarioScreenCaptureIFrame2.html">
<DestinationFolders>$(OutDir)\assets</DestinationFolders>
</CopyFileToFolders>
</ItemGroup>
<ItemGroup>
<Midl Include="HostObjectSample.idl" TypeLibraryName="$(OutDir)WebView2APISample.tlb" />
</ItemGroup>
<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.2526-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2526-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2584-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2584-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.2526-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2526-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2584-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2584-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>
43 changes: 43 additions & 0 deletions SampleApps/WebView2APISample/assets/ScenarioScreenCapture.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<title>ScenarioScreenCapture</title>
</head>
<body>
<h1>ScenarioScreenCapture Sample Page</h1>
<h1>Screen Capture Test From Main Frame</h1>
<button onclick="testScreenCapture()">Screen Capture Test</button>
<button id="toggleButton" onclick="toggleStatus()">Disable</button>
<div id="statusDisplay"></div>
<script> function testScreenCapture() {
navigator.mediaDevices.getDisplayMedia();
}

function toggleStatus() {
var button = document.getElementById('toggleButton');
var statusDisplay = document.getElementById('statusDisplay');
if (button.innerHTML === "Enable") {
chrome.webview.postMessage("EnableScreenCapture");
button.innerHTML = "Disable";
statusDisplay.innerHTML = "Status: Enabled";
} else {
chrome.webview.postMessage("DisableScreenCapture");
button.innerHTML = "Enable";
statusDisplay.innerHTML = "Status: Disabled";
}
}
</script>

<iframe src="ScenarioScreenCaptureIFrame1.html"
name="iframe-toplevel1"
title=""
height="300"
width="1000"> </iframe>

<iframe src="ScenarioScreenCaptureIFrame2.html"
name="iframe-toplevel2"
title=""
height="300"
width="1000"> </iframe>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>ScenarioScreenCaptureIFrame1</title>
</head>
<body>
<h1>Screen Capture Test From Top Level IFrame1</h1>
<button onclick="testScreenCapture()">Screen Capture Test</button>
<button id="toggleButton" onclick="toggleStatus()">Disable</button>
<div id="statusDisplay"></div>
<script>
function testScreenCapture() {
navigator.mediaDevices.getDisplayMedia();
}

function toggleStatus() {
var button = document.getElementById('toggleButton');
var statusDisplay = document.getElementById('statusDisplay');
if (button.innerHTML === "Enable") {
chrome.webview.postMessage("EnableScreenCapture");
button.innerHTML = "Disable";
statusDisplay.innerHTML = "Status: Enabled";
} else {
chrome.webview.postMessage("DisableScreenCapture");
button.innerHTML = "Enable";
statusDisplay.innerHTML = "Status: Disabled";
}
}
</script>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html>
<head>
<title>ScenarioScreenCaptureIFrame2</title>
</head>
<body>
<h1>Screen Capture Test From Top Level IFrame2</h1>
<button onclick="testScreenCapture()">Screen Capture Test</button>
<button id="toggleButton" onclick="toggleStatus()">Disable</button>
<div id="statusDisplay"></div>
<script>
function testScreenCapture() {
navigator.mediaDevices.getDisplayMedia();
}

function toggleStatus() {
var button = document.getElementById('toggleButton');
var statusDisplay = document.getElementById('statusDisplay');
if (button.innerHTML === "Enable") {
chrome.webview.postMessage("EnableScreenCapture");
button.innerHTML = "Disable";
statusDisplay.innerHTML = "Status: Enabled";
} else {
chrome.webview.postMessage("DisableScreenCapture");
button.innerHTML = "Enable";
statusDisplay.innerHTML = "Status: Disabled";
}
}
</script>

</body>
</html>
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.2526-prerelease" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.2584-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.2526-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2584-prerelease" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2WpfBrowser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ found in the LICENSE file.
<!--TODO-->
</MenuItem>
<MenuItem Header="_Window">
<MenuItem Header="_Close WebView" Command="{x:Static local:MainWindow.CloseWebViewCommand}"/>
<MenuItem Header="_Close WebView" Command="ApplicationCommands.Close"/>
<MenuItem Header="_New WebView" Command="{x:Static local:MainWindow.NewWebViewCommand}"/>
<MenuItem Header="_New Window" Command="ApplicationCommands.New"/>
<MenuItem Header="_New Window With Options" Command="{x:Static local:MainWindow.NewWindowWithOptionsCommand}"/>
Expand Down
1 change: 1 addition & 0 deletions SampleApps/WebView2WpfBrowser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ void CloseCmdExecuted(object sender, ExecutedRoutedEventArgs e)
return;
}
}
webView.Dispose();
this.Close();
}

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.2526-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2584-prerelease" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>
Loading