Skip to content

Commit 9d8e170

Browse files
authored
Fix some syntax error in sample code
1 parent cfc01c2 commit 9d8e170

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

specs/AdditionalAllowedFrameAncestors.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ const std::wstring siteToEmbed = L"https://www.microsoft.com/";
2929
bool AreSitesSame(PCWSTR url1, PCWSTR url2)
3030
{
3131
wil::com_ptr<IUri> uri1;
32-
CHECK_FAILURE(CreateUri(url1.c_str(), Uri_CREATE_CANONICALIZE, 0, &uri1));
33-
DWORD scheme1 = URL_SCHEME_INVALID;
32+
CHECK_FAILURE(CreateUri(url1, Uri_CREATE_CANONICALIZE, 0, &uri1));
33+
DWORD scheme1 = -1;
3434
DWORD port1 = 0;
3535
wil::unique_bstr host1;
3636
CHECK_FAILURE(uri1->GetScheme(&scheme1));
3737
CHECK_FAILURE(uri1->GetHost(&host1));
3838
CHECK_FAILURE(uri1->GetPort(&port1));
3939
wil::com_ptr<IUri> uri2;
40-
CHECK_FAILURE(CreateUri(url2.c_str(), Uri_CREATE_CANONICALIZE, 0, &uri2));
41-
DWORD scheme2 = URL_SCHEME_INVALID;
40+
CHECK_FAILURE(CreateUri(url2, Uri_CREATE_CANONICALIZE, 0, &uri2));
41+
DWORD scheme2 = -1;
4242
DWORD port2 = 0;
4343
wil::unique_bstr host2;
4444
CHECK_FAILURE(uri2->GetScheme(&scheme2));
@@ -50,13 +50,13 @@ bool AreSitesSame(PCWSTR url1, PCWSTR url2)
5050
// App specific logic to decide whether the page is fully trusted.
5151
bool IsAppContentUri(PCWSTR pageUrl)
5252
{
53-
return AreSitesSame(pageUrl, myTrustedSite);
53+
return AreSitesSame(pageUrl, myTrustedSite.c_str());
5454
}
5555

5656
// App specific logic to decide whether a site is the one it wants to embed.
5757
bool IsTargetSite(PCWSTR siteUrl)
5858
{
59-
return AreSitesSame(siteUrl, siteToEmbed);
59+
return AreSitesSame(siteUrl, siteToEmbed.c_str());
6060
}
6161

6262
void MyApp::HandleEmbeddedSites()
@@ -125,10 +125,12 @@ void MyApp::HandleEmbeddedSites()
125125
ICoreWebView2NavigationStartingEventArgs2>
126126
navigationStartArgs;
127127
if (SUCCEEDED(args->QueryInterface(
128-
IID_PPV_ARGS(&navigationStartArgs)))
129-
navigationStartArgs
128+
IID_PPV_ARGS(&navigationStartArgs))))
129+
{
130+
navigationStartArgs
130131
->put_AdditionalAllowedFrameAncestors(
131-
myTrustedSite);
132+
myTrustedSite.c_str());
133+
}
132134
}
133135
}
134136
return S_OK;
@@ -205,16 +207,16 @@ interface ICoreWebView2NavigationStartingEventArgs_2 : ICoreWebView2NavigationSt
205207
/// Get additional allowed frame ancestors set by the app.
206208
[propget] HRESULT AdditionalAllowedFrameAncestors([out, retval] LPWSTR* value);
207209
208-
/// The app may set this property to allow a frame to be embedded by certain additional ancestors besides what is allowed by
210+
/// The app may set this property to allow a frame to be embedded by additional ancestors besides what is allowed by
209211
/// http header [X-Frame-Options](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options)
210212
/// and [Content-Security-Policy frame-ancestors directive](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors).
211213
/// If set, a frame ancestor is allowed if it is allowed by the additional allowed frame
212214
/// ancestoers or original http header from the site.
213215
/// Whether an ancestor is allowed by the additional allowed frame ancestoers is done the same way as if the site provided
214216
/// it as the source list of the Content-Security-Policy frame-ancestors directive.
215217
/// For example, if `https://example.com` and `https://www.example.com` are the origins of the top
216-
/// page and intemediate iframes that embed a nested site embedding iframe, and you fully trust
217-
/// those origins, you should set thus property to `https://example.com https://www.example.com`.
218+
/// page and intemediate iframes that embed a nested site-embedding iframe, and you fully trust
219+
/// those origins, you should set this property to `https://example.com https://www.example.com`.
218220
/// This property gives the app the ability to use iframe to embed sites that otherwise
219221
/// could not be embedded in an iframe in trusted app pages.
220222
/// This could potentially subject the embedded sites to [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking)

0 commit comments

Comments
 (0)