Skip to content

Commit 79f85a8

Browse files
Merge pull request #1553 from MicrosoftEdge/api-browser-task-manager
API Review: Browser Task Manager
2 parents f38a92e + add1eeb commit 79f85a8

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

specs/BrowserTaskManager.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Background
2+
The WebView2 team has been asked to provide an API to expose the Browser Task
3+
Manager. The Browser Task Manager is a window helpful for debugging that
4+
displays the different processes associated with the current browser process and
5+
what they're used for. For instance, it could denote that a particular process
6+
is a renderer process and would show the different web pages rendered by that
7+
process. In a chromium browser it can be opened by the end user by pressing
8+
`Shift+Esc` or from the DevTools window's title bar's context menu entry
9+
`Browser task manager`. For WebView2 applications, we block the
10+
`Shift+Esc` shortcut, but the task manager can still be opened via the
11+
`Browser task manager` entry.
12+
13+
At the current time, it is expected that the user will close the Task
14+
Manager manually, so we do not need to provide an API to close it.
15+
16+
In this document we describe the updated API. We'd appreciate your feedback.
17+
18+
# Description
19+
We propose extending `CoreWebView2` to provide an `OpenTaskManagerWindow`
20+
method. This method will open a new window containing the task manager.
21+
If the task manager is already opened, this method will do nothing.
22+
23+
# Examples
24+
## C++: Open Task Manager
25+
26+
``` cpp
27+
wil::com_ptr<ICoreWebView2> m_webview;
28+
29+
// This method could be called from a menu bar item, such as
30+
// [Script -> Open Task Manager Window].
31+
void ScriptComponent::OpenTaskManagerWindow()
32+
{
33+
auto webview5 = m_webview.try_query<ICoreWebView2_5>();
34+
if (webview5)
35+
{
36+
CHECK_FAILURE(webview5->OpenTaskManagerWindow());
37+
}
38+
}
39+
40+
// Assume OpenTaskManagerWindow is available if the WebView supports ICoreWebView2_5.
41+
bool ScriptComponent::ShouldShowOpenTaskManagerWindowMenuItem()
42+
{
43+
return m_webview.try_query<ICoreWebView2_5>();
44+
}
45+
```
46+
47+
## C#: Open Task Manager
48+
```c#
49+
private WebView2 m_webview;
50+
51+
// This method could be called from a menu bar item, such as
52+
// [Script -> Open Task Manager Window].
53+
void OpenTaskManagerWindow()
54+
{
55+
m_webview.CoreWebView2.OpenTaskManagerWindow();
56+
}
57+
```
58+
59+
# API Details
60+
## C++
61+
```
62+
/// This is a continuation of the `ICoreWebView2_4` interface
63+
[uuid(20d02d59-6df2-42dc-bd06-f98a694b1302), object, pointer_default(unique)]
64+
interface ICoreWebView2_5 : ICoreWebView2_4 {
65+
/// Opens the Browser Task Manager view as a new window in the foreground.
66+
/// If the Browser Task Manager is already open, this will bring it into
67+
/// the foreground. WebView2 currently blocks the `Shift+Esc` shortcut for
68+
/// opening the task manager. An end user can open the browser task manager
69+
/// manually via the `Browser task manager` entry of the DevTools window's
70+
/// title bar's context menu.
71+
HRESULT OpenTaskManagerWindow();
72+
}
73+
```
74+
75+
## C#
76+
```c#
77+
namespace Microsoft.Web.WebView2.Core
78+
{
79+
runtimeclass CoreWebView2
80+
{
81+
// There are many methods and properties of ICoreWebView2_* which I am
82+
// not including here for simplicity.
83+
84+
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2_5")]
85+
{
86+
// ICoreWebView2_5 members
87+
void OpenTaskManagerWindow();
88+
}
89+
}
90+
}
91+
```

0 commit comments

Comments
 (0)