Skip to content

Commit b382e53

Browse files
authored
Move projects to use latest WebView2 SDK 1.0.674-prerelease (#58)
* Updated testing instructions and added missing images * Move win32 sample to use latest WebView2 prerelease SDK 0.9.579 * Move wpf sample to use latest WebView2 prerelease SDK 0.9.579 * Updated .gitignore * Move winforms sample to use latest WebView2 prerelease SDK 0.9.579 * Added VSCode debugging setup * Added screenshots that should be included in the previous commit * Improved script debugging attach and removed targeted * Moved WPF to use 0.9.579-prerelease * Improved testing instructions * Move projects to use latest WebView2 SDK 0.9.627-prerelease * Use 628 instead * Use 579 for testing purposes * Update package.config too * Added USE_WEBVIEW2_WIN10 * Revert "Update package.config too" This reverts commit 8df5be9. * Revert "Use 579 for testing purposes" This reverts commit 8b42389. * Link to latest docs * Move projects to use latest WebView2 SDK 1.0.672-prerelease * Move projects to use latest WebView2 SDK 1.0.674-prerelease
1 parent 2c0b66a commit b382e53

35 files changed

+6155
-5016
lines changed

SampleApps/WebView2APISample/App.cpp

Lines changed: 214 additions & 214 deletions
Large diffs are not rendered by default.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#include "stdafx.h"
6+
7+
#include <algorithm>
8+
#include <pathcch.h>
9+
#include <Psapi.h>
10+
11+
#include "AppStartPage.h"
12+
#include "AppWindow.h"
13+
#include "CheckFailure.h"
14+
15+
using namespace Microsoft::WRL;
16+
17+
namespace AppStartPage
18+
{
19+
20+
bool AreFileUrisEqual(std::wstring leftUri, std::wstring rightUri)
21+
{
22+
// Have to to lower due to current bug
23+
std::transform(leftUri.begin(), leftUri.end(),
24+
leftUri.begin(), ::tolower);
25+
std::transform(rightUri.begin(), rightUri.end(),
26+
rightUri.begin(), ::tolower);
27+
28+
return leftUri == rightUri;
29+
}
30+
31+
std::wstring ResolvePathAndTrimFile(std::wstring path)
32+
{
33+
wchar_t resultPath[MAX_PATH];
34+
PathCchCanonicalize(resultPath, ARRAYSIZE(resultPath), path.c_str());
35+
PathCchRemoveFileSpec(resultPath, ARRAYSIZE(resultPath));
36+
return resultPath;
37+
}
38+
39+
std::wstring GetSdkBuild()
40+
{
41+
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
42+
wil::unique_cotaskmem_string targetVersion;
43+
CHECK_FAILURE(options->get_TargetCompatibleBrowserVersion(&targetVersion));
44+
45+
// The full version string A.B.C.D
46+
const wchar_t* targetVersionMajorAndRest = targetVersion.get();
47+
// Should now be .B.C.D
48+
const wchar_t* targetVersionMinorAndRest = wcschr(targetVersionMajorAndRest, L'.');
49+
CHECK_FAILURE((targetVersionMinorAndRest != nullptr && *targetVersionMinorAndRest == L'.') ? S_OK : E_UNEXPECTED);
50+
51+
// Should now be .C.D
52+
const wchar_t* targetVersionBuildAndRest = wcschr(targetVersionMinorAndRest + 1, L'.');
53+
CHECK_FAILURE((targetVersionBuildAndRest != nullptr && *targetVersionBuildAndRest == L'.') ? S_OK : E_UNEXPECTED);
54+
55+
// Return + 1 to skip the first . so just C.D
56+
return targetVersionBuildAndRest + 1;
57+
}
58+
59+
std::wstring GetRuntimeVersion(AppWindow* appWindow)
60+
{
61+
wil::com_ptr<ICoreWebView2Environment> environment = appWindow->GetWebViewEnvironment();
62+
wil::unique_cotaskmem_string runtimeVersion;
63+
CHECK_FAILURE(environment->get_BrowserVersionString(&runtimeVersion));
64+
65+
return runtimeVersion.get();
66+
}
67+
68+
std::wstring GetAppPath()
69+
{
70+
wchar_t appPath[MAX_PATH];
71+
GetModuleFileName(nullptr, appPath, ARRAYSIZE(appPath));
72+
return ResolvePathAndTrimFile(appPath);
73+
}
74+
75+
std::wstring GetRuntimePath(AppWindow* appWindow)
76+
{
77+
wil::com_ptr<ICoreWebView2> webview = appWindow->GetWebView();
78+
UINT32 browserProcessId = 0;
79+
wchar_t runtimePath[MAX_PATH];
80+
CHECK_FAILURE(webview->get_BrowserProcessId(&browserProcessId));
81+
82+
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, browserProcessId);
83+
CHECK_FAILURE(processHandle == nullptr ? E_FAIL : S_OK);
84+
GetModuleFileNameEx(processHandle, nullptr, runtimePath, ARRAYSIZE(runtimePath));
85+
CloseHandle(processHandle);
86+
87+
return ResolvePathAndTrimFile(runtimePath);
88+
}
89+
90+
std::wstring GetUri(AppWindow* appWindow)
91+
{
92+
std::wstring uri = appWindow->GetLocalUri(L"AppStartPage.html");
93+
94+
uri += L"?sdkBuild=";
95+
uri += GetSdkBuild();
96+
97+
uri += L"&runtimeVersion=";
98+
uri += GetRuntimeVersion(appWindow);
99+
100+
uri += L"&appPath=";
101+
uri += GetAppPath();
102+
103+
uri += L"&runtimePath=";
104+
uri += GetRuntimePath(appWindow);
105+
106+
return uri;
107+
}
108+
109+
}; // namespace AppStartPage
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) Microsoft Corporation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#pragma once
6+
7+
#include "stdafx.h"
8+
#include <string>
9+
10+
class AppWindow;
11+
12+
namespace AppStartPage
13+
{
14+
std::wstring GetUri(AppWindow* appWindow);
15+
};
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<!DOCTYPE html>
2+
<html class="sans-serif-font borderless fill logo-background border-box-model center-parent">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Microsoft Edge WebView2</title>
6+
<style>
7+
.sans-serif-font {
8+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
9+
}
10+
11+
.logo-background {
12+
background: url("AppStartPageBackground.png") no-repeat center fixed;
13+
background-color: #e0e0e0;
14+
background-size: cover;
15+
}
16+
17+
.border-box-model {
18+
box-sizing: border-box;
19+
}
20+
21+
.fill, .container > div {
22+
width: 100%;
23+
height: 100%;
24+
}
25+
26+
.mostly-fill {
27+
width: calc(100% - 200px);
28+
height: calc(100% - 200px);
29+
}
30+
31+
.borderless, h1, h2 {
32+
border: 0;
33+
margin: 0;
34+
padding: 0;
35+
}
36+
37+
.center-parent, .container > div {
38+
display: flex;
39+
flex-direction: column;
40+
justify-content: center;
41+
align-items: center;
42+
}
43+
44+
.acrylic-background, .container > div {
45+
backdrop-filter: blur(20px) saturate(125%);
46+
background-color: rgba(255, 255, 255, 0.3);
47+
}
48+
49+
.center {
50+
text-align: center;
51+
vertical-align: middle;
52+
}
53+
54+
@media only screen
55+
and (min-width : 1001px) {
56+
.container {
57+
display: grid;
58+
grid-template-areas:
59+
'header header header'
60+
'box1 box1 box2'
61+
'box3 box4 box5'
62+
'box6 . .';
63+
grid-gap: 20px;
64+
}
65+
}
66+
67+
@media only screen
68+
and (max-width : 1000px) {
69+
.container {
70+
display: grid;
71+
grid-template-areas:
72+
'header header '
73+
'box1 box1'
74+
'box2 box3'
75+
'box4 box5'
76+
'box6 . ';
77+
grid-gap: 20px;
78+
}
79+
}
80+
81+
.header { grid-area: header; }
82+
.box1 { grid-area: box1; }
83+
.box2 { grid-area: box2; }
84+
.box3 { grid-area: box3; }
85+
.box4 { grid-area: box4; }
86+
.box5 { grid-area: box5; }
87+
.box6 { grid-area: box6; }
88+
</style>
89+
</head>
90+
<body class="mostly-fill container borderless">
91+
<div class="header">
92+
<h1 class="center">Microsoft Edge WebView2</h1>
93+
</div>
94+
95+
<div class="box1">
96+
<div>
97+
<dl>
98+
<dt>SDK build</dt><dd id="sdkBuild">...</dd>
99+
<dt>Runtime version</dt><dd id="runtimeVersion">...</dd>
100+
<dt>App path</dt><dd id="appPath">...</dd>
101+
<dt>Runtime path</dt><dd id="runtimePath">...</dd>
102+
</dl>
103+
</div>
104+
</div>
105+
106+
<div class="box2">
107+
<div>
108+
<h2>Issues</h2>
109+
<form action="https://github.com/MicrosoftEdge/WebViewFeedback/issues"><label>Query </label><input type="text" name="q" value="is:issue is:open "/></label><button>Search</button></form>
110+
<a href="https://github.com/MicrosoftEdge/WebViewFeedback/issues/new/choose">New issue</a>
111+
</div>
112+
</div>
113+
114+
<div class="box3">
115+
<div>
116+
<h2>Documentation</h2>
117+
<form action="https://docs.microsoft.com/search/"><label>Query <input type="text" name="terms" value="WebView2 "/><button>Search</button></label></form>
118+
<a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 documentation</a>
119+
</div>
120+
</div>
121+
122+
<div class="box4">
123+
<div>
124+
<h2>SDK releases</h2>
125+
<ul id="sdkReleases">
126+
</ul>
127+
</div>
128+
</div>
129+
130+
<div class="box5">
131+
<div>
132+
<h2>Runtime</h2>
133+
<ul>
134+
<li><a href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 Runtime</a></li>
135+
<li><a href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 Fixed Version Runtime</a></li>
136+
</ul>
137+
</div>
138+
</div>
139+
140+
<div class="box6">
141+
<div>
142+
<h2>Release Notes</h2>
143+
<ul>
144+
<li><a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes">WebView2 SDK</a></li>
145+
<li><a href="https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnote-stable-channel">Edge Stable channel</a></li>
146+
<li><a href="https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnote-beta-channel">Edge Beta channel</a></li>
147+
</ul>
148+
</div>
149+
</div>
150+
151+
<script src="AppStartPage.js"></script>
152+
</body>
153+
</html>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
(async function () {
2+
async function uriToObject(uri) {
3+
const responseFromFetch = await fetch(uri);
4+
const responseAsText = await responseFromFetch.text();
5+
const response = JSON.parse(responseAsText);
6+
return response;
7+
}
8+
9+
function parseQuery(query) {
10+
if (query.startsWith("?")) {
11+
query = query.substring(1);
12+
}
13+
14+
return query.
15+
split("&").
16+
map(encodedNameValueStr => encodedNameValueStr.split("=")).
17+
reduce((resultObject, encodedNameValueArr) => {
18+
const nameValueArr = encodedNameValueArr.map(decodeURIComponent);
19+
resultObject[nameValueArr[0]] = nameValueArr[1];
20+
return resultObject;
21+
}, {});
22+
}
23+
24+
const sdkReleasesNode = document.getElementById("sdkReleases");
25+
if (sdkReleasesNode) {
26+
const nugetInfoUri = "https://azuresearch-usnc.nuget.org/query?q=PackageID%3aMicrosoft.Web.WebView2&prerelease=true&semVerLevel=2.0.0";
27+
const nugetInfo = await uriToObject(nugetInfoUri);
28+
29+
let versions = nugetInfo.data[0].versions;
30+
versions.reverse();
31+
versions.forEach(version => {
32+
const versionText = version.version;
33+
const aNode = document.createElement("a");
34+
aNode.href = "https://www.nuget.org/packages/Microsoft.Web.WebView2/" + versionText;
35+
aNode.textContent = "WebView2 SDK " + versionText;
36+
37+
const itemNode = document.createElement("li");
38+
itemNode.appendChild(aNode);
39+
40+
sdkReleasesNode.appendChild(itemNode);
41+
});
42+
}
43+
44+
const query = parseQuery(location.search);
45+
const fillIds = ["sdkBuild", "runtimeVersion", "appPath", "runtimePath"];
46+
fillIds.forEach(id => {
47+
let content = query[id];
48+
if (content) {
49+
const maxContentLength = 100;
50+
if (content.length > maxContentLength) {
51+
content = "..." + content.substring(content.length - maxContentLength);
52+
}
53+
document.getElementById(id).textContent = content;
54+
}
55+
})
56+
})();
Loading

0 commit comments

Comments
 (0)