Skip to content
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 @@ -2317,7 +2317,8 @@ void AppWindow::RegisterEventHandlers()
}
else
{
newAppWindow = new AppWindow(m_creationModeId, GetWebViewOption(), L"none");
newAppWindow = new AppWindow(
m_creationModeId, GetWebViewOption(), L"none", m_userDataFolder);
}
newAppWindow->m_isPopupWindow = true;
newAppWindow->m_onWebViewFirstInitialized = [args, deferral, newAppWindow]()
Expand Down
6 changes: 4 additions & 2 deletions SampleApps/WebView2APISample/DropTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
#include "DropTarget.h"
#include "ViewComponent.h"
#include <ShlGuid.h>
#include <Shobjidl.h>
#include <shobjidl.h>

DropTarget::DropTarget() : m_window(nullptr) {}
DropTarget::DropTarget() : m_window(nullptr)
{
}

DropTarget::~DropTarget()
{
Expand Down
60 changes: 22 additions & 38 deletions SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ void ScenarioServiceWorkerManager::GetAllServiceWorkerRegistrations()
HRESULT error, ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
workerRegistrationCollection) -> HRESULT
{
CHECK_FAILURE(error);
UINT32 workersCount = 0;
CHECK_FAILURE(workerRegistrationCollection->get_Count(&workersCount));

Expand Down Expand Up @@ -217,10 +218,11 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()

if (dialog.confirmed)
{
std::wstring scope = dialog.input.c_str();
CHECK_FAILURE(m_serviceWorkerManager->GetServiceWorkerRegistrationsForScope(
dialog.input.c_str(),
scope.c_str(),
Callback<ICoreWebView2ExperimentalGetServiceWorkerRegistrationsCompletedHandler>(
[this](
[this, scope](
HRESULT error,
ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView*
workerRegistrationCollection) -> HRESULT
Expand All @@ -230,52 +232,34 @@ void ScenarioServiceWorkerManager::GetServiceWorkerRegisteredForScope()
CHECK_FAILURE(workerRegistrationCollection->get_Count(&workersCount));

std::wstringstream message{};
message << L"Number of service workers registered for the given scope: "
<< workersCount << std::endl;
message << L"Number of service workers registered for the scope ("
<< scope.c_str() << ") : " << workersCount << std::endl;

for (UINT32 i = 0; i < workersCount; i++)
{
Microsoft::WRL::ComPtr<
ICoreWebView2ExperimentalServiceWorkerRegistration>
ComPtr<ICoreWebView2ExperimentalServiceWorkerRegistration>
serviceWorkerRegistration;
CHECK_FAILURE(workerRegistrationCollection->GetValueAtIndex(
i, &serviceWorkerRegistration));

wil::com_ptr<ICoreWebView2ExperimentalServiceWorker> serviceWorker;
wil::unique_cotaskmem_string scopeUri;
CHECK_FAILURE(serviceWorkerRegistration->get_ScopeUri(&scopeUri));

wil::unique_cotaskmem_string origin;
CHECK_FAILURE(serviceWorkerRegistration->get_Origin(&origin));

wil::unique_cotaskmem_string topLevelOrigin;
CHECK_FAILURE(
serviceWorkerRegistration->get_ActiveServiceWorker(&serviceWorker));

if (serviceWorker)
{
// Log that the service worker is activated.
}
else
{
CHECK_FAILURE(serviceWorkerRegistration->add_ServiceWorkerActivated(
Callback<
ICoreWebView2ExperimentalServiceWorkerActivatedEventHandler>(
[this](
ICoreWebView2ExperimentalServiceWorkerRegistration*
sender,
ICoreWebView2ExperimentalServiceWorkerActivatedEventArgs*
args) -> HRESULT
{
wil::com_ptr<ICoreWebView2ExperimentalServiceWorker>
serviceWorker;
CHECK_FAILURE(
args->get_ActiveServiceWorker(&serviceWorker));

// Log that the service worker is activated.
m_appWindow->AsyncMessageBox(
L"Service worker is activated", L"Service worker");

return S_OK;
})
.Get(),
nullptr));
}
serviceWorkerRegistration->get_TopLevelOrigin(&topLevelOrigin));

message << L"ScopeUri: " << scopeUri.get() << std::endl;
message << L"Origin: " << origin.get() << std::endl;
message << L"TopLevelOrigin: " << topLevelOrigin.get() << std::endl;
}

m_appWindow->AsyncMessageBox(
std::move(message.str()), L"Registered service workers for scope");

return S_OK;
})
.Get()));
Expand Down
2 changes: 1 addition & 1 deletion SampleApps/WebView2APISample/WebView2APISample.rc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ BEGIN
BEGIN
MENUITEM "Listen to new Service Worker Registrations", IDM_SCENARIO_SERVICE_WORKER_REGISTRATION_REQUESTED
MENUITEM "Get Service Worker Registrations", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTRATIONS
MENUITEM "Get Service Worker registered for the Scope", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTERED_FOR_SCOPE
MENUITEM "Get Service Worker Registrations for the Scope", IDM_SCENARIO_GET_SERVICE_WORKER_REGISTERED_FOR_SCOPE
MENUITEM "Web Messaging", IDM_SCENARIO_SERVICE_WORKER_POST_MESSAGE
END
POPUP "Dedicated Worker"
Expand Down
4 changes: 2 additions & 2 deletions SampleApps/WebView2APISample/WebView2APISample.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,13 @@
<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.3415-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.3415-prerelease\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.3477-prerelease\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.3477-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.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'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.3477-prerelease\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.3477-prerelease\build\native\Microsoft.Web.WebView2.targets'))" />
</Target>
</Project>
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.3415-prerelease" targetFramework="native" />
<package id="Microsoft.Web.WebView2" version="1.0.3477-prerelease" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.220201.1" targetFramework="native" />
</packages>
6 changes: 3 additions & 3 deletions SampleApps/WebView2APISample/targetver.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

#pragma once

// Including SDKDDKVer.h defines the highest available Windows platform.
// Including sdkddkver.h defines the highest available Windows platform.

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

#include <SDKDDKVer.h>
#include <sdkddkver.h>
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.3415-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3477-prerelease" />
</ItemGroup>
<ItemGroup>
<Folder Include="assets\" />
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.3415-prerelease" />
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3477-prerelease" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>
</Project>
Loading