Skip to content

Commit 37fb557

Browse files
authored
Update AdditionalAllowedFrameAncestors.md
1 parent 5a0f451 commit 37fb557

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

specs/AdditionalAllowedFrameAncestors.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ void MyApp::HandleHostedSites()
9898
})
9999
.Get(),
100100
nullptr));
101+
// Using FrameNavigationStarting event instead of NavigationStarting event of CoreWebViewFrame
102+
// to cover all possible nested iframes inside the hosted site as CoreWebViewFrame
103+
// object currently only support first level iframes in the top page.
101104
CHECK_FAILURE(m_webview->add_FrameNavigationStarting(
102105
Microsoft::WRL::Callback<ICoreWebView2NavigationStartingEventHandler>(
103106
[this](
@@ -164,13 +167,21 @@ void MyApp::HandleHostedSites()
164167
m_hostingSite = false;
165168
}
166169
170+
// Using FrameNavigationStarting event instead of NavigationStarting event of CoreWebViewFrame
171+
// to cover all possible nested iframes inside the hosted site as CoreWebViewFrame
172+
// object currently only support first level iframes in the top page.
167173
private void CoreWebView2_FrameNavigationStarting(CoreWebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs args)
168174
{
169175
if (IsTargetSite(args.Uri))
170176
{
171177
args.AdditionalAllowedFrameAncestors = myTrustedSite;
172178
}
173179
}
180+
private void HandleHostedSites()
181+
{
182+
webView.FrameCreated += CoreWebView2_FrameCreated;
183+
webView.FrameNavigationStarting += CoreWebView2_FrameNavigationStarting;
184+
}
174185
```
175186

176187
# API Details

0 commit comments

Comments
 (0)