Skip to content

Commit 0300b06

Browse files
Updates for Win32, WPF, WinForms, UWP and WinUI3 sample apps from 140.0.3477.0
1 parent ff6beb5 commit 0300b06

File tree

6 files changed

+34
-47
lines changed

6 files changed

+34
-47
lines changed

SampleApps/WebView2APISample/AppWindow.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2317,7 +2317,8 @@ void AppWindow::RegisterEventHandlers()
23172317
}
23182318
else
23192319
{
2320-
newAppWindow = new AppWindow(m_creationModeId, GetWebViewOption(), L"none");
2320+
newAppWindow = new AppWindow(
2321+
m_creationModeId, GetWebViewOption(), L"none", m_userDataFolder);
23212322
}
23222323
newAppWindow->m_isPopupWindow = true;
23232324
newAppWindow->m_onWebViewFirstInitialized = [args, deferral, newAppWindow]()

SampleApps/WebView2APISample/DropTarget.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
#include "DropTarget.h"
88
#include "ViewComponent.h"
99
#include <ShlGuid.h>
10-
#include <Shobjidl.h>
10+
#include <shobjidl.h>
1111

12-
DropTarget::DropTarget() : m_window(nullptr) {}
12+
DropTarget::DropTarget() : m_window(nullptr)
13+
{
14+
}
1315

1416
DropTarget::~DropTarget()
1517
{

SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ void ScenarioServiceWorkerManager::GetAllServiceWorkerRegistrations()
171171
HRESULT error, ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
172172
workerRegistrationCollection) -> HRESULT
173173
{
174+
CHECK_FAILURE(error);
174175
UINT32 workersCount = 0;
175176
CHECK_FAILURE(workerRegistrationCollection->get_Count(&workersCount));
176177

@@ -217,10 +218,11 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()
217218

218219
if (dialog.confirmed)
219220
{
221+
std::wstring scope = dialog.input.c_str();
220222
CHECK_FAILURE(m_serviceWorkerManager->GetServiceWorkerRegistrationsForScope(
221-
dialog.input.c_str(),
223+
scope.c_str(),
222224
Callback<ICoreWebView2ExperimentalGetServiceWorkerRegistrationsCompletedHandler>(
223-
[this](
225+
[this, scope](
224226
HRESULT error,
225227
ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
226228
workerRegistrationCollection) -> HRESULT
@@ -230,52 +232,34 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()
230232
CHECK_FAILURE(workerRegistrationCollection->get_Count(&workersCount));
231233

232234
std::wstringstream message{};
233-
message << L"Number of service workers registered for the given scope: "
234-
<< workersCount << std::endl;
235+
message << L"Number of service workers registered for the scope ("
236+
<< scope.c_str() << ") : " << workersCount << std::endl;
235237

236238
for (UINT32 i = 0; i < workersCount; i++)
237239
{
238-
Microsoft::WRL::ComPtr<
239-
ICoreWebView2ExperimentalServiceWorkerRegistration>
240+
ComPtr<ICoreWebView2ExperimentalServiceWorkerRegistration>
240241
serviceWorkerRegistration;
241242
CHECK_FAILURE(workerRegistrationCollection->GetValueAtIndex(
242243
i, &serviceWorkerRegistration));
243244

244-
wil::com_ptr<ICoreWebView2ExperimentalServiceWorker> serviceWorker;
245+
wil::unique_cotaskmem_string scopeUri;
246+
CHECK_FAILURE(serviceWorkerRegistration->get_ScopeUri(&scopeUri));
247+
248+
wil::unique_cotaskmem_string origin;
249+
CHECK_FAILURE(serviceWorkerRegistration->get_Origin(&origin));
250+
251+
wil::unique_cotaskmem_string topLevelOrigin;
245252
CHECK_FAILURE(
246-
serviceWorkerRegistration->get_ActiveServiceWorker(&serviceWorker));
247-
248-
if (serviceWorker)
249-
{
250-
// Log that the service worker is activated.
251-
}
252-
else
253-
{
254-
CHECK_FAILURE(serviceWorkerRegistration->add_ServiceWorkerActivated(
255-
Callback<
256-
ICoreWebView2ExperimentalServiceWorkerActivatedEventHandler>(
257-
[this](
258-
ICoreWebView2ExperimentalServiceWorkerRegistration*
259-
sender,
260-
ICoreWebView2ExperimentalServiceWorkerActivatedEventArgs*
261-
args) -> HRESULT
262-
{
263-
wil::com_ptr<ICoreWebView2ExperimentalServiceWorker>
264-
serviceWorker;
265-
CHECK_FAILURE(
266-
args->get_ActiveServiceWorker(&serviceWorker));
267-
268-
// Log that the service worker is activated.
269-
m_appWindow->AsyncMessageBox(
270-
L"Service worker is activated", L"Service worker");
271-
272-
return S_OK;
273-
})
274-
.Get(),
275-
nullptr));
276-
}
253+
serviceWorkerRegistration->get_TopLevelOrigin(&topLevelOrigin));
254+
255+
message << L"ScopeUri: " << scopeUri.get() << std::endl;
256+
message << L"Origin: " << origin.get() << std::endl;
257+
message << L"TopLevelOrigin: " << topLevelOrigin.get() << std::endl;
277258
}
278259

260+
m_appWindow->AsyncMessageBox(
261+
std::move(message.str()), L"Registered service workers for scope");
262+
279263
return S_OK;
280264
})
281265
.Get()));

SampleApps/WebView2APISample/WebView2APISample.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ BEGIN
312312
BEGIN
313313
MENUITEM "Listen to new Service Worker Registrations", IDM_SCENARIO_SERVICE_WORKER_REGISTRATION_REQUESTED
314314
MENUITEM "Get Service Worker Registrations", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTRATIONS
315-
MENUITEM "Get Service Worker registered for the Scope", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTERED_FOR_SCOPE
315+
MENUITEM "Get Service Worker Registrations for the Scope", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTERED_FOR_SCOPE
316316
MENUITEM "Web Messaging", IDM_SCENARIO_SERVICE_WORKER_POST_MESSAGE
317317
END
318318
POPUP "Dedicated Worker"

SampleApps/WebView2APISample/WebView2APISample.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
@@ -526,4 +526,4 @@
526526
<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'))" />
527527
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.3415-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.3415-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
528528
</Target>
529-
</Project>
529+
</Project>

SampleApps/WebView2APISample/targetver.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
#pragma once
66

7-
// Including SDKDDKVer.h defines the highest available Windows platform.
7+
// Including sdkddkver.h defines the highest available Windows platform.
88

99
// If you wish to build your application for a previous Windows platform,
1010
// include WinSDKVer.h and set the _WIN32_WINNT macro to the platform you wish
11-
// to support before including SDKDDKVer.h.
11+
// to support before including sdkddkver.h.
1212

13-
#include <SDKDDKVer.h>
13+
#include <sdkddkver.h>

0 commit comments

Comments
 (0)