// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module autofill.mojom;
import "components/autofill/core/common/mojom/autofill_types.mojom";
import "mojo/public/mojom/base/string16.mojom";
// There is one instance of this interface per render frame in the render
// process. All methods are called by browser on renderer.
interface AutofillAgent {
// Triggers form re-extraction the new forms. This is done when a form is seen
// in a subframe and it is not known which form is its parent.
TriggerFormExtraction();
// Triggers form re-extraction the new forms and notifies the caller when
// it's done.
// If `success == false`, TriggerFormExtractionWithResponse() was triggered
// while another TriggerFormExtractionWithResponse() was ongoing.
TriggerFormExtractionWithResponse() => (bool success);
// Fills or previews the form identified by `form` with the data of its
// fields. `action_type` denotes if the action is a Fill or Undo.
// `action_persistence` denotes if the operation is a Fill or Preview.
ApplyFieldsAction(FormActionType action_type,
ActionPersistence action_persistence,
array<FormFieldData_FillData> fields);
// Fills or previews the field identified by `field` with `value`.
// `action_persistence` denotes if the operation is a Fill or Preview.
// `action_type` indicates whether to replace the field's entire value
// or only the current selection or select all text inside the field.
// For non-text fields, this parameter has no effect. This must not be
// `kReplaceSelection` if `action_persistence` is `kPreview`.
// Enabling this is desirable but not implemented, yet.
// If `action_type` is `kSelectAll`, then the `value` must be empty.
ApplyFieldAction(FieldActionType action_type,
ActionPersistence action_persistence,
FieldRendererId field,
mojo_base.mojom.String16 value);
// Extracts the given form and responds with the FormData if that form can
// be found and extracted.
ExtractForm(FormRendererId form) => (FormData? form);
// Sends the heuristic and server field type predictions to the renderer.
FieldTypePredictionsAvailable(array<FormDataPredictions> forms);
// Tells the renderer that the Autofill previewed form should be cleared.
ClearPreviewedForm();
// Tells the renderer to trigger Autofill suggestions on the `field`, as if
// triggered through the provided `trigger_source`.
// For the most part, suggestions are triggered through Blink events on the
// renderer-side. However, manual fallbacks from the context menu are
// triggered from the browser processes. They need to make another round-trip
// to the renderer, since rendering suggestions relies on the `field`'s
// position. Since the browser process doesn't have up-to-date coordinates,
// suggestions are triggered through the renderer, which causes the field and
// its coordinates to be re-extracted.
// Assuming the `field` is found, the driver's `AskForValuesToFill()` will be
// called.
TriggerSuggestions(FieldRendererId field,
AutofillSuggestionTriggerSource trigger_source);
// Sets the autofill/autocomplete suggestion availability of `field` (if it is
// still the currently selected node).
SetSuggestionAvailability(
FieldRendererId field,
AutofillSuggestionAvailability suggestion_availability);
// Sets the value of `field` (if it is still the currently selected node).
// to the given data list value.
AcceptDataListSuggestion(FieldRendererId field,
mojo_base.mojom.String16 value);
// Tells the renderer to preview the username and password with the given
// values.
PreviewPasswordSuggestion(mojo_base.mojom.String16 username,
mojo_base.mojom.String16 password);
// Tells the renderer to preview the generated password.
PreviewPasswordGenerationSuggestion(mojo_base.mojom.String16 password);
// Returns a vector of four digit combinations present in the DOM of a
// webpage. Used to check for the presence of the virtual card last four in
// the DOM prior to offering CVC autofill for a virtual card saved on a
// merchant website.
GetPotentialLastFourCombinationsForStandaloneCvc() =>
(array<string> potential_matches);
};
// There is one instance of this interface per render frame in the render
// process.
interface PasswordAutofillAgent {
// Provides fill information for a password form, which can fill the form and
// prepare field autocomplete for multiple matching logins. Lets the renderer
// know if it should disable the popup because the browser process will own
// the popup UI.
SetPasswordFillData(PasswordFormFillData form_data);
// Tells the renderer to fill the username and password with with given
// values.
FillPasswordSuggestion(mojo_base.mojom.String16 username,
mojo_base.mojom.String16 password);
// Lets the renderer know that there are no saved credentials for filling.
// This is the "no results" equivalent of SetPasswordFillData.
InformNoSavedCredentials(bool should_show_popup_without_passwords);
// Fills the given `credential` into the last focused text input.
FillIntoFocusedField(bool is_password, mojo_base.mojom.String16 credential);
// Previews the given `value` into the field identified by `field_id`.
PreviewField(FieldRendererId field_id, mojo_base.mojom.String16 value);
// Fills the given `value` into the field identified by `field_id`.
FillField(FieldRendererId field_id, mojo_base.mojom.String16 value);
// Notification to start (`active` == true) or stop (`active` == false)
// logging the decisions made about saving the password.
SetLoggingState(bool active);
// Informs the renderer that the Keyboard Replacing Surface has been closed.
// Indicates whether the virtual keyboard should be shown instead.
// TODO(crbug.com/40274966): Remove this API once PasswordSuggestionBottomSheetV2
// is launched.
[EnableIf=is_android]
KeyboardReplacingSurfaceClosed(bool show_virtual_keyboard);
// Triggers a form submission on the last interacted element.
[EnableIf=is_android]
TriggerFormSubmission();
// Annotate password related (username, password) DOM input elements with
// corresponding HTML attributes. It is used only for debugging.
AnnotateFieldsWithParsingResult(ParsingResult parsing_result);
};
// There is one instance of this interface per render frame in the render
// process.
interface PasswordGenerationAgent {
// Tells the renderer to populate the correct password fields with this
// generated password.
GeneratedPasswordAccepted(mojo_base.mojom.String16 generated_password);
// Tells the renderer to find a focused element, and if it is a password field
// eligible for generation then to trigger generation by returning
// non-empty PasswordGenerationUIData.
TriggeredGeneratePassword() => (PasswordGenerationUIData? data);
// Tells the renderer that a password can be generated on the fields
// identified by `form`.
FoundFormEligibleForGeneration(PasswordFormGenerationData form);
// Tells the renderer to advance focus to the next field after password fields
// (assuming that password fields are adjacent in account creation).
FocusNextFieldAfterPasswords();
};