Skip to content

Commit e04c4c8

Browse files
Merge pull request #1137 from MicrosoftEdge/api-autofillsettings-draft
Api autofill settings draft
2 parents dabc632 + c61b885 commit e04c4c8

1 file changed

Lines changed: 130 additions & 0 deletions

File tree

specs/Autofill.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Background
2+
The WebView2 team has been asked for an API to allow end developers to set the autofill preferences. We are exposing two of the autofill preferences that will allow enabling and disabling general autofill and password autosave. General autofill includes things like email addresses, shipping addresses, phone numbers, and names. Password autosave includes things like usernames and passwords for login. Password information is not included in general autofill.
3+
4+
In this document we describe the updated API. We'd appreciate your feedback.
5+
6+
7+
# Description
8+
9+
The components of autofill/autosave are as follows:
10+
* Auto-populate - Populate the corresponding form fields automatically on page load.
11+
* Suggest - When the user clicks on the form field, drop down suggestions of previously saved forms will be displayed.
12+
* Populate - When clicking on one of the suggestions, the form data will populate the respective fields.
13+
* Save/Update prompt - After submitting password information, if IsPasswordAutosaveEnabled is true, a prompt will popup that allows the user to give permission to save or update their password information.
14+
15+
The general autofill setting and password autosave setting behave independently. Their behavior differs as well.
16+
17+
The default behavior for the general autofill setting is enabled.
18+
The default behavior for the password autosave setting is disabled.
19+
20+
| Behavior | IsPasswordAutosaveEnabled = false | IsGeneralAutofillEnabled = false | IsPasswordAutoSaveEnabled = true | IsGeneralAutofillEnabled = true |
21+
|-|-|-|-|-|
22+
| Populate on accepted suggestion | Yes | No | Yes | Yes |
23+
| Suggest | Yes | No | Yes | Yes |
24+
| Auto-populate | Yes | No | Yes | No |
25+
| Save/Update prompt | No | N/A | Yes | N/A |
26+
| Input saved | No | No | Yes | Yes |
27+
28+
The information that is autofilled, auto-populated, or suggested when the IsPasswordAutosaveEnabled is false is previously saved information when the IsPasswordAutosaveEnabled property has been set to true.
29+
30+
# Examples
31+
32+
## Win32 C++
33+
```cpp
34+
void SettingsComponent::TogglePasswordAutofill() {
35+
wil::com_ptr<ICoreWebView2Settings> settings;
36+
CHECK_FAILURE(webView->get_Settings(&settings));
37+
wil::com_ptr<ICoreWebView2Settings4> settings4 = settings.try_query<ICoreWebView2Settings4>();
38+
if (settings4)
39+
{
40+
bool enabled;
41+
CHECK_FAILURE(settings4->get_IsPasswordAutofillEnabled(&enabled));
42+
CHECK_FAILURE(settings4->put_IsPasswordAutofillEnabled(!enabled));
43+
}
44+
}
45+
46+
void SettingsComponent::ToggleGeneralAutofill() {
47+
wil::com_ptr<ICoreWebView2Settings> settings;
48+
CHECK_FAILURE(webView->get_Settings(&settings));
49+
wil::com_ptr<ICoreWebView2Settings4> settings4 = settings.try_query<ICoreWebView2Settings4>();
50+
if (settings4)
51+
{
52+
bool enabled;
53+
CHECK_FAILURE(settings4->get_IsGeneralAutofillEnabled(&enabled));
54+
CHECK_FAILURE(settings4->put_IsGeneralAutofillEnabled(!enabled));
55+
}
56+
}
57+
```
58+
59+
## .NET, WinRT
60+
```c#
61+
62+
// This demonstrates a scenario in which a button triggers TogglePasswordAutofill or
63+
// ToggleGeneralAutofill.
64+
65+
private void TogglePasswordAutofill(CoreWebView2 sender, CoreWebView2NavigationStartingEventArgs e)
66+
{
67+
var settings = webView2Control.CoreWebView2.Settings;
68+
settings.IsPasswordAutofillEnabled = !settings.IsPasswordAutofillEnabled;
69+
}
70+
71+
private void ToggleGeneralAutofill(CoreWebView2 sender, CoreWebView2NavigationStartingEventArgs e)
72+
{
73+
var settings = webView2Control.CoreWebView2.Settings;
74+
settings.IsGeneralAutofillEnabled = !settings.IsGeneralAutofillEnabled;
75+
}
76+
77+
```
78+
79+
80+
# API Notes
81+
See [API Details](#api-details) section below for API reference.
82+
83+
84+
# API Details
85+
```IDL
86+
interface ICoreWebView2Settings4
87+
88+
/// A continuation of the ICoreWebView2Settings interface.
89+
[uuid(cb56846c-4168-4d53-b04f-03b6d6796ff2), object, pointer_default(unique)]
90+
interface ICoreWebView2Settings4 : ICoreWebView2Settings3 {
91+
/// IsPasswordAutosaveEnabled controls whether autosave for password
92+
/// information is enabled. The IsPasswordAutosaveEnabled property behaves
93+
/// independently of the IsGeneralAutofillEnabled property. When IsPasswordAutosaveEnabled is
94+
/// false, no new password data is saved and no Save/Update Password prompts are displayed.
95+
/// However, if there was password data already saved before disabling this setting,
96+
/// then that password information is auto-populated, suggestions are shown and clicking on
97+
/// one will populate the fields.
98+
/// When IsPasswordAutosaveEnabled is true, password information is auto-populated,
99+
/// suggestions are shown and clicking on one will populate the fields, new data
100+
/// is saved, and a Save/Update Password prompt is displayed.
101+
/// The default value is `FALSE`.
102+
[propget] HRESULT IsPasswordAutosaveEnabled([out, retval] BOOL* value);
103+
/// Set the IsPasswordAutosaveEnabled property.
104+
[propput] HRESULT IsPasswordAutosaveEnabled([in] BOOL value);
105+
106+
/// IsGeneralAutofillEnabled controls whether autofill for information
107+
/// like names, street and email addresses, phone numbers, and arbitrary input
108+
/// is enabled. This excludes password and credit card information. When
109+
/// IsGeneralAutofillEnabled is false, no suggestions appear, and no new information
110+
/// is saved. When IsGeneralAutofillEnabled is true, information is saved, suggestions
111+
/// appear and clicking on one will populate the form fields.
112+
/// The default value is `TRUE`.
113+
[propget] HRESULT IsGeneralAutofillEnabled([out, retval] BOOL* value);
114+
/// Set the IsGeneralAutofillEnabled property.
115+
[propput] HRESULT IsGeneralAutofillEnabled([in] BOOL value);
116+
}
117+
```
118+
119+
## .NET and WinRT
120+
```c#
121+
namespace Microsoft.Web.WebView2.Core
122+
{
123+
public partial class CoreWebView2Settings
124+
{
125+
public bool IsPasswordAutofillEnabled { get; set; };
126+
public bool IsGeneralAutofillEnabled {get; set; };
127+
}
128+
}
129+
130+
```

0 commit comments

Comments
 (0)