Skip to content

Commit a068f86

Browse files
author
Maura Winstanley
committed
autofill spec draft
1 parent f2abacd commit a068f86

1 file changed

Lines changed: 112 additions & 0 deletions

File tree

specs/Autofill.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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 toggling between enable and disable autofill for addresses and passwords. Addresses includes things like email addresses, shipping addresses, phone numbers, and names. Passwords includes things like username and passwords for login.
3+
4+
In this document we describe the updated API. We'd appreciate your feedback.
5+
6+
7+
# Description
8+
9+
Autofilling has three components
10+
* Auto-stuffing - filling the corresponding form fields automatically on page load.
11+
* Suggesting - When the user clicks on the form field, drop down suggestions of previously saved forms will be displayed.
12+
* Populating - When clicking on one of the suggestions, the form data will populate the respective fields.
13+
14+
15+
# Examples
16+
17+
## Win32 C++
18+
```cpp
19+
void SettingsComponent::TogglePasswordAutofill() {
20+
wil::com_ptr<ICoreWebView2Settings2_2> settings;
21+
webView->get_Settings(&settings);
22+
bool enabled;
23+
settings->get_IsPasswordAutofillEnabled(&enabled);
24+
settings->put_IsPasswordAutofillEnabled(!enabled);
25+
}
26+
27+
void SettingsComponent::ToggleAddressAutofill() {
28+
wil::com_ptr<ICoreWebView2Settings2_2> settings;
29+
webView->get_Settings(&settings);
30+
bool enabled;
31+
settings->get_IsAddressAutofillEnabled(&enabled)
32+
settings->put_IsAddressAutofillEnabled(!enabled);
33+
}
34+
```
35+
36+
## .NET, WinRT
37+
```c#
38+
webView2Control.NavigationStarting += TogglePasswordAutofill;
39+
40+
private void TogglePasswordAutofill(CoreWebView2 sender, CoreWebView2NavigationStartingEventArgs e)
41+
{
42+
var settings = webView2Control.CoreWebView2.Settings;
43+
settings.IsPasswordAutofillEnabled = !settings.IsPasswordAutofillEnabled;
44+
}
45+
46+
webView2Control.NavigationStarting += ToggleAddressAutofill;
47+
48+
private void ToggleAddressAutofill(CoreWebView2 sender, CoreWebView2NavigationStartingEventArgs e)
49+
{
50+
var settings = webView2Control.CoreWebView2.Settings;
51+
settings.IsAddressAutofillEnabled = !settings.IsAddressAutofillEnabled;
52+
}
53+
54+
```
55+
56+
57+
# Remarks
58+
The behaviour of the two types of autofill preferences behaves differently when toggling between enable and disable.
59+
If address autofill is enabled:
60+
* Address data will be saved
61+
* Upon clicking on the form field, suggestions will appear
62+
* Clicking on one of the suggestions will populate the corresponding fields
63+
If address autofill is disabled
64+
* No new address data will be saved
65+
* Upon clicking on the form field, suggestions will not appear
66+
If password autofill is enabled
67+
* Password data will be autostuffed
68+
* Upon clicking on the form field, suggestions will appear
69+
* Clicking on one of the suggestions will populate the corresponding fields
70+
* Upon submitting the password data, a save password prompt will be displayed that will give the user the option to save or update the password data. If the user selects `Yes`, the new password data will be saved or updated depending on if they have previously entered password data while password autofill is enabled.
71+
If password autofill is disabled
72+
* The password data will be autostuffed
73+
* Upon clicking on the form field, suggestions will appear
74+
* Clicking on one of the suggestions will populate the corresponding fields.
75+
* Upon submitting the password data, no save password prompt will be displayed and no password information is saved or updated.
76+
77+
78+
# API Notes
79+
See [API Details](#api-details) section below for API reference.
80+
81+
82+
# API Details
83+
```IDL
84+
interface ICoreWebView2Settings2_2
85+
86+
[uuid(f051013e-4bb3-46b2-b6e4-6ee3fe4f43c2), object, pointer_default(unique)]
87+
interface ICoreWebView2Settings2_2 : ICoreWebView2Settings2 {
88+
/// IsPasswordAutofillEnabled controls whether autofill for passwords is enabled.
89+
/// The default value is `FALSE`.
90+
[propget] HRESULT IsPasswordAutofillEnabled([out, retval] BOOL* isPasswordAutofillEnabled);
91+
// Set the IsPasswordAutofillEnabled property.
92+
[propput] HRESULT IsPasswordAutofillEnabled([in] BOOL isPasswordAutofillEnabled);
93+
94+
/// IsAddressAutofillEnabled controls whether autofill for addresses is enabled.
95+
/// The default value is `TRUE`.
96+
[propget] HRESULT IsAddressAutofillEnabled([out, retval] BOOL* isAddressAutofillEnabled);
97+
/// Set the IsAddressAutofillEnabled property.
98+
[propput] HRESULT IsAddressAutofillEnabled([in] BOOL isAddressAutofillEnabled);
99+
}
100+
```
101+
## .NET and WinRT
102+
```c#
103+
namespace Microsoft.Web.WebView2.Core
104+
{
105+
public partial class CoreWebView2Settings
106+
{
107+
public bool IsPasswordAutofillEnabled { get; set; };
108+
public bool IsAddressAutofillEnabled {get; set; };
109+
}
110+
}
111+
112+
```

0 commit comments

Comments
 (0)