Class Autocomplete


public class Autocomplete extends Object
The Autocomplete API provides a way to leverage Gecko's input form handling for autocompletion.

The API is split into two parts: 1. Storage-level delegates. 2. User-prompt delegates.

The storage-level delegates connect Gecko mechanics to the app's storage, e.g., retrieving and storing of login entries.

The user-prompt delegates propagate decisions to the app that could require user choice, e.g., saving or updating of login entries or the selection of a login entry out of multiple options.

Throughout the documentation, we will refer to the filling out of input forms using two terms: 1. Autofill: automatic filling without user interaction. 2. Autocomplete: semi-automatic filling that requires user prompting for the selection.


Autocomplete/Fetch API

GeckoView loads which contains (for the purpose of this example) elements resembling a login form, e.g.,

     <input type="text" placeholder="username">
     <input type="password" placeholder="password">
     <input type="submit" value="submit">

With the document parsed and the login input fields identified, GeckoView dispatches a StorageDelegate.onLoginFetch("") request to fetch logins for the given domain.

Based on the provided login entries, GeckoView will attempt to autofill the login input fields, if there is only one suitable login entry option.

In the case of multiple valid login entry options, GeckoView dispatches a GeckoSession.PromptDelegate.onLoginSelect request, which allows for user-choice delegation.

Based on the returned login entries, GeckoView will attempt to autofill/autocomplete the login input fields.

Update API

When the user submits some login input fields, GeckoView dispatches another StorageDelegate.onLoginFetch("") request to check whether the submitted login exists or whether it's a new or updated login entry.

If the submitted login is already contained as-is in the collection returned by onLoginFetch, then GeckoView dispatches StorageDelegate.onLoginUsed with the submitted login entry.

If the submitted login is a new or updated entry, GeckoView dispatches a sequence of requests to save/update the login entry, see the Save API example.

Save API

The user enters new or updated (password) login credentials in some login input fields and submits explicitely (submit action) or by navigation. GeckoView identifies the entered credentials and dispatches a GeckoSession.PromptDelegate.onLoginSave(session, request) with the provided credentials.

The app may dismiss the prompt request via return GeckoResult.fromValue(prompt.dismiss()) which terminates this saving request, or confirm it via return GeckoResult.fromValue(prompt.confirm(login)) where login either holds the credentials originally provided by the prompt request ( prompt.logins[0]) or a new or modified login entry.

The login entry returned in a confirmed save prompt is used to request for saving in the runtime delegate via StorageDelegate.onLoginSave(login). If the app has already stored the entry during the prompt request handling, it may ignore this storage saving request.

See Also:
  • Constructor Details

    • Autocomplete

      protected Autocomplete()