Skip to content

Commit

Permalink
Move projects to use latest WebView2 SDK 1.0.674-prerelease (#58)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
peiche-jessica authored Oct 19, 2020
1 parent 2c0b66a commit b382e53
Show file tree
Hide file tree
Showing 35 changed files with 6,155 additions and 5,016 deletions.
428 changes: 214 additions & 214 deletions SampleApps/WebView2APISample/App.cpp

Large diffs are not rendered by default.

109 changes: 109 additions & 0 deletions SampleApps/WebView2APISample/AppStartPage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// 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 <algorithm>
#include <pathcch.h>
#include <Psapi.h>

#include "AppStartPage.h"
#include "AppWindow.h"
#include "CheckFailure.h"

using namespace Microsoft::WRL;

namespace AppStartPage
{

bool AreFileUrisEqual(std::wstring leftUri, std::wstring rightUri)
{
// Have to to lower due to current bug
std::transform(leftUri.begin(), leftUri.end(),
leftUri.begin(), ::tolower);
std::transform(rightUri.begin(), rightUri.end(),
rightUri.begin(), ::tolower);

return leftUri == rightUri;
}

std::wstring ResolvePathAndTrimFile(std::wstring path)
{
wchar_t resultPath[MAX_PATH];
PathCchCanonicalize(resultPath, ARRAYSIZE(resultPath), path.c_str());
PathCchRemoveFileSpec(resultPath, ARRAYSIZE(resultPath));
return resultPath;
}

std::wstring GetSdkBuild()
{
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
wil::unique_cotaskmem_string targetVersion;
CHECK_FAILURE(options->get_TargetCompatibleBrowserVersion(&targetVersion));

// The full version string A.B.C.D
const wchar_t* targetVersionMajorAndRest = targetVersion.get();
// Should now be .B.C.D
const wchar_t* targetVersionMinorAndRest = wcschr(targetVersionMajorAndRest, L'.');
CHECK_FAILURE((targetVersionMinorAndRest != nullptr && *targetVersionMinorAndRest == L'.') ? S_OK : E_UNEXPECTED);

// Should now be .C.D
const wchar_t* targetVersionBuildAndRest = wcschr(targetVersionMinorAndRest + 1, L'.');
CHECK_FAILURE((targetVersionBuildAndRest != nullptr && *targetVersionBuildAndRest == L'.') ? S_OK : E_UNEXPECTED);

// Return + 1 to skip the first . so just C.D
return targetVersionBuildAndRest + 1;
}

std::wstring GetRuntimeVersion(AppWindow* appWindow)
{
wil::com_ptr<ICoreWebView2Environment> environment = appWindow->GetWebViewEnvironment();
wil::unique_cotaskmem_string runtimeVersion;
CHECK_FAILURE(environment->get_BrowserVersionString(&runtimeVersion));

return runtimeVersion.get();
}

std::wstring GetAppPath()
{
wchar_t appPath[MAX_PATH];
GetModuleFileName(nullptr, appPath, ARRAYSIZE(appPath));
return ResolvePathAndTrimFile(appPath);
}

std::wstring GetRuntimePath(AppWindow* appWindow)
{
wil::com_ptr<ICoreWebView2> webview = appWindow->GetWebView();
UINT32 browserProcessId = 0;
wchar_t runtimePath[MAX_PATH];
CHECK_FAILURE(webview->get_BrowserProcessId(&browserProcessId));

HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, browserProcessId);
CHECK_FAILURE(processHandle == nullptr ? E_FAIL : S_OK);
GetModuleFileNameEx(processHandle, nullptr, runtimePath, ARRAYSIZE(runtimePath));
CloseHandle(processHandle);

return ResolvePathAndTrimFile(runtimePath);
}

std::wstring GetUri(AppWindow* appWindow)
{
std::wstring uri = appWindow->GetLocalUri(L"AppStartPage.html");

uri += L"?sdkBuild=";
uri += GetSdkBuild();

uri += L"&runtimeVersion=";
uri += GetRuntimeVersion(appWindow);

uri += L"&appPath=";
uri += GetAppPath();

uri += L"&runtimePath=";
uri += GetRuntimePath(appWindow);

return uri;
}

}; // namespace AppStartPage
15 changes: 15 additions & 0 deletions SampleApps/WebView2APISample/AppStartPage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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>

class AppWindow;

namespace AppStartPage
{
std::wstring GetUri(AppWindow* appWindow);
};
153 changes: 153 additions & 0 deletions SampleApps/WebView2APISample/AppStartPage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<!DOCTYPE html>
<html class="sans-serif-font borderless fill logo-background border-box-model center-parent">
<head>
<meta charset="UTF-8">
<title>Microsoft Edge WebView2</title>
<style>
.sans-serif-font {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.logo-background {
background: url("AppStartPageBackground.png") no-repeat center fixed;
background-color: #e0e0e0;
background-size: cover;
}

.border-box-model {
box-sizing: border-box;
}

.fill, .container > div {
width: 100%;
height: 100%;
}

.mostly-fill {
width: calc(100% - 200px);
height: calc(100% - 200px);
}

.borderless, h1, h2 {
border: 0;
margin: 0;
padding: 0;
}

.center-parent, .container > div {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.acrylic-background, .container > div {
backdrop-filter: blur(20px) saturate(125%);
background-color: rgba(255, 255, 255, 0.3);
}

.center {
text-align: center;
vertical-align: middle;
}

@media only screen
and (min-width : 1001px) {
.container {
display: grid;
grid-template-areas:
'header header header'
'box1 box1 box2'
'box3 box4 box5'
'box6 . .';
grid-gap: 20px;
}
}

@media only screen
and (max-width : 1000px) {
.container {
display: grid;
grid-template-areas:
'header header '
'box1 box1'
'box2 box3'
'box4 box5'
'box6 . ';
grid-gap: 20px;
}
}

.header { grid-area: header; }
.box1 { grid-area: box1; }
.box2 { grid-area: box2; }
.box3 { grid-area: box3; }
.box4 { grid-area: box4; }
.box5 { grid-area: box5; }
.box6 { grid-area: box6; }
</style>
</head>
<body class="mostly-fill container borderless">
<div class="header">
<h1 class="center">Microsoft Edge WebView2</h1>
</div>

<div class="box1">
<div>
<dl>
<dt>SDK build</dt><dd id="sdkBuild">...</dd>
<dt>Runtime version</dt><dd id="runtimeVersion">...</dd>
<dt>App path</dt><dd id="appPath">...</dd>
<dt>Runtime path</dt><dd id="runtimePath">...</dd>
</dl>
</div>
</div>

<div class="box2">
<div>
<h2>Issues</h2>
<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>
<a href="https://github.com/MicrosoftEdge/WebViewFeedback/issues/new/choose">New issue</a>
</div>
</div>

<div class="box3">
<div>
<h2>Documentation</h2>
<form action="https://docs.microsoft.com/search/"><label>Query <input type="text" name="terms" value="WebView2 "/><button>Search</button></label></form>
<a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 documentation</a>
</div>
</div>

<div class="box4">
<div>
<h2>SDK releases</h2>
<ul id="sdkReleases">
</ul>
</div>
</div>

<div class="box5">
<div>
<h2>Runtime</h2>
<ul>
<li><a href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 Runtime</a></li>
<li><a href="https://developer.microsoft.com/en-us/microsoft-edge/webview2/">WebView2 Fixed Version Runtime</a></li>
</ul>
</div>
</div>

<div class="box6">
<div>
<h2>Release Notes</h2>
<ul>
<li><a href="https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes">WebView2 SDK</a></li>
<li><a href="https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnote-stable-channel">Edge Stable channel</a></li>
<li><a href="https://docs.microsoft.com/en-us/deployedge/microsoft-edge-relnote-beta-channel">Edge Beta channel</a></li>
</ul>
</div>
</div>

<script src="AppStartPage.js"></script>
</body>
</html>
56 changes: 56 additions & 0 deletions SampleApps/WebView2APISample/AppStartPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(async function () {
async function uriToObject(uri) {
const responseFromFetch = await fetch(uri);
const responseAsText = await responseFromFetch.text();
const response = JSON.parse(responseAsText);
return response;
}

function parseQuery(query) {
if (query.startsWith("?")) {
query = query.substring(1);
}

return query.
split("&").
map(encodedNameValueStr => encodedNameValueStr.split("=")).
reduce((resultObject, encodedNameValueArr) => {
const nameValueArr = encodedNameValueArr.map(decodeURIComponent);
resultObject[nameValueArr[0]] = nameValueArr[1];
return resultObject;
}, {});
}

const sdkReleasesNode = document.getElementById("sdkReleases");
if (sdkReleasesNode) {
const nugetInfoUri = "https://azuresearch-usnc.nuget.org/query?q=PackageID%3aMicrosoft.Web.WebView2&prerelease=true&semVerLevel=2.0.0";
const nugetInfo = await uriToObject(nugetInfoUri);

let versions = nugetInfo.data[0].versions;
versions.reverse();
versions.forEach(version => {
const versionText = version.version;
const aNode = document.createElement("a");
aNode.href = "https://www.nuget.org/packages/Microsoft.Web.WebView2/" + versionText;
aNode.textContent = "WebView2 SDK " + versionText;

const itemNode = document.createElement("li");
itemNode.appendChild(aNode);

sdkReleasesNode.appendChild(itemNode);
});
}

const query = parseQuery(location.search);
const fillIds = ["sdkBuild", "runtimeVersion", "appPath", "runtimePath"];
fillIds.forEach(id => {
let content = query[id];
if (content) {
const maxContentLength = 100;
if (content.length > maxContentLength) {
content = "..." + content.substring(content.length - maxContentLength);
}
document.getElementById(id).textContent = content;
}
})
})();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b382e53

Please sign in to comment.