Skip to content

Commit f8d1329

Browse files
authored
Make some changes based on review
1 parent f37516e commit f8d1329

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# Background
22

3-
[Edge SmartScreen](https://docs.microsoft.com/en-us/deployedge/microsoft-edge-security-smartscreen) helps you identify reported phishing and malware websites, and also helps you make informed decisions about downloads.
3+
[Edge SmartScreen](https://support.microsoft.com/en-us/microsoft-edge/how-can-smartscreen-help-protect-me-in-microsoft-edge-1c9a874a-6826-be5e-45b1-67fa445a74c8) helps end users identify reported phishing and malware websites, and also helps you make informed decisions about downloads.
44

55
Currently, developers can use `options->put_AdditionalBrowserArguments(L"--disable-features=msSmartScreenProtection")` to disable SmartScreen in the WebView2 application. It is essentially a startup parameter of the browser process and applies to all WebView2 instances associated with that WebView2Environment. It must be determined when the WebView2Environment is created, and it cannot be modified at runtime.
66

77
To support more flexibility we introduce a new API.
8-
We initially considered an API like `CoreWebView2Environment.IsSmartScreenEnabled` that would directly change the value for all the processes. The problem is this is not easy to do for apps like Office who have multiple apps connected to the same browser process. In their case each app has IsSmartScreenEnabled and its hard for the browser process to know which change to the property should win.
98

10-
Instead we have CoreWebView2Settings.IsSmartScreenRequired. Each WebView2 declares if it requires SmartScreen. Some WebView2s may be used to display app content and don't require SmartScreen and others may be rendering arbitrary web content and do need SmartScreen. Having SmartScreen on unnecessarily for app content is a detriment to performance but otherwise not a problem. Having SmartScreen off for arbitrary web content is an issue. We have to turn SmartScreen on or off for all the WebView2s in an environment so if any WebView2 requires SmartScreen then we turn it on for all of them. If WebView2 settings change or WebView2s are closed and then all the WebView2s in an environment don't require SmartScreen, then we can turn SmartScreen off.
9+
we have CoreWebView2Settings.IsSmartScreenRequired. Each WebView2 declares if it requires SmartScreen. Some WebView2s may be used to display app content and don't require SmartScreen and others may be rendering arbitrary web content and do need SmartScreen. Having SmartScreen on unnecessarily for app content is a detriment to performance but otherwise not a problem. Having SmartScreen off for arbitrary web content is an issue. We have to turn SmartScreen on or off for all the WebView2s in an environment so if any WebView2 requires SmartScreen then we turn it on for all of them. If WebView2 settings change or WebView2s are closed and then all the WebView2s in an environment don't require SmartScreen, then we can turn SmartScreen off.
1110

1211
It is much easier to indicate if individual WebView2s require SmartScreen than to have an end developer explicitly manage if SmartScreen should be enabled as a whole, especially when its different sets of WebView2s in different processes (like Excel's set of WebView2s and Word's set of WebView2s) all sharing the same user data folder.
13-
In this document we describe the new setting. We'd appreciate your feedback.
12+
In this document we describe the new setting.
1413

1514

1615
# Description
@@ -23,17 +22,20 @@ Changes to `IsSmartScreenRequired` take effect on the next navigation or downloa
2322

2423
# Examples
2524
```cpp
25+
// member variable
2626
wil::com_ptr<ICoreWebView2Settings> m_webViewSettings;
27-
void SettingsComponent::ToggleSmartScreenRequired()
27+
28+
// isLocalContent is TRUE if the page is navigated to content that is completely
29+
// app-provided, with no user-provided content or web-served content.
30+
// Note that we must update the property before navigating to the content.
31+
void SettingsComponent::UpdateSmartScreenRequirementBeforeNavigating(bool isLocalContent)
2832
{
29-
wil::com_ptr<ICoreWebView2Settings11> coreWebView2Settings11;
33+
wil::com_ptr<ICoreWebView2Settings11> coreWebView2Settings11;
3034
coreWebView2Settings11 =
3135
m_webViewSettings.try_query<ICoreWebView2Settings11>();
3236
if(coreWebView2Settings11)
3337
{
34-
BOOL enabled;
35-
CHECK_FAILURE(coreWebView2Settings11->get_IsSmartScreenRequired(&enabled));
36-
CHECK_FAILURE(coreWebView2Settings11->put_IsSmartScreenRequired(enabled ? FALSE : TRUE));
38+
CHECK_FAILURE(coreWebView2Settings11->put_IsSmartScreenRequired(!isLocalContent));
3739
}
3840
}
3941
```
@@ -58,28 +60,27 @@ See [API Details](#api-details) section below for API reference.
5860
```cpp
5961
[uuid(d667d3a7-c1b7-479f-8833-db7547df6687), object, pointer_default(unique)]
6062
interface ICoreWebView2Settings11 : ICoreWebView2Settings10 {
61-
/// SmartScreen helps you identify reported phishing and malware websites
63+
/// SmartScreen helps end users identify reported phishing and malware websites
6264
/// and also helps you make informed decisions about downloads.
6365
/// `IsSmartScreenRequired` is used to control whether SmartScreen enabled or not.
6466
/// SmartScreen is enabled or disabled for all CoreWebView2s in a CoreWebView2Environment.
6567
/// If CoreWebView2Setting.IsSmartScreenRequired is true for any CoreWebView2 associated to the same
6668
/// CoreWebView2Environment, then SmartScreen is enabled. If CoreWebView2Setting.IsSmartScreenRequired
6769
/// is false for all CoreWebView2s in the associated CoreWebView2Environment, then SmartScreen is disabled.
6870
/// When it is changed, the change will be applied to all WebViews using the
69-
/// same user data folder.
71+
/// same CoreWebView2Environment.
7072
/// The default value for `IsSmartScreenRequired` is true if SmartScreen is enabled when the CoreWebView2
7173
/// is created and false if SmartScreen is disabled when the CoreWebView2 is created. The value doesn't change
7274
/// if SmartScreen is enabled or disabled later.
73-
/// \snippet SettingsComponent.cpp ToggleSmartScreenEnabled.
7475
[propget] HRESULT IsSmartScreenRequired([out, retval] BOOL* value);
7576

76-
/// The setting of SmartScreen does not mean the actual situation, it only represents
77-
/// the intention of each WebView2.
77+
/// Sets whether this webview2 instance needs SmartScreen protection for its content.
7878
/// Set the `IsSmartScreenRequired` property.
7979
[propput] HRESULT IsSmartScreenRequired([in] BOOL value);
8080
}
8181
```
8282

83+
```c# (really MIDL3)
8384
namespace Microsoft.Web.WebView2.Core
8485
{
8586
runtimeclass CoreWebView2Settings
@@ -91,4 +92,8 @@ namespace Microsoft.Web.WebView2.Core
9192
}
9293
}
9394
}
95+
```
9496

97+
# Appendix
98+
99+
We initially considered an API like `CoreWebView2Environment.IsSmartScreenEnabled` that would directly change the value for all the processes. The problem is this is not easy to do for apps like Office who have multiple apps connected to the same browser process. In their case each app has IsSmartScreenEnabled and its hard for the browser process to know which change to the property should win.

0 commit comments

Comments
 (0)