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
32 changes: 31 additions & 1 deletion SampleApps/WebView2APISample/AppWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "ScenarioSharedWorkerManager.h"
#include "ScenarioSaveAs.h"
#include "ScenarioScreenCapture.h"
#include "ScenarioSensitivityLabel.h"
#include "ScenarioSharedBuffer.h"
#include "ScenarioSharedWorkerWRR.h"
#include "ScenarioThrottlingControl.h"
Expand Down Expand Up @@ -630,6 +631,30 @@ bool AppWindow::ExecuteWebViewCommands(WPARAM wParam, LPARAM lParam)
NewComponent<ScenarioNotificationReceived>(this);
return true;
}
case IDM_SCENARIO_PIRM_SET_ALLOWLIST:
{
auto sensitivityLabelComponent = GetOrCreateComponent<ScenarioSensitivityLabel>();
sensitivityLabelComponent->SetPageRestrictionManagerAllowlist();
return true;
}
case IDM_SCENARIO_PIRM_CHECK_AVAILABILITY:
{
auto sensitivityLabelComponent = GetOrCreateComponent<ScenarioSensitivityLabel>();
sensitivityLabelComponent->CheckPageRestrictionManagerAvailability();
return true;
}
case IDM_SCENARIO_SENSITIVITY_LABEL_START_TEST:
{
auto sensitivityLabelComponent = GetOrCreateComponent<ScenarioSensitivityLabel>();
sensitivityLabelComponent->LaunchLabelDemoPage();
return true;
}
case IDM_SCENARIO_SENSITIVITY_LABEL_TOGGLE_EVENTS:
{
auto sensitivityLabelComponent = GetOrCreateComponent<ScenarioSensitivityLabel>();
sensitivityLabelComponent->ToggleEventListener();
return true;
}
case IDM_SCENARIO_TESTING_FOCUS:
{
WCHAR testingFocusPath[] = L"ScenarioTestingFocus.html";
Expand Down Expand Up @@ -1740,7 +1765,12 @@ void AppWindow::InitializeWebView()
//! [CreateCoreWebView2EnvironmentWithOptions]

std::wstring args;
args.append(L"--enable-features=ThirdPartyStoragePartitioning,PartitionedCookies");
// Page Interaction Restriction Manager requires msPageInteractionManagerWebview2 to be
// enabled from the args, as by default it's disabled in the browser. If you want to
// test these scenarios, this flag should be enabled.
args.append(
L"--enable-features=ThirdPartyStoragePartitioning,PartitionedCookies,"
L"msPageInteractionManagerWebview2");
auto options = Microsoft::WRL::Make<CoreWebView2EnvironmentOptions>();
options->put_AdditionalBrowserArguments(args.c_str());
CHECK_FAILURE(
Expand Down
13 changes: 13 additions & 0 deletions SampleApps/WebView2APISample/AppWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class AppWindow

template <class ComponentType> ComponentType* GetComponent();

template <class ComponentType> ComponentType* GetOrCreateComponent();

void DeleteComponent(ComponentBase* scenario);

// Runs a function by posting it to the event loop. Use this to do things
Expand Down Expand Up @@ -329,3 +331,14 @@ template <class ComponentType> ComponentType* AppWindow::GetComponent()
}
return nullptr;
}

template <class ComponentType> ComponentType* AppWindow::GetOrCreateComponent()
{
auto component = GetComponent<ComponentType>();
if (!component)
{
NewComponent<ComponentType>(this);
component = GetComponent<ComponentType>();
}
return component;
}
Loading
Loading