interface ICoreWebView2EnvironmentOptions4
interface ICoreWebView2EnvironmentOptions4
: public IUnknown
Additional options used to create WebView2 Environment that manages custom scheme registration.
Summary
Members | Descriptions |
---|---|
GetCustomSchemeRegistrations | Array of custom scheme registrations. |
SetCustomSchemeRegistrations | Set the array of custom scheme registrations to be used. |
Applies to
Product | Introduced |
---|---|
WebView2 Win32 | 1.0.1587.40 |
WebView2 Win32 Prerelease | 1.0.1619 |
Members
GetCustomSchemeRegistrations
Array of custom scheme registrations.
public HRESULT GetCustomSchemeRegistrations(UINT32 * count, ICoreWebView2CustomSchemeRegistration *** schemeRegistrations)
The returned ICoreWebView2CustomSchemeRegistration pointers must be released, and the array itself must be deallocated with CoTaskMemFree.
SetCustomSchemeRegistrations
Set the array of custom scheme registrations to be used.
public HRESULT SetCustomSchemeRegistrations(UINT32 count, ICoreWebView2CustomSchemeRegistration ** schemeRegistrations)
Microsoft::WRL::ComPtr<ICoreWebView2EnvironmentOptions4> options4;
if (options.As(&options4) == S_OK)
{
const WCHAR* allowedOrigins[1] = {L"https://*.example.com"};
auto customSchemeRegistration =
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(L"custom-scheme");
customSchemeRegistration->SetAllowedOrigins(1, allowedOrigins);
auto customSchemeRegistration2 =
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(L"wv2rocks");
customSchemeRegistration2->put_TreatAsSecure(TRUE);
customSchemeRegistration2->SetAllowedOrigins(1, allowedOrigins);
customSchemeRegistration2->put_HasAuthorityComponent(TRUE);
auto customSchemeRegistration3 =
Microsoft::WRL::Make<CoreWebView2CustomSchemeRegistration>(
L"custom-scheme-not-in-allowed-origins");
ICoreWebView2CustomSchemeRegistration* registrations[3] = {
customSchemeRegistration.Get(), customSchemeRegistration2.Get(),
customSchemeRegistration3.Get()};
options4->SetCustomSchemeRegistrations(
2, static_cast<ICoreWebView2CustomSchemeRegistration**>(registrations));
}
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기