Skip to content

Commit d8c297f

Browse files
author
Diana Qu
committed
change comment. modify background, description
1 parent 98c8ec5 commit d8c297f

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

specs/GetEnvironment.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# Background
2-
When the WebView2 team was making design changes to the [WebResourceRequested API](https://github.com/MicrosoftEdge/WebView2Feedback/wiki/WebResourceRequested-API-Review-Spec) for .NET, we realized it was not intutive to create the WebView2 Environment. Thus it was not straightforward to use the CreateWebResourceResponse off the WebView2 Environment.
3-
WebView2 team plans to introduce an easier way to get the Environment variable and CreateWebResourceResponse.
2+
When the WebView2 team was making design changes to the [WebResourceRequested API](https://github.com/MicrosoftEdge/WebView2Feedback/wiki/WebResourceRequested-API-Review-Spec) for .NET, we realized several caveats. It was not ideal to force all end developers to keep references back to the CoreWebView2Environment from their CoreWebView2 event handlers, and also in the case of WPF, WinForms and WinUI3.0 the UI framework can create the CoreWebView2Environment internally with no easy way for the end developers to obtain a reference to it. Thus providing a reference to the CoreWebView2Environment off of the CoreWebView2 solves both of those problems.
43

54
# Description
6-
One can get WebView2 Environment from `Environment`.
5+
Get the `CoreWebView2Environment` used to create the `CoreWebView2` from that `CoreWebView2`'s `CoreWebView2Environment` property
76

87

98
# Examples
@@ -64,7 +63,6 @@ void SettingsComponent::SetBlockImages(bool blockImages)
6463
```c#
6564
private void CoreWebView2_WebResourceRequested(object sender, CoreWebView2WebResourceRequestedEventArgs e)
6665
{
67-
CoreWebView2Environment environment = webView2Control.CoreWebView2.Environment;
6866
// Create response object for custom response and set it
6967
var environment = webView2Control.CoreWebView2.Environment;
7068
CoreWebView2WebResourceResponse response = environment.CreateWebResourceResponse(null, 403, "Blocked", "");
@@ -85,9 +83,11 @@ See [API Details](#api-details) section below for API reference.
8583

8684
```IDL
8785
interface ICoreWebView2;
86+
interface ICoreWebView2_2;
8887
8988
[uuid(76eceacb-0462-4d94-ac83-423a6793775e), object, pointer_default(unique)]
90-
interface ICoreWebView2 : IUnknown {
89+
interface ICoreWebView2_2 : ICoreWebView2 {
90+
/// Exposes the CoreWebView2Environment used to create this CoreWebView2.
9191
[propget] HRESULT Environment([out, retval] ICoreWebView2Environment** environment);
9292
}
9393
```
@@ -99,6 +99,7 @@ namespace Microsoft.Web.WebView2.Core
9999
{
100100
public partial class CoreWebView2
101101
{
102+
// There are other API in this interface that we are not showing
102103
public CoreWebView2Environment Environment { get; };
103104
}
104105
}

0 commit comments

Comments
 (0)