blob: 1556a52ceb17d737ff978109627df9858b463c09 [file] [log] [blame]
// Copyright 2018 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;
package autofill_assistant;
// Context contains client environment details.
message ClientContextProto {
message Chrome { optional string chrome_version = 1; }
oneof client { Chrome chrome = 1; }
}
// Get the list of scripts that can potentially be run on a url.
message SupportsScriptRequestProto {
optional string url = 1;
// Parameters that can be used to filter the scripts suitable for execution.
repeated ScriptParameterProto script_parameters = 2;
optional ClientContextProto client_context = 3;
}
message ScriptParameterProto {
// Parameter name, as found in the Intent, without prefix.
optional string name = 3;
optional string value = 2;
}
// Response of the list of supported scripts.
message SupportsScriptResponseProto {
repeated SupportedScriptProto scripts = 1;
}
// Supported script.
message SupportedScriptProto {
// This is the internal name of the script.
optional string path = 1;
message PresentationProto {
// Script name.
optional string name = 1;
// Precondition contains a set of conditions that must hold for a script to
// be executed. No precondition means that a script can run in any case.
optional ScriptPreconditionProto precondition = 3;
// Display priority of the script. Lowest number has highest priority, which
// means a script with priority 0 should be displayed before a script with
// priority 1.
optional int32 priority = 5;
// When set to true this script can be run in 'autostart mode'. Script won't
// be shown.
optional bool autostart = 8;
}
optional PresentationProto presentation = 2;
}
enum ScriptStatusProto {
// Never explicitly set. Reading this value means the enum field is either
// not set or set to a value not listed here.
UNKNOWN_SCRIPT_STATUS = 0;
// The script finished successfully.
SCRIPT_STATUS_SUCCESS = 1;
// The script failed.
SCRIPT_STATUS_FAILURE = 2;
// The user cancelled the script.
SCRIPT_STATUS_CANCELLED = 3;
// The script is currently running.
SCRIPT_STATUS_RUNNING = 4;
// The script was not run.
SCRIPT_STATUS_NOT_RUN = 5;
}
// Condition on the status of a previous script run.
message ScriptStatusMatchProto {
enum Comparator {
UNSPECIFIED = 0;
EQUAL = 1;
DIFFERENT = 2;
}
// Required. Path of the script whose status should be checked.
optional string script = 1;
// Required. The status the script should have for the condition to hold.
optional ScriptStatusProto status = 2;
// Optional. The comparison performed when checking the status. It will be
// interpreted as EQUAL if not set.
optional Comparator comparator = 3;
}
message ScriptPreconditionProto {
// Combined with AND: the elements referenced here must be present.
repeated ElementReferenceProto elements_exist = 3;
// Pattern of the path parts of the URL.
repeated string path_pattern = 5;
// Domain (exact match) excluding the last '/' character.
repeated string domain = 6;
// Combined with AND: all matches must be true for precondition to hold.
repeated ScriptParameterMatchProto script_parameter_match = 7;
repeated ScriptStatusMatchProto script_status_match = 8;
repeated FormValueMatchProto form_value_match = 9;
}
message ScriptParameterMatchProto {
// Parameter name, as found in the Intent, without prefix.
optional string name = 4;
// Checks whether the script parameter is present.
optional bool exists = 2 [default = true];
// Checks whether the script parameter has exact value. Empty or missing value
// is treated as wildcard - any value will pass.
optional string value_equals = 3;
}
message FormValueMatchProto {
// Required. The selector associated to the form element whose value should be
// checked.
optional ElementReferenceProto element = 1;
}
enum PolicyType {
UNKNOWN_POLICY = 0;
SCRIPT = 1;
}
message ScriptActionRequestProto {
optional ClientContextProto client_context = 7;
// The server payload received from the previous response.
optional bytes server_payload = 2;
oneof request {
InitialScriptActionsRequestProto initial_request = 4;
NextScriptActionsRequestProto next_request = 5;
}
}
// Initial request to get a script's actions.
message InitialScriptActionsRequestProto {
message QueryProto {
// The backend expects the |script_path| to be a repeated field. This field
// is expected to contain only one element.
repeated string script_path = 1;
optional PolicyType policy = 3;
}
optional QueryProto query = 3;
repeated ScriptParameterProto script_parameters = 2;
}
// Next request to get a script's actions.
message NextScriptActionsRequestProto {
// The result of processing each ActionProto from the previous response. This
// field must be in the same order as the actions in the original response.
// It may have less actions in case of failure.
repeated ProcessedActionProto processed_actions = 1;
}
// Response of a script's actions.
message ActionsResponseProto {
// Opaque data that should not be interpreted and must pass this back
// unchanged in the next request.
optional bytes server_payload = 2;
// Actions to be performed in order.
// Should stop processing as soon as an action fails.
repeated ActionProto actions = 3;
}
// An action could be performed.
message ActionProto {
// Wait these many milliseconds before executing the action, if set.
optional int32 action_delay_ms = 3;
// Opaque data that should not be interpreted by the client. The client must
// pass this back unchanged in the next request
optional bytes server_payload = 4;
oneof action_info {
ClickProto click = 5;
SelectOptionProto select_option = 7;
NavigateProto navigate = 9;
TellProto tell = 11;
FocusElementProto focus_element = 12;
WaitForDomProto wait_for_dom = 19;
UseCreditCardProto use_card = 28;
UseAddressProto use_address = 29;
UploadDomProto upload_dom = 18;
HighlightElementProto highlight_element = 31;
ShowDetailsProto show_details = 32;
ResetProto reset = 34;
StopProto stop = 35;
}
}
message ProcessedActionProto {
// The action that was processed.
optional ActionProto action = 1;
optional ProcessedActionStatusProto status = 2;
oneof result_data { string html_source = 12; }
}
enum ProcessedActionStatusProto {
UNKNOWN_ACTION_STATUS = 0;
ELEMENT_RESOLUTION_FAILED = 1;
ACTION_APPLIED = 2;
OTHER_ACTION_STATUS = 3;
}
// A reference to an unique element on the page, possibly nested in frames.
message ElementReferenceProto {
// A sequence of CSS selectors. Any non-final CSS selector is expected to
// arrive at a frame or an iframe, i.e. an element that contains another
// document.
// APIs are free to reject element references that do not refer to unique
// elements (i.e. resolve to more than one element on the page).
repeated string selectors = 2;
}
// Contain all arguments to perform a click.
message ClickProto {
optional ElementReferenceProto element_to_click = 1;
}
// Contain all arguments to perform a select option action.
message SelectOptionProto {
// The drop down element on which to select an option.
optional ElementReferenceProto element = 2;
// Value of the option to use.
optional string selected_option = 3;
}
// Contain a localized text message from the server.
message TellProto {
optional string message = 1;
}
// Contain all arguments to focus on an element.
message FocusElementProto {
// Element to focus on.
optional ElementReferenceProto element = 1;
// Optional title to show in the status bar.
optional string title = 2;
}
message AutofillStrings {
optional string fill_manually = 1;
optional string fill_form = 2;
optional string check_form = 3;
}
// Fill a form with an address if there is, otherwise fail this action.
message UseAddressProto {
// Message used to indicate what form fields should be filled with what
// information coming from the address.
message RequiredField {
enum AddressField {
UNDEFINED = 0;
FIRST_NAME = 1;
LAST_NAME = 2;
FULL_NAME = 3;
PHONE_NUMBER = 4;
EMAIL = 5;
ORGANIZATION = 6;
COUNTRY_CODE = 7;
REGION = 8; // e.g. state
STREET_ADDRESS = 9;
LOCALITY = 10; // e.g. city
DEPENDANT_LOCALITY = 11;
POSTAL_CODE = 12;
}
optional AddressField address_field = 1;
optional ElementReferenceProto element = 2;
}
// An optional name to allow to handle multiple addresses selection (for
// instance a billing and a delivery address).
optional string name = 1;
// An optional message to show to the user when asking to select an address.
// TODO(crbug.com/806868): Make the prompt a required field.
optional string prompt = 2;
// Reference to an element in the form that should be filled.
optional ElementReferenceProto form_field_element = 4;
// An optional list of fields that should be filled by this action.
repeated RequiredField required_fields = 6;
optional AutofillStrings strings = 8;
}
// Fill a form with a credit card if there is, otherwise fail this action.
message UseCreditCardProto {
// An optional message to show to the user when asking to select a card.
// TODO(crbug.com/806868): Make the prompt a required field.
optional string prompt = 1;
// A reference to the card number field in the form that should be filled.
optional ElementReferenceProto form_field_element = 3;
optional AutofillStrings strings = 8;
}
// Ask Chrome to wait for an element in the DOM. This can be used to only
// proceed to the next action once the page is ready.
message WaitForDomProto {
// Fail after waiting this amount of time.
optional int32 timeout_ms = 1;
// The element to wait for.
repeated string selectors = 2;
}
// Volatile upload of a portion of the dom for backend analysis, does not store
// anything.
message UploadDomProto {
// The element that should be a root of uploaded DOM. If empty then the whole
// page is returned.
optional ElementReferenceProto tree_root = 1;
}
// Contain all arguments to perform a highlight element action.
message HighlightElementProto {
// The element to highlight.
optional ElementReferenceProto element = 1;
}
// Load the given URL in the current tab.
message NavigateProto {
optional string url = 1;
}
// Resets Autofill Assistant: clears any state and server payload.
message ResetProto {}
// Stop Autofill Assistant.
message StopProto {}
message DateProto {
optional int64 year = 1;
// Month of the year in the range [1-12].
optional int32 month = 2;
// Day of the month in the range [1-31].
optional int32 day = 3;
}
message TimeProto {
// Hour in the range [0-23].
optional int32 hour = 1;
// Minute in the range [0-59].
optional int32 minute = 2;
// Second in the range [0-59].
optional int32 second = 3;
}
message DateTimeProto {
optional DateProto date = 1;
optional TimeProto time = 2;
}
message DetailsProto {
optional string title = 1;
optional string url = 2;
optional DateTimeProto datetime = 3;
optional string description = 4;
}
// Show contextual information.
message ShowDetailsProto {
optional DetailsProto details = 1;
}