@@ -106,10 +106,11 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow)
106106 CHECK_FAILURE (args2->get_ExitCode (&exitCode));
107107
108108 std::wstringstream message;
109- message << L" Kind: " << ProcessFailedKindToString (kind) << L" \n "
110- << L" Reason: " << ProcessFailedReasonToString (reason) << L" \n "
111- << L" Exit code: " << std::to_wstring (exitCode) << L" \n "
112- << L" Process description: " << processDescription.get () << std::endl;
109+ message << L" Kind: " << ProcessFailedKindToString (kind) << L" \n "
110+ << L" Reason: " << ProcessFailedReasonToString (reason) << L" \n "
111+ << L" Exit code: " << exitCode << L" \n "
112+ << L" Process description: " << processDescription.get ()
113+ << std::endl;
113114 m_appWindow->AsyncMessageBox ( std::move (message.str ()), L" Child process failed" );
114115 }
115116 return S_OK;
@@ -176,8 +177,8 @@ bool ProcessComponent::HandleWindowMessage(
176177 case IDM_PERFORMANCE_INFO:
177178 PerformanceInfo ();
178179 return true ;
179- case IDM_PROCESS_FRAME_INFO :
180- ShowProcessFrameInfo ();
180+ case IDM_PROCESS_EXTENDED_INFO :
181+ ShowProcessExtendedInfo ();
181182 return true ;
182183 }
183184 }
@@ -206,7 +207,9 @@ std::wstring ProcessComponent::FrameKindToString(const COREWEBVIEW2_FRAME_KIND k
206207
207208 KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_MAIN_FRAME);
208209 KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_IFRAME);
209- KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_OTHER);
210+ KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_EMBED);
211+ KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_OBJECT);
212+ KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_UNKNOWN);
210213
211214#undef KIND_ENTRY
212215 }
@@ -220,16 +223,16 @@ void ProcessComponent::AppendFrameInfo(
220223 UINT32 frameId = 0 ;
221224 UINT32 parentFrameId = 0 ;
222225 UINT32 mainFrameId = 0 ;
223- UINT32 firstLevelFrameId = 0 ;
226+ UINT32 childFrameId = 0 ;
224227 std::wstring type = L" other child frame" ;
225228 wil::unique_cotaskmem_string nameRaw;
226229 wil::unique_cotaskmem_string sourceRaw;
227- COREWEBVIEW2_FRAME_KIND frameKind = COREWEBVIEW2_FRAME_KIND_OTHER ;
230+ COREWEBVIEW2_FRAME_KIND frameKind = COREWEBVIEW2_FRAME_KIND_UNKNOWN ;
228231
229232 CHECK_FAILURE (frameInfo->get_Name (&nameRaw));
230- std::wstring name = ((std::wstring)( nameRaw.get ())). empty () ? L" none" : nameRaw. get () ;
233+ std::wstring name = nameRaw.get ()[ 0 ] ? nameRaw. get () : L" none" ;
231234 CHECK_FAILURE (frameInfo->get_Source (&sourceRaw));
232- std::wstring source = ((std::wstring)( sourceRaw.get ())). empty () ? L" none" : sourceRaw. get () ;
235+ std::wstring source = sourceRaw.get ()[ 0 ] ? sourceRaw. get () : L" none" ;
233236
234237 wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
235238 CHECK_FAILURE (frameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
@@ -252,26 +255,24 @@ void ProcessComponent::AppendFrameInfo(
252255 CHECK_FAILURE (mainFrameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
253256 CHECK_FAILURE (frameInfoExperimental->get_FrameId (&mainFrameId));
254257
255- wil::com_ptr<ICoreWebView2FrameInfo> firstLevelFrameInfo =
256- GetAncestorFirstLevelFrameInfo (frameInfo);
257- if (firstLevelFrameInfo == frameInfo)
258+ wil::com_ptr<ICoreWebView2FrameInfo> childFrameInfo =
259+ GetAncestorMainFrameDirectChildFrameInfo (frameInfo);
260+ if (childFrameInfo == frameInfo)
258261 {
259262 type = L" first level frame" ;
260263 }
261- if (firstLevelFrameInfo )
264+ if (childFrameInfo )
262265 {
263- CHECK_FAILURE (
264- firstLevelFrameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
265- CHECK_FAILURE (frameInfoExperimental->get_FrameId (&firstLevelFrameId));
266+ CHECK_FAILURE (childFrameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
267+ CHECK_FAILURE (frameInfoExperimental->get_FrameId (&childFrameId));
266268 }
267269
268- result << L" {frame name:" << name << L" | frame Id:" << std::to_wstring (frameId)
269- << L" | parent frame Id:"
270+ result << L" {frame name:" << name << L" | frame Id:" << frameId << L" | parent frame Id:"
270271 << ((parentFrameId == 0 ) ? L" none" : std::to_wstring (parentFrameId))
271272 << L" | frame type:" << type << L" \n "
272- << L" | ancestor main frame Id:" << std::to_wstring ( mainFrameId)
273- << L" | ancestor first level frame Id:"
274- << ((firstLevelFrameId == 0 ) ? L" none" : std::to_wstring (firstLevelFrameId )) << L" \n "
273+ << L" | ancestor main frame Id:" << mainFrameId
274+ << L" | ancestor main frame's direct child frame Id:"
275+ << ((childFrameId == 0 ) ? L" none" : std::to_wstring (childFrameId )) << L" \n "
275276 << L" | frame kind:" << FrameKindToString (frameKind) << L" \n "
276277 << L" | frame source:" << source << L" }," << std::endl;
277278}
@@ -292,34 +293,46 @@ wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorMainFrameInfo(
292293 return mainFrameInfo;
293294}
294295
295- // Get the ancestor first level frameInfo.
296- // Return itself if it's a first level frameInfo.
297- wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorFirstLevelFrameInfo (
296+ // Get the frame's corresponding main frame's direct child frameInfo.
297+ // Example:
298+ // A (main frame/CoreWebView2)
299+ // | \
300+ // (frame) B C (frame)
301+ // | |
302+ // (frame) D E (frame)
303+ // |
304+ // F (frame)
305+ // C GetAncestorMainFrameDirectChildFrameInfo returns C.
306+ // D GetAncestorMainFrameDirectChildFrameInfo returns B.
307+ // F GetAncestorMainFrameDirectChildFrameInfo returns C.
308+ wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorMainFrameDirectChildFrameInfo (
298309 wil::com_ptr<ICoreWebView2FrameInfo> frameInfo)
299310{
300311 wil::com_ptr<ICoreWebView2FrameInfo> mainFrameInfo;
301- wil::com_ptr<ICoreWebView2FrameInfo> firstLevelFrameInfo ;
312+ wil::com_ptr<ICoreWebView2FrameInfo> childFrameInfo ;
302313 wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
303314 while (frameInfo)
304315 {
305- firstLevelFrameInfo = mainFrameInfo;
316+ childFrameInfo = mainFrameInfo;
306317 mainFrameInfo = frameInfo;
307318 CHECK_FAILURE (frameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
308319 CHECK_FAILURE (frameInfoExperimental->get_ParentFrameInfo (&frameInfo));
309320 }
310- return firstLevelFrameInfo ;
321+ return childFrameInfo ;
311322}
312323
313- void ProcessComponent::ShowProcessFrameInfo ()
324+ void ProcessComponent::ShowProcessExtendedInfo ()
314325{
315- auto environmentExperimental11 =
316- m_webViewEnvironment.try_query <ICoreWebView2ExperimentalEnvironment11 >();
317- if (environmentExperimental11 )
326+ auto environmentExperimental13 =
327+ m_webViewEnvironment.try_query <ICoreWebView2ExperimentalEnvironment13 >();
328+ if (environmentExperimental13 )
318329 {
319- // ! [GetProcessInfosWithDetails]
320- CHECK_FAILURE (environmentExperimental11->GetProcessInfosWithDetails (
321- Callback<ICoreWebView2ExperimentalGetProcessInfosWithDetailsCompletedHandler>(
322- [this ](HRESULT error, ICoreWebView2ProcessInfoCollection* processCollection)
330+ // ! [GetProcessExtendedInfos]
331+ CHECK_FAILURE (environmentExperimental13->GetProcessExtendedInfos (
332+ Callback<ICoreWebView2ExperimentalGetProcessExtendedInfosCompletedHandler>(
333+ [this ](
334+ HRESULT error,
335+ ICoreWebView2ExperimentalProcessExtendedInfoCollection* processCollection)
323336 -> HRESULT
324337 {
325338 UINT32 processCount = 0 ;
@@ -329,8 +342,12 @@ void ProcessComponent::ShowProcessFrameInfo()
329342 std::wstringstream rendererProcessInfos;
330343 for (UINT32 i = 0 ; i < processCount; i++)
331344 {
345+ Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalProcessExtendedInfo>
346+ processExtendedInfo;
347+ CHECK_FAILURE (
348+ processCollection->GetValueAtIndex (i, &processExtendedInfo));
332349 Microsoft::WRL::ComPtr<ICoreWebView2ProcessInfo> processInfo;
333- CHECK_FAILURE (processCollection-> GetValueAtIndex (i, &processInfo));
350+ CHECK_FAILURE (processExtendedInfo-> get_ProcessInfo ( &processInfo));
334351 COREWEBVIEW2_PROCESS_KIND kind;
335352 CHECK_FAILURE (processInfo->get_Kind (&kind));
336353 INT32 processId = 0 ;
@@ -339,12 +356,8 @@ void ProcessComponent::ShowProcessFrameInfo()
339356 {
340357 // ! [AssociatedFrameInfos]
341358 std::wstringstream rendererProcess;
342- wil::com_ptr<ICoreWebView2ExperimentalProcessInfo>
343- processInfoExperimental;
344- CHECK_FAILURE (processInfo->QueryInterface (
345- IID_PPV_ARGS (&processInfoExperimental)));
346359 wil::com_ptr<ICoreWebView2FrameInfoCollection> frameInfoCollection;
347- CHECK_FAILURE (processInfoExperimental ->get_AssociatedFrameInfos (
360+ CHECK_FAILURE (processExtendedInfo ->get_AssociatedFrameInfos (
348361 &frameInfoCollection));
349362 wil::com_ptr<ICoreWebView2FrameInfoCollectionIterator> iterator;
350363 CHECK_FAILURE (frameInfoCollection->GetIterator (&iterator));
@@ -363,34 +376,32 @@ void ProcessComponent::ShowProcessFrameInfo()
363376 frameInfoCount++;
364377 }
365378 rendererProcessInfos
366- << std::to_wstring ( frameInfoCount)
367- << L" frameInfo(s) found in Renderer Process ID:"
368- << std::to_wstring (processId) << L" \n "
379+ << frameInfoCount
380+ << L" frameInfo(s) found in Renderer Process ID:" << processId
381+ << L" \n "
369382 << rendererProcess.str () << std::endl;
370383 // ! [AssociatedFrameInfos]
371384 rendererProcessCount++;
372385 }
373386 else
374387 {
375- otherProcessInfos << L" Process Id:" << std::to_wstring ( processId)
388+ otherProcessInfos << L" Process Id:" << processId
376389 << L" | Process Kind:"
377390 << ProcessKindToString (kind) << std::endl;
378391 }
379392 }
380393 std::wstringstream message;
381- message << std::to_wstring (processCount)
382- << L" process(es) found, from which "
383- << std::to_wstring (rendererProcessCount)
384- << L" renderer process(es) found\n\n "
394+ message << processCount << L" process(es) found, from which "
395+ << rendererProcessCount << L" renderer process(es) found\n\n "
385396 << rendererProcessInfos.str () << L" Remaining Process(es) Infos:\n "
386397 << otherProcessInfos.str ();
387398
388399 m_appWindow->AsyncMessageBox (
389- std::move (message.str ()), L" Process Info with Associated Frames " );
400+ std::move (message.str ()), L" Process Extended Info " );
390401 return S_OK;
391402 })
392403 .Get ()));
393- // ! [GetProcessInfosWithDetails ]
404+ // ! [GetProcessExtendedInfos ]
394405 }
395406}
396407
0 commit comments