1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Multiply-included message file, hence no include guard.
10 #include "base/strings/string16.h"
11 #include "base/time/time.h"
12 #include "components/autofill/content/common/autofill_param_traits_macros.h"
13 #include "components/autofill/core/common/form_data.h"
14 #include "components/autofill/core/common/form_data_predictions.h"
15 #include "components/autofill/core/common/form_field_data.h"
16 #include "components/autofill/core/common/form_field_data_predictions.h"
17 #include "components/autofill/core/common/password_form.h"
18 #include "components/autofill/core/common/password_form_fill_data.h"
19 #include "components/autofill/core/common/web_element_descriptor.h"
20 #include "content/public/common/common_param_traits.h"
21 #include "content/public/common/common_param_traits_macros.h"
22 #include "ipc/ipc_message_macros.h"
23 #include "ipc/ipc_message_utils.h"
24 #include "third_party/WebKit/public/web/WebFormElement.h"
25 #include "ui/gfx/geometry/rect.h"
26 #include "ui/gfx/ipc/gfx_param_traits.h"
29 #define IPC_MESSAGE_START AutofillMsgStart
31 IPC_ENUM_TRAITS_MAX_VALUE(autofill::FormFieldData::RoleAttribute
,
32 autofill::FormFieldData::ROLE_ATTRIBUTE_OTHER
)
34 IPC_ENUM_TRAITS_MAX_VALUE(base::i18n::TextDirection
,
35 base::i18n::TEXT_DIRECTION_NUM_DIRECTIONS
- 1)
37 IPC_STRUCT_TRAITS_BEGIN(autofill::WebElementDescriptor
)
38 IPC_STRUCT_TRAITS_MEMBER(descriptor
)
39 IPC_STRUCT_TRAITS_MEMBER(retrieval_method
)
40 IPC_STRUCT_TRAITS_END()
42 IPC_ENUM_TRAITS_MAX_VALUE(autofill::WebElementDescriptor::RetrievalMethod
,
43 autofill::WebElementDescriptor::NONE
)
45 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData
)
46 IPC_STRUCT_TRAITS_MEMBER(label
)
47 IPC_STRUCT_TRAITS_MEMBER(name
)
48 IPC_STRUCT_TRAITS_MEMBER(value
)
49 IPC_STRUCT_TRAITS_MEMBER(form_control_type
)
50 IPC_STRUCT_TRAITS_MEMBER(autocomplete_attribute
)
51 IPC_STRUCT_TRAITS_MEMBER(role
)
52 IPC_STRUCT_TRAITS_MEMBER(max_length
)
53 IPC_STRUCT_TRAITS_MEMBER(is_autofilled
)
54 IPC_STRUCT_TRAITS_MEMBER(is_checked
)
55 IPC_STRUCT_TRAITS_MEMBER(is_checkable
)
56 IPC_STRUCT_TRAITS_MEMBER(is_focusable
)
57 IPC_STRUCT_TRAITS_MEMBER(should_autocomplete
)
58 IPC_STRUCT_TRAITS_MEMBER(text_direction
)
59 IPC_STRUCT_TRAITS_MEMBER(option_values
)
60 IPC_STRUCT_TRAITS_MEMBER(option_contents
)
61 IPC_STRUCT_TRAITS_END()
63 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldDataPredictions
)
64 IPC_STRUCT_TRAITS_MEMBER(field
)
65 IPC_STRUCT_TRAITS_MEMBER(signature
)
66 IPC_STRUCT_TRAITS_MEMBER(heuristic_type
)
67 IPC_STRUCT_TRAITS_MEMBER(server_type
)
68 IPC_STRUCT_TRAITS_MEMBER(overall_type
)
69 IPC_STRUCT_TRAITS_END()
71 IPC_STRUCT_TRAITS_BEGIN(autofill::FormDataPredictions
)
72 IPC_STRUCT_TRAITS_MEMBER(data
)
73 IPC_STRUCT_TRAITS_MEMBER(signature
)
74 IPC_STRUCT_TRAITS_MEMBER(experiment_id
)
75 IPC_STRUCT_TRAITS_MEMBER(fields
)
76 IPC_STRUCT_TRAITS_END()
78 IPC_STRUCT_TRAITS_BEGIN(autofill::UsernamesCollectionKey
)
79 IPC_STRUCT_TRAITS_MEMBER(username
)
80 IPC_STRUCT_TRAITS_MEMBER(password
)
81 IPC_STRUCT_TRAITS_END()
83 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordFormFillData
)
84 IPC_STRUCT_TRAITS_MEMBER(name
)
85 IPC_STRUCT_TRAITS_MEMBER(origin
)
86 IPC_STRUCT_TRAITS_MEMBER(action
)
87 IPC_STRUCT_TRAITS_MEMBER(user_submitted
)
88 IPC_STRUCT_TRAITS_MEMBER(username_field
)
89 IPC_STRUCT_TRAITS_MEMBER(password_field
)
90 IPC_STRUCT_TRAITS_MEMBER(preferred_realm
)
91 IPC_STRUCT_TRAITS_MEMBER(additional_logins
)
92 IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames
)
93 IPC_STRUCT_TRAITS_MEMBER(wait_for_username
)
94 IPC_STRUCT_TRAITS_END()
96 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordAndRealm
)
97 IPC_STRUCT_TRAITS_MEMBER(password
)
98 IPC_STRUCT_TRAITS_MEMBER(realm
)
99 IPC_STRUCT_TRAITS_END()
101 IPC_ENUM_TRAITS_MAX_VALUE(
102 blink::WebFormElement::AutocompleteResult
,
103 blink::WebFormElement::AutocompleteResultErrorInvalid
)
105 // Singly-included section for type definitions.
106 #ifndef COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
107 #define COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
109 // IPC_MESSAGE macros fail on the std::map, when expanding. We need to define
110 // a type to avoid that.
111 using FormDataFieldDataMap
=
112 std::map
<autofill::FormData
, autofill::FormFieldData
>;
114 #endif // COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
116 // Autofill messages sent from the browser to the renderer.
118 // Tells the render frame that a user gesture was observed somewhere in the tab
119 // (including in a different frame).
120 IPC_MESSAGE_ROUTED0(AutofillMsg_FirstUserGestureObservedInTab
)
122 // Instructs the renderer to immediately return an IPC acknowledging the ping.
123 // This is used to correctly sequence events, since IPCs are guaranteed to be
124 // processed in order.
125 IPC_MESSAGE_ROUTED0(AutofillMsg_Ping
)
127 // Instructs the renderer to fill the active form with the given form data.
128 IPC_MESSAGE_ROUTED2(AutofillMsg_FillForm
,
130 autofill::FormData
/* form */)
132 // Instructs the renderer to preview the active form with the given form data.
133 IPC_MESSAGE_ROUTED2(AutofillMsg_PreviewForm
,
135 autofill::FormData
/* form */)
137 // Fill a password form and prepare field autocomplete for multiple
138 // matching logins. Lets the renderer know if it should disable the popup
139 // because the browser process will own the popup UI. |key| serves for
140 // identifying the fill form data in subsequent
141 // AutofillHostMsg_ShowPasswordSuggestions messages to the browser.
142 IPC_MESSAGE_ROUTED2(AutofillMsg_FillPasswordForm
,
144 autofill::PasswordFormFillData
/* the fill form data*/)
146 // Notification to start (|active| == true) or stop (|active| == false) logging
147 // the decisions made about saving the password.
148 IPC_MESSAGE_ROUTED1(AutofillMsg_SetLoggingState
, bool /* active */)
150 // Send the heuristic and server field type predictions to the renderer.
152 AutofillMsg_FieldTypePredictionsAvailable
,
153 std::vector
<autofill::FormDataPredictions
> /* forms */)
155 // Clears the currently displayed Autofill results.
156 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearForm
)
158 // Tells the renderer that the Autofill previewed form should be cleared.
159 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearPreviewedForm
)
161 // Sets the currently selected node's value.
162 IPC_MESSAGE_ROUTED1(AutofillMsg_FillFieldWithValue
,
163 base::string16
/* value */)
165 // Sets the suggested value for the currently previewed node.
166 IPC_MESSAGE_ROUTED1(AutofillMsg_PreviewFieldWithValue
,
167 base::string16
/* value */)
169 // Sets the currently selected node's value to be the given data list value.
170 IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptDataListSuggestion
,
171 base::string16
/* accepted data list value */)
173 // Tells the renderer to populate the correct password fields with this
174 // generated password.
175 IPC_MESSAGE_ROUTED1(AutofillMsg_GeneratedPasswordAccepted
,
176 base::string16
/* generated_password */)
178 // Tells the renderer to fill the username and password with with given
180 IPC_MESSAGE_ROUTED2(AutofillMsg_FillPasswordSuggestion
,
181 base::string16
/* username */,
182 base::string16
/* password */)
184 // Tells the renderer to preview the username and password with the given
186 IPC_MESSAGE_ROUTED2(AutofillMsg_PreviewPasswordSuggestion
,
187 base::string16
/* username */,
188 base::string16
/* password */)
190 // Tells the renderer that this password form is not blacklisted. A form can
191 // be blacklisted if a user chooses "never save passwords for this site".
192 IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted
,
193 autofill::PasswordForm
/* form checked */)
195 // Sent when requestAutocomplete() finishes (either succesfully or with an
196 // error). If it was a success, the renderer fills the form that requested
197 // autocomplete with the |form_data| values input by the user. |message|
198 // is printed to the console if non-empty.
199 IPC_MESSAGE_ROUTED3(AutofillMsg_RequestAutocompleteResult
,
200 blink::WebFormElement::AutocompleteResult
/* result */,
201 base::string16
/* message */,
202 autofill::FormData
/* form_data */)
204 // Sent when Autofill manager gets the query response from the Autofill server
205 // and there are fields classified as ACCOUNT_CREATION_PASSWORD in the response.
206 IPC_MESSAGE_ROUTED1(AutofillMsg_AccountCreationFormsDetected
,
207 std::vector
<autofill::FormData
> /* forms */)
209 // Sent when Autofill manager gets the query response from the Autofill server
210 // which contains information about username fields for some forms.
211 // |predictions| maps forms to their username fields.
212 IPC_MESSAGE_ROUTED1(AutofillMsg_AutofillUsernameDataReceived
,
213 FormDataFieldDataMap
/* predictions */)
215 // Autofill messages sent from the renderer to the browser.
217 // TODO(creis): check in the browser that the renderer actually has permission
218 // for the URL to avoid compromised renderers talking to the browser.
220 // Notification that there has been a user gesture.
221 IPC_MESSAGE_ROUTED0(AutofillHostMsg_FirstUserGestureObserved
)
223 // Notification that forms have been seen that are candidates for
224 // filling/submitting by the AutofillManager.
225 IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormsSeen
,
226 std::vector
<autofill::FormData
> /* forms */,
227 base::TimeTicks
/* timestamp */)
229 // Notification that password forms have been seen that are candidates for
230 // filling/submitting by the password manager.
231 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed
,
232 std::vector
<autofill::PasswordForm
> /* forms */)
234 // Notification that initial layout has occurred and the following password
235 // forms are visible on the page (e.g. not set to display:none.), and whether
236 // all frames in the page have been rendered.
237 IPC_MESSAGE_ROUTED2(AutofillHostMsg_PasswordFormsRendered
,
238 std::vector
<autofill::PasswordForm
> /* forms */,
239 bool /* did_stop_loading */)
241 // A ping to the browser that PasswordAutofillAgent was constructed. As a
242 // consequence, the browser sends AutofillMsg_SetLoggingState with the current
243 // state of the logging activity.
244 IPC_MESSAGE_ROUTED0(AutofillHostMsg_PasswordAutofillAgentConstructed
)
246 // Notification that this password form was submitted by the user.
247 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormSubmitted
,
248 autofill::PasswordForm
/* form */)
250 // Notification that in-page navigation happened and at this moment we have
251 // filled password form. We use this as a signal for successful login.
252 IPC_MESSAGE_ROUTED1(AutofillHostMsg_InPageNavigation
,
253 autofill::PasswordForm
/* form */)
255 // Sends |log| to browser for displaying to the user. Only strings passed as an
256 // argument to methods overriding SavePasswordProgressLogger::SendLog may become
257 // |log|, because those are guaranteed to be sanitized. Never pass a free-form
259 IPC_MESSAGE_ROUTED1(AutofillHostMsg_RecordSavePasswordProgress
,
260 std::string
/* log */)
262 // Notification that a form is about to be submitted. The user hit the button.
263 IPC_MESSAGE_ROUTED2(AutofillHostMsg_WillSubmitForm
,
264 autofill::FormData
/* form */,
265 base::TimeTicks
/* timestamp */)
267 // Notification that a form has been submitted.
268 IPC_MESSAGE_ROUTED1(AutofillHostMsg_FormSubmitted
,
269 autofill::FormData
/* form */)
271 // Notification that a form field's value has changed.
272 IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange
,
273 autofill::FormData
/* the form */,
274 autofill::FormFieldData
/* the form field */,
275 base::TimeTicks
/* timestamp */)
277 // Queries the browser for Autofill suggestions for a form input field.
278 IPC_MESSAGE_ROUTED5(AutofillHostMsg_QueryFormFieldAutofill
,
279 int /* id of this message */,
280 autofill::FormData
/* the form */,
281 autofill::FormFieldData
/* the form field */,
282 gfx::RectF
/* input field bounds, window-relative */,
283 bool /* display warning if autofill disabled */)
285 // Sent when a form is previewed with Autofill suggestions.
286 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidPreviewAutofillFormData
)
288 // Sent immediately after the renderer receives a ping IPC.
289 IPC_MESSAGE_ROUTED0(AutofillHostMsg_PingAck
)
291 // Sent when a form is filled with Autofill suggestions.
292 IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData
,
293 base::TimeTicks
/* timestamp */)
295 // Sent when a form receives a request to do interactive autocomplete.
296 IPC_MESSAGE_ROUTED1(AutofillHostMsg_RequestAutocomplete
,
297 autofill::FormData
/* form_data */)
299 // Send when a text field is done editing.
300 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidEndTextFieldEditing
)
302 // Instructs the browser to hide the Autofill popup if it is open.
303 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePopup
)
305 // Instructs the browser to show the password generation popup at the
306 // specified location. This location should be specified in the renderers
307 // coordinate system. Form is the form associated with the password field.
308 IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup
,
309 gfx::RectF
/* source location */,
310 int /* max length of the password */,
311 autofill::PasswordForm
)
313 // Instructs the browser to show the popup for editing a generated password.
314 // The location should be specified in the renderers coordinate system. Form
315 // is the form associated with the password field.
316 IPC_MESSAGE_ROUTED2(AutofillHostMsg_ShowPasswordEditingPopup
,
317 gfx::RectF
/* source location */,
318 autofill::PasswordForm
)
320 // Instructs the browser to hide any password generation popups.
321 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePasswordGenerationPopup
)
323 // Instruct the browser to show a popup with suggestions filled from data
324 // associated with |key|. The popup will use |text_direction| for displaying
327 AutofillHostMsg_ShowPasswordSuggestions
,
329 base::i18n::TextDirection
/* text_direction */,
330 base::string16
/* username typed by user */,
331 int /* options bitmask of autofill::ShowPasswordSuggestionsOptions */,
332 gfx::RectF
/* input field bounds, window-relative */)
334 // Inform browser of data list values for the curent field.
335 IPC_MESSAGE_ROUTED2(AutofillHostMsg_SetDataList
,
336 std::vector
<base::string16
> /* values */,
337 std::vector
<base::string16
> /* labels */)