diff --git a/SampleApps/WebView2APISample/AppWindow.cpp b/SampleApps/WebView2APISample/AppWindow.cpp index 2c998e1a..6d700b4b 100644 --- a/SampleApps/WebView2APISample/AppWindow.cpp +++ b/SampleApps/WebView2APISample/AppWindow.cpp @@ -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]() diff --git a/SampleApps/WebView2APISample/DropTarget.cpp b/SampleApps/WebView2APISample/DropTarget.cpp index 9ad1dc17..d9982f50 100644 --- a/SampleApps/WebView2APISample/DropTarget.cpp +++ b/SampleApps/WebView2APISample/DropTarget.cpp @@ -7,9 +7,11 @@ #include "DropTarget.h" #include "ViewComponent.h" #include -#include +#include -DropTarget::DropTarget() : m_window(nullptr) {} +DropTarget::DropTarget() : m_window(nullptr) +{ +} DropTarget::~DropTarget() { diff --git a/SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp b/SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp index 8df4726f..e738d51d 100644 --- a/SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp +++ b/SampleApps/WebView2APISample/ScenarioServiceWorkerManager.cpp @@ -171,6 +171,7 @@ void ScenarioServiceWorkerManager::GetAllServiceWorkerRegistrations() HRESULT error, ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView* workerRegistrationCollection) -> HRESULT { + CHECK_FAILURE(error); UINT32 workersCount = 0; CHECK_FAILURE(workerRegistrationCollection->get_Count(&workersCount)); @@ -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( - [this]( + [this, scope]( HRESULT error, ICoreWebView2ExperimentalServiceWorkerRegistrationCollectionView* workerRegistrationCollection) -> HRESULT @@ -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 serviceWorkerRegistration; CHECK_FAILURE(workerRegistrationCollection->GetValueAtIndex( i, &serviceWorkerRegistration)); - wil::com_ptr 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 - 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())); diff --git a/SampleApps/WebView2APISample/WebView2APISample.rc b/SampleApps/WebView2APISample/WebView2APISample.rc index 399acbe8..410c3a4c 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.rc +++ b/SampleApps/WebView2APISample/WebView2APISample.rc @@ -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" diff --git a/SampleApps/WebView2APISample/WebView2APISample.vcxproj b/SampleApps/WebView2APISample/WebView2APISample.vcxproj index 0e916d67..658c3f8c 100644 --- a/SampleApps/WebView2APISample/WebView2APISample.vcxproj +++ b/SampleApps/WebView2APISample/WebView2APISample.vcxproj @@ -517,13 +517,13 @@ - + 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}. - + diff --git a/SampleApps/WebView2APISample/packages.config b/SampleApps/WebView2APISample/packages.config index c8fcd36b..c1257901 100644 --- a/SampleApps/WebView2APISample/packages.config +++ b/SampleApps/WebView2APISample/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file diff --git a/SampleApps/WebView2APISample/targetver.h b/SampleApps/WebView2APISample/targetver.h index 1048c990..6870b268 100644 --- a/SampleApps/WebView2APISample/targetver.h +++ b/SampleApps/WebView2APISample/targetver.h @@ -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 +#include diff --git a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj index c5af8394..929be190 100644 --- a/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj +++ b/SampleApps/WebView2WindowsFormsBrowser/WebView2WindowsFormsBrowser.csproj @@ -25,7 +25,7 @@ AnyCPU - + diff --git a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj index 22cf026b..ccd0efc6 100644 --- a/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj +++ b/SampleApps/WebView2WpfBrowser/WebView2WpfBrowser.csproj @@ -61,7 +61,7 @@ - +