1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.
//! Defines commands and events for Autofill.
//!
//! Types, command parameters and event payloads for the `Autofill`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CreditCard {
/// 16-digit credit card number.
pub number: String,
/// Name of the credit card owner.
pub name: String,
/// 2-digit expiry month.
#[serde(rename = "expiryMonth")]
pub expiry_month: String,
/// 4-digit expiry year.
#[serde(rename = "expiryYear")]
pub expiry_year: String,
/// 3-digit card verification code.
pub cvc: String,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddressField {
/// address field name, for example GIVEN_NAME. The full list of supported
/// field names:
/// <https://source.chromium.org/chromium/chromium/src/+/main:components/autofill/core/browser/field_types.cc;l=38>
pub name: String,
/// address field value, for example Jon Doe.
pub value: String,
}
/// A list of address fields.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddressFields {
pub fields: Vec<AddressField>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Address {
/// fields and values defining an address.
pub fields: Vec<AddressField>,
}
/// Defines how an address can be displayed like in
/// chrome://settings/addresses. Address UI is a two dimensional array, each
/// inner array is an "address information line", and when rendered in a UI
/// surface should be displayed as such. The following address UI for
/// instance: \[\[{name: "GIVE_NAME", value: "Jon"}, {name: "FAMILY_NAME",
/// value: "Doe"}\], \[{name: "CITY", value: "Munich"}, {name: "ZIP", value:
/// "81456"}\]\] should allow the receiver to render: Jon Doe Munich 81456
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddressUi {
/// A two dimension array containing the representation of values from an
/// address profile.
#[serde(rename = "addressFields")]
pub address_fields: Vec<AddressFields>,
}
/// Specified whether a filled field was done so by using the html
/// autocomplete attribute or autofill heuristics.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum FillingStrategy {
/// `autocompleteAttribute`
#[serde(rename = "autocompleteAttribute")]
AutocompleteAttribute,
/// `autofillInferred`
#[serde(rename = "autofillInferred")]
AutofillInferred,
/// A value this vendored schema does not list. Chrome adds values ahead of
/// the published protocol, so an unrecognised one is kept as it arrived
/// rather than failing the payload it came in.
#[serde(untagged)]
Unrecognized(String),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct FilledField {
/// The type of the field, e.g text, password etc.
#[serde(rename = "htmlType")]
pub html_type: String,
/// the html id
pub id: String,
/// the html name
pub name: String,
/// the field value
pub value: String,
/// The actual field type, e.g FAMILY_NAME
#[serde(rename = "autofillType")]
pub autofill_type: String,
/// The filling strategy
#[serde(rename = "fillingStrategy")]
pub filling_strategy: FillingStrategy,
/// The frame the field belongs to
#[serde(rename = "frameId")]
pub frame_id: crate::protocol::page::FrameId,
/// The form field's DOM node
#[serde(rename = "fieldId")]
pub field_id: crate::protocol::dom::BackendNodeId,
}
/// Trigger autofill on a form identified by the fieldId. If the field and
/// related form cannot be autofilled, returns an error. Returns once the
/// values have been applied to the form fields.
///
/// Parameters of `Autofill.trigger`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct TriggerParams {
/// Identifies a field that serves as an anchor for autofill.
#[serde(rename = "fieldId")]
pub field_id: crate::protocol::dom::BackendNodeId,
/// Identifies the frame that field belongs to.
#[serde(rename = "frameId", default, skip_serializing_if = "Option::is_none")]
pub frame_id: Option<crate::protocol::page::FrameId>,
/// Credit card information to fill out the form. Credit card data is not
/// saved. Mutually exclusive with `address`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub card: Option<CreditCard>,
/// Address to fill out the form. Address data is not saved. Mutually
/// exclusive with `card`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
}
impl crate::typed::Command for TriggerParams {
const METHOD: &'static str = "Autofill.trigger";
type Returns = crate::typed::NoReturns;
}
/// Set addresses so that developers can verify their forms implementation.
///
/// Parameters of `Autofill.setAddresses`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetAddressesParams {
pub addresses: Vec<Address>,
}
impl crate::typed::Command for SetAddressesParams {
const METHOD: &'static str = "Autofill.setAddresses";
type Returns = crate::typed::NoReturns;
}
/// Disables autofill domain notifications.
///
/// Parameters of `Autofill.disable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DisableParams {}
impl crate::typed::Command for DisableParams {
const METHOD: &'static str = "Autofill.disable";
type Returns = crate::typed::NoReturns;
}
/// Enables autofill domain notifications.
///
/// Parameters of `Autofill.enable`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct EnableParams {}
impl crate::typed::Command for EnableParams {
const METHOD: &'static str = "Autofill.enable";
type Returns = crate::typed::NoReturns;
}
/// Emitted when an address form is filled.
///
/// Payload of the `Autofill.addressFormFilled` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddressFormFilledEvent {
/// Information about the fields that were filled
#[serde(rename = "filledFields")]
pub filled_fields: Vec<FilledField>,
/// An UI representation of the address used to fill the form. Consists of a
/// 2D array where each child represents an address/profile line.
#[serde(rename = "addressUi")]
pub address_ui: AddressUi,
}
impl crate::typed::Event for AddressFormFilledEvent {
const METHOD: &'static str = "Autofill.addressFormFilled";
}