如何通过调用 CreateWebView2EnvironmentWithDetails 来更改 Microsoft Edge WebView2 mDNS 行为?

How to change Microsoft Edge WebView2 mDNS behavior by calling CreateWebView2EnvironmentWithDetails?

我正在使用 Microsoft Edge WebView2 开发 WebRTC 应用程序。我想将 edge://flags/#enable-webrtc-hide-local-ips-with-mdns 标志的值从 'Default' 更改为 'Disabled'.

根据 MSDN 文档 https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl,API CreateWebView2EnvironmentWithDetails 有一个参数 additionalBrowserArguments,它可以更改 chromium 标志。我尝试了以下根本不起作用的值。

WCHAR args[] = TEXT("--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--disable-webrtc-hide-local-ips-with-mdns");
WCHAR args[] = TEXT("--edge-webview-switches=\"--enable-webrtc-hide-local-ips-with-mdns=0\"");
WCHAR args[] = TEXT("--edge-webview-switches=--enable-webrtc-hide-local-ips-with-mdns=0");
WCHAR args[] = TEXT("--edge-webview-switches=--disable-webrtc-hide-local-ips-with-mdns");

以上参数在 API

中不起作用
CreateWebView2EnvironmentWithDetails(nullptr, nullptr, args, callback_handler);

我在 Window 10.

上使用 80.0.315.0(官方构建)金丝雀版(64 位)的 Microsoft Edge

提前致谢

我在文档中找到了此信息。

"The switches are not guaranteed to be applied except for the first WebView that starts the browser process. If parsing failed for the specified switches, they will be ignored. nullptr will run browser process with no flags."

参考:

members

您也可以尝试通过 Edge (Chromium) 浏览器提供有关问题的反馈。

According to the MSDN doc https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2/reference/webview2.idl, the API CreateWebView2EnvironmentWithDetails has an argument additionalBrowserArguments which can change chromium flags. I've tried the following values which don't work at all.

我已经用 official Samples and Process Explorer 试过了。参数已正确添加到流程中:

之所以不行是因为没有这个开关:

这里是switch list found at Run Chromium with flags。我搜索了列表,但没有找到名为 --enable-webrtc-hide-local-ips-with-mdns.

的开关

当我通过 edge://flags/#enable-webrtc-hide-local-ips-with-mdns 手动启用标志并检查它时,开关如下所示:

所以答案很明确,你应该把参数从--enable-webrtc-hide-local-ips-with-mdns改成--enable-features=WebRtcHideLocalIpsWithMdns