List icon Contents

Passwords

This guide describes how to save, update, and manage passwords the user enters in a new form online.

Overview

Chromium has a built-in functionality that allows remembering the entered credentials when the user submits a new form containing username and password. The library will ask you if you’d like to save the credentials.

If you save them, the next time you load the form, the library will suggest autofill it.

Password autofil

Saving passwords

When the user submits a new form containing a username and password, the SavePasswordHandler will be called. In the handler, you can decide whether to save the credentials for this website by returning the “Save” or “Never” option. For example:

C#
VB
Browser.Passwords.SavePasswordHandler = 
    new Handler<SavePasswordParameters, SavePasswordResponse>(p =>
    {
        return SavePasswordResponse.Save;
    });
Copied
Browser.Passwords.SavePasswordHandler = 
    New Handler(Of SavePasswordParameters, SavePasswordResponse)(Function(p)
        Return SavePasswordResponse.Save
    End Function)
Copied

If you choose to save the password, it will be added to the password store. If you select the “Never” option, the library will not suggest saving the passwords for this web page anymore.

Updating passwords

When the user submits the previously submitted form with the same username and a new password, the UpdatePasswordHandler will be called. In this handler, you can decide whether to update the existing credentials or ignore the new value. For example:

C#
VB
Browser.Passwords.UpdatePasswordHandler = 
    new Handler<UpdatePasswordParameters, UpdatePasswordResponse>(p =>
    {
        return UpdatePasswordResponse.Update;
    });
Copied
Browser.Passwords.UpdatePasswordHandler = 
    New Handler(Of UpdatePasswordParameters, UpdatePasswordResponse)(Function(p)
        Return UpdatePasswordResponse.Update
    End Function)
Copied

Managing passwords

Each element in the password store is represented by a PasswordRecord instance. It contains the user’s login and the URL of a web page where the form was submitted. It doesn’t contain the password itself.

To read all saved and blocklisted records, use:

C#
VB
IReadOnlyList<PasswordRecord> allPasswords = 
    Engine.Profiles.Default.PasswordStore.All;
Copied
Dim allPasswords As IReadOnlyList(Of PasswordRecord) = 
    Engine.Profiles.Default.PasswordStore.All
Copied

To read only saved records, use:

C#
VB
IReadOnlyList<PasswordRecord> savedPasswords = 
    Engine.Profiles.Default.PasswordStore.AllSaved;
Copied
Dim savedPasswords As IReadOnlyList(Of PasswordRecord) = 
    Engine.Profiles.Default.PasswordStore.AllSaved
Copied

To read only the records with the websites for which the passwords will never be saved, use:

C#
VB
IReadOnlyList<PasswordRecord> neverSavedPasswords = 
    Engine.Profiles.Default.PasswordStore.AllNeverSaved;
Copied
Dim neverSavedPasswords As IReadOnlyList(Of PasswordRecord) = 
    Engine.Profiles.Default.PasswordStore.AllNeverSaved
Copied

To remove all records from the store use:

C#
VB
PasswordStore.Clear();
Copied
PasswordStore.Clear()
Copied

To remove the records associated with a specific URL use:

C#
VB
PasswordStore.RemoveByUrl(url);
Copied
PasswordStore.RemoveByUrl(url)
Copied
Go Top