|
| 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_5> 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 | + CHECK_FAILURE(m_webview->OpenTaskManagerWindow()); |
| 34 | +} |
| 35 | +``` |
| 36 | + |
| 37 | +## C#: Open Task Manager |
| 38 | +```c# |
| 39 | +private WebView2 m_webview; |
| 40 | + |
| 41 | +// This method could be called from a menu bar item, such as |
| 42 | +// [Script -> Open Task Manager Window]. |
| 43 | +void OpenTaskManagerWindow() |
| 44 | +{ |
| 45 | + m_webview.CoreWebView2.OpenTaskManagerWindow(); |
| 46 | +} |
| 47 | +``` |
| 48 | + |
| 49 | +# API Details |
| 50 | +## C++ |
| 51 | +``` |
| 52 | +/// This is a continuation of the `ICoreWebView2_4` interface |
| 53 | +[uuid(20d02d59-6df2-42dc-bd06-f98a694b1302), object, pointer_default(unique)] |
| 54 | +interface ICoreWebView2_5 : ICoreWebView2_4 { |
| 55 | + /// Opens the Browser Task Manager view as a new window. Does nothing |
| 56 | + /// if run when the Browser Task Manager is already open. |
| 57 | + /// WebView2 currently blocks the `Shift+Esc` shortcut for opening the |
| 58 | + /// task manager. An end user can open the browser task manager manually |
| 59 | + /// via the `Browser task manager` entry of the DevTools window's title |
| 60 | + /// bar's context menu. |
| 61 | + HRESULT OpenTaskManagerWindow(); |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +## C# |
| 66 | +```c# |
| 67 | +namespace Microsoft.Web.WebView2.Core |
| 68 | +{ |
| 69 | + runtimeclass CoreWebView2 |
| 70 | + { |
| 71 | + // There are many methods and properties of ICoreWebView2_* which I am |
| 72 | + // not including here for simplicity. |
| 73 | +
|
| 74 | + [interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2_5")] |
| 75 | + { |
| 76 | + // ICoreWebView2_5 members |
| 77 | + void OpenTaskManagerWindow(); |
| 78 | + } |
| 79 | + } |
| 80 | +} |
| 81 | +``` |
0 commit comments