blob: f6f438d79478ea4a61ff107ab3d878a4809b0965 [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto2";
option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.chrome.browser.autofill_assistant.proto";
option java_multiple_files = true;
package autofill_assistant;
import "action_value.proto";
import "model.proto";
import "view_layout.proto";
message GenericUserInterfaceProto {
// The root view, usually a view container.
optional ViewProto root_view = 1;
// The interactions for this generic user interface.
optional InteractionsProto interactions = 2;
// The model containing initial values for interactive UI.
optional ModelProto model = 3;
}
message InteractionsProto {
repeated InteractionProto interactions = 1;
}
// An interaction consists of a set of trigger events and a series of actions.
message InteractionProto {
// Functions to call each time one of the events happens, in the specified
// order.
repeated CallbackProto callbacks = 1;
// The trigger events for |callbacks|.
repeated EventProto trigger_event = 2;
}
// UI Actions to invoke.
message CallbackProto {
oneof kind {
SetModelValueProto set_value = 1;
ShowInfoPopupProto show_info_popup = 2;
ShowListPopupProto show_list_popup = 3;
ComputeValueProto compute_value = 4;
SetUserActionsProto set_user_actions = 5;
EndActionProto end_action = 6;
ShowCalendarPopupProto show_calendar_popup = 7;
SetTextProto set_text = 8;
ToggleUserActionProto toggle_user_action = 9;
SetViewVisibilityProto set_view_visibility = 11;
SetViewEnabledProto set_view_enabled = 12;
ShowGenericUiPopupProto show_generic_popup = 13;
CreateNestedGenericUiProto create_nested_ui = 14;
ClearViewContainerProto clear_view_container = 15;
ForEachProto for_each = 16;
}
// Optional model identifier pointing to a single boolean. If set, the
// callback will only be invoked if the condition is true.
optional string condition_model_identifier = 10;
}
message EventProto {
oneof kind {
OnModelValueChangedEventProto on_value_changed = 1;
OnViewClickedEventProto on_view_clicked = 2;
OnUserActionCalled on_user_action_called = 3;
OnTextLinkClickedProto on_text_link_clicked = 4;
OnPopupDismissedProto on_popup_dismissed = 5;
OnViewContainerClearedProto on_view_container_cleared = 6;
}
}
// Event that is triggered whenever |model_identifier| changes.
message OnModelValueChangedEventProto {
// The identifier of the value to observe.
optional string model_identifier = 1;
}
// Event that is triggered whenever |view_identifier| is clicked.
message OnViewClickedEventProto {
// The identifier of the view to observe.
optional string view_identifier = 1;
}
// Event that is triggered when |user_action_identifier| is called.
message OnUserActionCalled {
// The identifier of the user action to observe.
optional string user_action_identifier = 1;
}
// Event that is triggered when clicking the specified text link.
message OnTextLinkClickedProto {
// The number of the text link to observe, i.e., the number in the html-style
// tag <link3>...</link3>.
optional int32 text_link = 1;
}
// Event that is triggered when the specified popup is dismissed.
message OnPopupDismissedProto {
// The identifier of the popup to observe.
optional string popup_identifier = 1;
}
// Event which is called whenever |view_identifier| was cleared with a
// |ClearViewContainer| interaction.
message OnViewContainerClearedProto {
// The view container that was cleared.
optional string view_identifier = 1;
}
// Callback that writes the specified value to |model_identifier|.
message SetModelValueProto {
// The model identifier to write to.
optional string model_identifier = 1;
// The value to write.
optional ValueReferenceProto value = 3;
reserved 2;
}
// Computes a value and stores the result to |result_model_identifier|.
message ComputeValueProto {
oneof kind {
// Computes the logical AND of the specified model identifiers.
BooleanAndProto boolean_and = 2;
// Computes the logical OR of the specified model identifiers.
BooleanOrProto boolean_or = 3;
// Computes the logical NOT of the specified model identifiers.
BooleanNotProto boolean_not = 4;
// Creates a string representation of the specified value.
ToStringProto to_string = 5;
// Compares two values.
ValueComparisonProto comparison = 6;
// Computes the sum of two single integers.
IntegerSumProto integer_sum = 7;
// Writes safe-to-transmit parts of the input credit card to the result.
CreateCreditCardResponseProto create_credit_card_response = 8;
// Writes safe-to-transmit parts of the input login option to the result.
CreateLoginOptionResponseProto create_login_option_response = 9;
// Check if a string value is empty.
StringEmptyProto string_empty = 10;
}
// The model identifier to write the result to.
optional string result_model_identifier = 1;
}
// Performs a logical AND on all specified values.
message BooleanAndProto {
// The values to logically AND. All values must be single booleans.
repeated ValueReferenceProto values = 2;
reserved 1;
}
// Performs a logical OR on all specified values.
message BooleanOrProto {
// The values to logically OR. All values must be single booleans.
repeated ValueReferenceProto values = 2;
reserved 1;
}
// Performs a logical NOT on the specified value.
message BooleanNotProto {
// The value to logically invert. Must be a single boolean.
optional ValueReferenceProto value = 2;
reserved 1;
}
// Creates a string representation of the specified value. For input lists, will
// create a corresponding string result list.
message ToStringProto {
// The value to stringify.
optional ValueReferenceProto value = 3;
// Optional format options.
oneof format_options {
DateFormatProto date_format = 2;
AutofillFormatProto autofill_format = 4;
}
reserved 1;
}
// A format string for a date, such as "EEE, MMM d". See
// http://userguide.icu-project.org/formatparse/datetime for full specification.
message DateFormatProto {
optional string date_format = 1;
}
// Format options for autofill profiles and credit cards.
message AutofillFormatProto {
// Fields we add that are not mapped to field_types.h. The values must be
// negative to avoid overlap with field_types.h.
// Note: CREDIT_CARD_VERIFICATION_CODE and CREDIT_CARD_RAW_NUMBER are only
// available in UseCreditCardAction, as they require the CVC dialog to be
// shown.
enum AutofillAssistantCustomField {
UNDEFINED = 0;
CREDIT_CARD_VERIFICATION_CODE = -1;
CREDIT_CARD_NETWORK = -2;
CREDIT_CARD_RAW_NUMBER = -3;
CREDIT_CARD_NUMBER_LAST_FOUR_DIGITS = -4;
CREDIT_CARD_NETWORK_FOR_DISPLAY = -5;
// Currently only US states are supported. The state name is in lower case,
// starting with a capital.
ADDRESS_HOME_STATE_NAME = -6;
CREDIT_CARD_NON_PADDED_EXP_MONTH = -7;
// The two letter country code, e.g. CH.
ADDRESS_HOME_COUNTRY_CODE = -8;
}
// The format string to use. May contain one or multiple key
// placeholders, where the key is an integer corresponding to
// entries from field_types.h or AutofillAssistantCustomField.
optional ValueExpression value_expression = 3;
// The locale to use when stringifying data. Invalid locales will
// automatically default to "en-US".
optional string locale = 2;
reserved 1;
}
// A comparison of two values in the form |value_a| <mode> |value_b|. EQUAL and
// NOT_EQUAL are supported for all values. All other comparison modes are only
// supported for single integers, strings, and dates.
message ValueComparisonProto {
enum Mode {
UNDEFINED = 0;
LESS = 1;
LESS_OR_EQUAL = 2;
EQUAL = 3;
GREATER_OR_EQUAL = 4;
GREATER = 5;
NOT_EQUAL = 6;
}
// The first value to compare.
optional ValueReferenceProto value_a = 4;
// The second value to compare.
optional ValueReferenceProto value_b = 5;
// The comparison mode.
optional Mode mode = 3;
reserved 1, 2;
}
// Computes the sum of all input integers.
message IntegerSumProto {
// The values to sum. All values must be single integers.
repeated ValueReferenceProto values = 3;
reserved 1, 2;
}
// Creates a safe-to-transmit CreditCardResponseProto for the input |value|.
message CreateCreditCardResponseProto {
// The input CreditCardProto.
optional ValueReferenceProto value = 1;
}
// Creates a safe-to-transmit LoginOptionResponseProto for the input |value|.
message CreateLoginOptionResponseProto {
// The input LoginOptionProto.
optional ValueReferenceProto value = 1;
}
// Checks whether or not a string value is empty.
message StringEmptyProto {
// The input string.
optional ValueReferenceProto value = 1;
}
// Displays a standard info popup.
message ShowInfoPopupProto {
optional InfoPopupProto info_popup = 1;
}
// Displays a popup showing a list of strings to choose from. Depending on
// |allow_multiselect|, users will be able to select one or multiple items from
// the list.
message ShowListPopupProto {
// The popup item type, corresponding to
// chromium/content/browser/input/PopupItemType.java.
enum ItemType {
GROUP = 0;
DISABLED = 1;
ENABLED = 2;
}
// The item names to show in the list. Must be a StringList.
optional ValueReferenceProto item_names = 6;
// Optional, must be the same length as the list stored at
// |items_list_model_identifier| if specified. Will default to ENABLED for all
// items if not specified. Must be a list of int32 |ItemType| if specified.
optional ValueReferenceProto item_types = 7;
// The indices of the selected items (both input and output). Must be a list
// of integers.
optional string selected_item_indices_model_identifier = 3;
// Whether to allow the selection of multiple items or not.
optional bool allow_multiselect = 4;
// Optional output model identifier to store the names of the selected items
// in a StringList.
optional string selected_item_names_model_identifier = 5;
reserved 1, 2;
}
// Sets the list of available user actions. User actions are either direct
// actions performed via assistant and/or chips that users can tap.
message SetUserActionsProto {
// The user actions to set. Must contain a UserActionList value.
optional ValueReferenceProto user_actions = 2;
reserved 1;
}
// Enables or disables a single user action. Modifies the value in-place.
message ToggleUserActionProto {
// Input and output. Should point to a list of user actions to modify.
optional string user_actions_model_identifier = 1;
// The identifier of the specific user action to modify.
optional string user_action_identifier = 2;
// Whether the user action should be enabled or disabled. Should be a single
// boolean.
optional ValueReferenceProto enabled = 4;
reserved 3;
}
// Ends the generic Ui action (this is usually tied to a chip).
//
// This behaves exactly the same as tapping a regular chip would in any other
// action, i.e., the result of the action (|status| + model) is written to the
// action response, which will be sent to the backend.
message EndActionProto {
// The status to report to the backend.
optional ProcessedActionStatusProto status = 1;
}
// Displays a calendar popup that lets the user select a date.
message ShowCalendarPopupProto {
// The date model identifier (both input and output). Must point to a single
// Date. If not set, the calendar will default to the current date.
optional string date_model_identifier = 1;
// The minimum allowed date. Must point to a single Date.
optional ValueReferenceProto min_date = 4;
// The maximum allowed date. Must point to a single Date.
optional ValueReferenceProto max_date = 5;
reserved 2, 3;
}
// Modifies the displayed text of a text view or a text input view.
message SetTextProto {
// The text to set. Must be a single string.
optional ValueReferenceProto text = 3;
// The text view to modify. Must point to a text view or a text input
// view.
optional string view_identifier = 2;
reserved 1;
}
// Modifies a view's visibiliy.
message SetViewVisibilityProto {
// The view to modify.
optional string view_identifier = 1;
// The visibility flag. Must be a single boolean.
optional ValueReferenceProto visible = 3;
reserved 2;
}
// Shows a popup with generic UI.
message ShowGenericUiPopupProto {
// The user interface to show. Note that nested user models are merged into
// the global one, so take care to avoid accidental identifier overlap.
optional GenericUserInterfaceProto generic_ui = 1;
// Mandatory identifier for this popup, used in the corresponding trigger
// events.
optional string popup_identifier = 2;
}
// Enables or disables a view. Note that disabled views won't react to click
// events.
message SetViewEnabledProto {
// The view to modify.
optional string view_identifier = 1;
// Whether the view should be enabled or not. Must point to a single boolean.
optional ValueReferenceProto enabled = 2;
}
// Creates new UI and interactions, i.e., a nested instance and attaches it to
// |parent_view_identifier|. Nested UI instances have their own view layout and
// interactions, but share the same model with their parent. All interactions
// between ancestor and descendant UIs must pass through the user model, as
// neither can directly reference views or interactions of the other.
//
// Use |ClearViewContainerProto| on a nested UI's view parent to detach and
// destroy the nested UI.
message CreateNestedGenericUiProto {
// Identifier for the newly created instance.
optional string generic_ui_identifier = 1;
// The UI to create.
optional GenericUserInterfaceProto generic_ui = 2;
// The view identifier of the parent to attach (=append) this UI to.
optional string parent_view_identifier = 3;
}
// Removes all views from the target view container. Nested UI instances
// attached to |view_identifier| will be destroyed.
message ClearViewContainerProto {
// The view container to clear.
optional string view_identifier = 1;
}
// Invokes |callbacks| for each item in the loop value. Automatically replaces
// instances of "${i}" in model and view identifiers with the loop counter.
message ForEachProto {
// The loop counter, usually "i", "j", etc. Callbacks may use this counter
// in view and model identifiers by using "${i}"" placeholders, e.g.,
// "profiles[${i}]" or "my_view_${i}".
optional string loop_counter = 1;
// The value list to loop over.
optional string loop_value_model_identifier = 2;
// The callbacks to invoke for every iteration of the loop.
repeated CallbackProto callbacks = 3;
}