@@ -106,10 +106,11 @@ ProcessComponent::ProcessComponent(AppWindow* appWindow)
106
106
CHECK_FAILURE (args2->get_ExitCode (&exitCode));
107
107
108
108
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;
113
114
m_appWindow->AsyncMessageBox ( std::move (message.str ()), L" Child process failed" );
114
115
}
115
116
return S_OK;
@@ -176,8 +177,8 @@ bool ProcessComponent::HandleWindowMessage(
176
177
case IDM_PERFORMANCE_INFO:
177
178
PerformanceInfo ();
178
179
return true ;
179
- case IDM_PROCESS_FRAME_INFO :
180
- ShowProcessFrameInfo ();
180
+ case IDM_PROCESS_EXTENDED_INFO :
181
+ ShowProcessExtendedInfo ();
181
182
return true ;
182
183
}
183
184
}
@@ -206,7 +207,9 @@ std::wstring ProcessComponent::FrameKindToString(const COREWEBVIEW2_FRAME_KIND k
206
207
207
208
KIND_ENTRY (COREWEBVIEW2_FRAME_KIND_MAIN_FRAME);
208
209
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);
210
213
211
214
#undef KIND_ENTRY
212
215
}
@@ -220,16 +223,16 @@ void ProcessComponent::AppendFrameInfo(
220
223
UINT32 frameId = 0 ;
221
224
UINT32 parentFrameId = 0 ;
222
225
UINT32 mainFrameId = 0 ;
223
- UINT32 firstLevelFrameId = 0 ;
226
+ UINT32 childFrameId = 0 ;
224
227
std::wstring type = L" other child frame" ;
225
228
wil::unique_cotaskmem_string nameRaw;
226
229
wil::unique_cotaskmem_string sourceRaw;
227
- COREWEBVIEW2_FRAME_KIND frameKind = COREWEBVIEW2_FRAME_KIND_OTHER ;
230
+ COREWEBVIEW2_FRAME_KIND frameKind = COREWEBVIEW2_FRAME_KIND_UNKNOWN ;
228
231
229
232
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" ;
231
234
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" ;
233
236
234
237
wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
235
238
CHECK_FAILURE (frameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
@@ -252,26 +255,24 @@ void ProcessComponent::AppendFrameInfo(
252
255
CHECK_FAILURE (mainFrameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
253
256
CHECK_FAILURE (frameInfoExperimental->get_FrameId (&mainFrameId));
254
257
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)
258
261
{
259
262
type = L" first level frame" ;
260
263
}
261
- if (firstLevelFrameInfo )
264
+ if (childFrameInfo )
262
265
{
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));
266
268
}
267
269
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:"
270
271
<< ((parentFrameId == 0 ) ? L" none" : std::to_wstring (parentFrameId))
271
272
<< 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 "
275
276
<< L" | frame kind:" << FrameKindToString (frameKind) << L" \n "
276
277
<< L" | frame source:" << source << L" }," << std::endl;
277
278
}
@@ -292,34 +293,46 @@ wil::com_ptr<ICoreWebView2FrameInfo> ProcessComponent::GetAncestorMainFrameInfo(
292
293
return mainFrameInfo;
293
294
}
294
295
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 (
298
309
wil::com_ptr<ICoreWebView2FrameInfo> frameInfo)
299
310
{
300
311
wil::com_ptr<ICoreWebView2FrameInfo> mainFrameInfo;
301
- wil::com_ptr<ICoreWebView2FrameInfo> firstLevelFrameInfo ;
312
+ wil::com_ptr<ICoreWebView2FrameInfo> childFrameInfo ;
302
313
wil::com_ptr<ICoreWebView2ExperimentalFrameInfo> frameInfoExperimental;
303
314
while (frameInfo)
304
315
{
305
- firstLevelFrameInfo = mainFrameInfo;
316
+ childFrameInfo = mainFrameInfo;
306
317
mainFrameInfo = frameInfo;
307
318
CHECK_FAILURE (frameInfo->QueryInterface (IID_PPV_ARGS (&frameInfoExperimental)));
308
319
CHECK_FAILURE (frameInfoExperimental->get_ParentFrameInfo (&frameInfo));
309
320
}
310
- return firstLevelFrameInfo ;
321
+ return childFrameInfo ;
311
322
}
312
323
313
- void ProcessComponent::ShowProcessFrameInfo ()
324
+ void ProcessComponent::ShowProcessExtendedInfo ()
314
325
{
315
- auto environmentExperimental11 =
316
- m_webViewEnvironment.try_query <ICoreWebView2ExperimentalEnvironment11 >();
317
- if (environmentExperimental11 )
326
+ auto environmentExperimental13 =
327
+ m_webViewEnvironment.try_query <ICoreWebView2ExperimentalEnvironment13 >();
328
+ if (environmentExperimental13 )
318
329
{
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)
323
336
-> HRESULT
324
337
{
325
338
UINT32 processCount = 0 ;
@@ -329,8 +342,12 @@ void ProcessComponent::ShowProcessFrameInfo()
329
342
std::wstringstream rendererProcessInfos;
330
343
for (UINT32 i = 0 ; i < processCount; i++)
331
344
{
345
+ Microsoft::WRL::ComPtr<ICoreWebView2ExperimentalProcessExtendedInfo>
346
+ processExtendedInfo;
347
+ CHECK_FAILURE (
348
+ processCollection->GetValueAtIndex (i, &processExtendedInfo));
332
349
Microsoft::WRL::ComPtr<ICoreWebView2ProcessInfo> processInfo;
333
- CHECK_FAILURE (processCollection-> GetValueAtIndex (i, &processInfo));
350
+ CHECK_FAILURE (processExtendedInfo-> get_ProcessInfo ( &processInfo));
334
351
COREWEBVIEW2_PROCESS_KIND kind;
335
352
CHECK_FAILURE (processInfo->get_Kind (&kind));
336
353
INT32 processId = 0 ;
@@ -339,12 +356,8 @@ void ProcessComponent::ShowProcessFrameInfo()
339
356
{
340
357
// ! [AssociatedFrameInfos]
341
358
std::wstringstream rendererProcess;
342
- wil::com_ptr<ICoreWebView2ExperimentalProcessInfo>
343
- processInfoExperimental;
344
- CHECK_FAILURE (processInfo->QueryInterface (
345
- IID_PPV_ARGS (&processInfoExperimental)));
346
359
wil::com_ptr<ICoreWebView2FrameInfoCollection> frameInfoCollection;
347
- CHECK_FAILURE (processInfoExperimental ->get_AssociatedFrameInfos (
360
+ CHECK_FAILURE (processExtendedInfo ->get_AssociatedFrameInfos (
348
361
&frameInfoCollection));
349
362
wil::com_ptr<ICoreWebView2FrameInfoCollectionIterator> iterator;
350
363
CHECK_FAILURE (frameInfoCollection->GetIterator (&iterator));
@@ -363,34 +376,32 @@ void ProcessComponent::ShowProcessFrameInfo()
363
376
frameInfoCount++;
364
377
}
365
378
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 "
369
382
<< rendererProcess.str () << std::endl;
370
383
// ! [AssociatedFrameInfos]
371
384
rendererProcessCount++;
372
385
}
373
386
else
374
387
{
375
- otherProcessInfos << L" Process Id:" << std::to_wstring ( processId)
388
+ otherProcessInfos << L" Process Id:" << processId
376
389
<< L" | Process Kind:"
377
390
<< ProcessKindToString (kind) << std::endl;
378
391
}
379
392
}
380
393
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 "
385
396
<< rendererProcessInfos.str () << L" Remaining Process(es) Infos:\n "
386
397
<< otherProcessInfos.str ();
387
398
388
399
m_appWindow->AsyncMessageBox (
389
- std::move (message.str ()), L" Process Info with Associated Frames " );
400
+ std::move (message.str ()), L" Process Extended Info " );
390
401
return S_OK;
391
402
})
392
403
.Get ()));
393
- // ! [GetProcessInfosWithDetails ]
404
+ // ! [GetProcessExtendedInfos ]
394
405
}
395
406
}
396
407
0 commit comments