Skip to content

Commit d08709c

Browse files
authored
Update and rename IsSmartScreenEnabled to IsSmartScreenRequired
1 parent f0906fb commit d08709c

File tree

2 files changed

+88
-88
lines changed

2 files changed

+88
-88
lines changed

specs/IsSmartScreenEnabled

Lines changed: 0 additions & 88 deletions
This file was deleted.

specs/IsSmartScreenRequired

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Background
2+
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.
4+
5+
Currently, users can use `options->put_AdditionalBrowserArguments(L"--disable-features=msSmartScreenProtection")` to control SmartScreen in the WebView2 application. It is essentially a startup parameter of the browser process. It must be determined when the WebView2Environment is created. And Cannot be modified at runtime.
6+
7+
To support more flexibility. We introduce a new API.
8+
9+
In this document we describe the new setting. We'd appreciate your feedback.
10+
11+
12+
# Description
13+
Users can use ICoreWebView2Settings to control it.When it is changed, all WebView2 applications using the same path of the user data folder will be changed.
14+
`put_IsSmartScreenRequired(true)` will always take effect when multiple WebView2s using the same user data folder call `put_IsSmartScreenRequired` at the same time.`put_IsSmartScreenRequired(false)` only takes effect if all WebView2 settings are false.
15+
The default value for `IsSmartScreenRequired` is the current actual value.After this, this setting does not mean the actual situation, it only represents the intention of current WebView.
16+
When the set `false` takes effect, it will turn off SmartScreen protection when visiting web pages and performing downloads.
17+
18+
Changes to `IsSmartScreenRequired` does not take effect until the next navigation or downloads.
19+
20+
21+
# Examples
22+
```cpp
23+
wil::com_ptr<ICoreWebView2Settings> m_webViewSettings;
24+
void SettingsComponent::ToggleSmartScreenRequired()
25+
{
26+
wil::com_ptr<ICoreWebView2Settings11> coreWebView2Settings11;
27+
coreWebView2Settings11 =
28+
m_webViewSettings.try_query<ICoreWebView2Settings11>();
29+
if(coreWebView2Settings11)
30+
{
31+
BOOL enabled;
32+
CHECK_FAILURE(coreWebView2Settings11->get_IsSmartScreenRequired(&enabled));
33+
CHECK_FAILURE(coreWebView2Settings11->put_IsSmartScreenRequired(enabled ? FALSE : TRUE));
34+
}
35+
}
36+
```
37+
38+
```c#
39+
void ToggleSmartScreenRequired()
40+
{
41+
var settings = webView2Control.CoreWebView2.Settings;
42+
settings.IsSmartScreenRequired = !settings.IsSmartScreenRequired;
43+
}
44+
```
45+
46+
# Remarks
47+
All WebViews using the same user data folder share the same SmartScreen setting. When it is changed, the change will be applied to all WebViews using the same user data folder.
48+
49+
# API Notes
50+
51+
See [API Details](#api-details) section below for API reference.
52+
53+
# API Details
54+
55+
## Win32 C++
56+
```cpp
57+
[uuid(d667d3a7-c1b7-479f-8833-db7547df6687), object, pointer_default(unique)]
58+
interface ICoreWebView2Settings11 : ICoreWebView2Settings10 {
59+
/// SmartScreen helps you identify reported phishing and malware websites
60+
/// also helps you make informed decisions about downloads.
61+
/// `IsSmartScreenRequired` is used to control whether SmartScreen is turned on or not.
62+
/// All WebViews using the same user data folder share the same SmartScreen setting.
63+
/// When it is changed, the change will be applied to all WebViews using the
64+
/// same user data folder.
65+
/// By default, it is the current actual state of SmartScreen.
66+
/// \snippet SettingsComponent.cpp ToggleSmartScreenEnabled.
67+
[propget] HRESULT IsSmartScreenRequired([out, retval] BOOL* value);
68+
69+
/// The setting of SmartScreen does not mean the actual situation, it only represents
70+
/// the intention of each WebView2.
71+
/// `put_IsSmartScreenRequired(true)` will always take effect when multiple WebView2s
72+
/// using the same user data folder call `put_IsSmartScreenRequired` at the same time.
73+
/// `put_IsSmartScreenRequired(false)` only takes effect if all WebView2 settings are false.
74+
/// Set the `IsSmartScreenRequired` property.
75+
[propput] HRESULT IsSmartScreenRequired([in] BOOL value);
76+
}
77+
```
78+
79+
## .NET and WinRT
80+
namespace Microsoft.Web.WebView2.Core
81+
{
82+
public partial class CoreWebView2Settings
83+
{
84+
public bool IsSmartScreenRequired { get; set; };
85+
public bool IsSmartScreenRequired { get; set; };
86+
}
87+
}
88+

0 commit comments

Comments
 (0)