Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / content / common / autofill_messages.h
blob821566fb7daaeecbc780c5ed6418bbae22419610
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.
7 #include <string>
8 #include <vector>
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_field_prediction_map.h"
19 #include "components/autofill/core/common/password_form_fill_data.h"
20 #include "components/autofill/core/common/web_element_descriptor.h"
21 #include "content/public/common/common_param_traits.h"
22 #include "content/public/common/common_param_traits_macros.h"
23 #include "ipc/ipc_message_macros.h"
24 #include "ipc/ipc_message_utils.h"
25 #include "third_party/WebKit/public/web/WebFormElement.h"
26 #include "ui/gfx/geometry/rect_f.h"
27 #include "ui/gfx/ipc/gfx_param_traits.h"
28 #include "url/gurl.h"
30 #define IPC_MESSAGE_START AutofillMsgStart
32 IPC_ENUM_TRAITS_MAX_VALUE(autofill::FormFieldData::RoleAttribute,
33 autofill::FormFieldData::ROLE_ATTRIBUTE_OTHER)
35 IPC_ENUM_TRAITS_MAX_VALUE(
36 autofill::PasswordFormFieldPredictionType,
37 autofill::PasswordFormFieldPredictionType::PREDICTION_MAX)
39 IPC_ENUM_TRAITS_MAX_VALUE(base::i18n::TextDirection,
40 base::i18n::TEXT_DIRECTION_NUM_DIRECTIONS - 1)
42 IPC_STRUCT_TRAITS_BEGIN(autofill::WebElementDescriptor)
43 IPC_STRUCT_TRAITS_MEMBER(descriptor)
44 IPC_STRUCT_TRAITS_MEMBER(retrieval_method)
45 IPC_STRUCT_TRAITS_END()
47 IPC_ENUM_TRAITS_MAX_VALUE(autofill::WebElementDescriptor::RetrievalMethod,
48 autofill::WebElementDescriptor::NONE)
50 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData)
51 IPC_STRUCT_TRAITS_MEMBER(label)
52 IPC_STRUCT_TRAITS_MEMBER(name)
53 IPC_STRUCT_TRAITS_MEMBER(value)
54 IPC_STRUCT_TRAITS_MEMBER(form_control_type)
55 IPC_STRUCT_TRAITS_MEMBER(autocomplete_attribute)
56 IPC_STRUCT_TRAITS_MEMBER(role)
57 IPC_STRUCT_TRAITS_MEMBER(max_length)
58 IPC_STRUCT_TRAITS_MEMBER(is_autofilled)
59 IPC_STRUCT_TRAITS_MEMBER(is_checked)
60 IPC_STRUCT_TRAITS_MEMBER(is_checkable)
61 IPC_STRUCT_TRAITS_MEMBER(is_focusable)
62 IPC_STRUCT_TRAITS_MEMBER(should_autocomplete)
63 IPC_STRUCT_TRAITS_MEMBER(text_direction)
64 IPC_STRUCT_TRAITS_MEMBER(option_values)
65 IPC_STRUCT_TRAITS_MEMBER(option_contents)
66 IPC_STRUCT_TRAITS_END()
68 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldDataPredictions)
69 IPC_STRUCT_TRAITS_MEMBER(field)
70 IPC_STRUCT_TRAITS_MEMBER(signature)
71 IPC_STRUCT_TRAITS_MEMBER(heuristic_type)
72 IPC_STRUCT_TRAITS_MEMBER(server_type)
73 IPC_STRUCT_TRAITS_MEMBER(overall_type)
74 IPC_STRUCT_TRAITS_END()
76 IPC_STRUCT_TRAITS_BEGIN(autofill::FormDataPredictions)
77 IPC_STRUCT_TRAITS_MEMBER(data)
78 IPC_STRUCT_TRAITS_MEMBER(signature)
79 IPC_STRUCT_TRAITS_MEMBER(experiment_id)
80 IPC_STRUCT_TRAITS_MEMBER(fields)
81 IPC_STRUCT_TRAITS_END()
83 IPC_STRUCT_TRAITS_BEGIN(autofill::UsernamesCollectionKey)
84 IPC_STRUCT_TRAITS_MEMBER(username)
85 IPC_STRUCT_TRAITS_MEMBER(password)
86 IPC_STRUCT_TRAITS_END()
88 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordFormFillData)
89 IPC_STRUCT_TRAITS_MEMBER(name)
90 IPC_STRUCT_TRAITS_MEMBER(origin)
91 IPC_STRUCT_TRAITS_MEMBER(action)
92 IPC_STRUCT_TRAITS_MEMBER(username_field)
93 IPC_STRUCT_TRAITS_MEMBER(password_field)
94 IPC_STRUCT_TRAITS_MEMBER(preferred_realm)
95 IPC_STRUCT_TRAITS_MEMBER(additional_logins)
96 IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames)
97 IPC_STRUCT_TRAITS_MEMBER(wait_for_username)
98 IPC_STRUCT_TRAITS_MEMBER(is_possible_change_password_form)
99 IPC_STRUCT_TRAITS_END()
101 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordAndRealm)
102 IPC_STRUCT_TRAITS_MEMBER(password)
103 IPC_STRUCT_TRAITS_MEMBER(realm)
104 IPC_STRUCT_TRAITS_END()
106 IPC_ENUM_TRAITS_MAX_VALUE(
107 blink::WebFormElement::AutocompleteResult,
108 blink::WebFormElement::AutocompleteResultErrorInvalid)
110 // Singly-included section for type definitions.
111 #ifndef COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
112 #define COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
114 // IPC_MESSAGE macros fail on the std::map, when expanding. We need to define
115 // a type to avoid that.
116 using FormsPredictionsMap =
117 std::map<autofill::FormData, autofill::PasswordFormFieldPredictionMap>;
119 #endif // COMPONENTS_AUTOFILL_CONTENT_COMMON_AUTOFILL_MESSAGES_H_
121 // Autofill messages sent from the browser to the renderer.
123 // Tells the render frame that a user gesture was observed somewhere in the tab
124 // (including in a different frame).
125 IPC_MESSAGE_ROUTED0(AutofillMsg_FirstUserGestureObservedInTab)
127 // Instructs the renderer to fill the active form with the given form data.
128 IPC_MESSAGE_ROUTED2(AutofillMsg_FillForm,
129 int /* query_id */,
130 autofill::FormData /* form */)
132 // Instructs the renderer to preview the active form with the given form data.
133 IPC_MESSAGE_ROUTED2(AutofillMsg_PreviewForm,
134 int /* query_id */,
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,
143 int /* key */,
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.
151 IPC_MESSAGE_ROUTED1(
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
179 // values.
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
185 // values.
186 IPC_MESSAGE_ROUTED2(AutofillMsg_PreviewPasswordSuggestion,
187 base::string16 /* username */,
188 base::string16 /* password */)
190 // Tells the renderer to find the focused password form (assuming it exists).
191 // Renderer is expected to respond with the message
192 // |AutofillHostMsg_FocusedPasswordFormFound|.
193 IPC_MESSAGE_ROUTED0(AutofillMsg_FindFocusedPasswordForm)
195 // Tells the renderer that this password form is not blacklisted. A form can
196 // be blacklisted if a user chooses "never save passwords for this site".
197 IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted,
198 autofill::PasswordForm /* form checked */)
200 // Sent when requestAutocomplete() finishes (either succesfully or with an
201 // error). If it was a success, the renderer fills the form that requested
202 // autocomplete with the |form_data| values input by the user. |message|
203 // is printed to the console if non-empty.
204 IPC_MESSAGE_ROUTED3(AutofillMsg_RequestAutocompleteResult,
205 blink::WebFormElement::AutocompleteResult /* result */,
206 base::string16 /* message */,
207 autofill::FormData /* form_data */)
209 // Sent when Autofill manager gets the query response from the Autofill server
210 // and there are fields classified as ACCOUNT_CREATION_PASSWORD in the response.
211 IPC_MESSAGE_ROUTED1(AutofillMsg_AccountCreationFormsDetected,
212 std::vector<autofill::FormData> /* forms */)
214 // Sent when Autofill manager gets the query response from the Autofill server
215 // which contains information about username and password fields for some forms.
216 // |predictions| maps forms to their username fields.
217 IPC_MESSAGE_ROUTED1(AutofillMsg_AutofillUsernameAndPasswordDataReceived,
218 FormsPredictionsMap /* predictions */)
220 // Autofill messages sent from the renderer to the browser.
222 // TODO(creis): check in the browser that the renderer actually has permission
223 // for the URL to avoid compromised renderers talking to the browser.
225 // Notification that there has been a user gesture.
226 IPC_MESSAGE_ROUTED0(AutofillHostMsg_FirstUserGestureObserved)
228 // Notification that forms have been seen that are candidates for
229 // filling/submitting by the AutofillManager.
230 IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormsSeen,
231 std::vector<autofill::FormData> /* forms */,
232 base::TimeTicks /* timestamp */)
234 // Notification that password forms have been seen that are candidates for
235 // filling/submitting by the password manager.
236 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed,
237 std::vector<autofill::PasswordForm> /* forms */)
239 // Notification that initial layout has occurred and the following password
240 // forms are visible on the page (e.g. not set to display:none.), and whether
241 // all frames in the page have been rendered.
242 IPC_MESSAGE_ROUTED2(AutofillHostMsg_PasswordFormsRendered,
243 std::vector<autofill::PasswordForm> /* forms */,
244 bool /* did_stop_loading */)
246 // A ping to the browser that PasswordAutofillAgent was constructed. As a
247 // consequence, the browser sends AutofillMsg_SetLoggingState with the current
248 // state of the logging activity.
249 IPC_MESSAGE_ROUTED0(AutofillHostMsg_PasswordAutofillAgentConstructed)
251 // Notification that this password form was submitted by the user.
252 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormSubmitted,
253 autofill::PasswordForm /* form */)
255 // Notification that in-page navigation happened and at this moment we have
256 // filled password form. We use this as a signal for successful login.
257 IPC_MESSAGE_ROUTED1(AutofillHostMsg_InPageNavigation,
258 autofill::PasswordForm /* form */)
260 // Sends |log| to browser for displaying to the user. Only strings passed as an
261 // argument to methods overriding SavePasswordProgressLogger::SendLog may become
262 // |log|, because those are guaranteed to be sanitized. Never pass a free-form
263 // string as |log|.
264 IPC_MESSAGE_ROUTED1(AutofillHostMsg_RecordSavePasswordProgress,
265 std::string /* log */)
267 // Notification that a form is about to be submitted. The user hit the button.
268 IPC_MESSAGE_ROUTED2(AutofillHostMsg_WillSubmitForm,
269 autofill::FormData /* form */,
270 base::TimeTicks /* timestamp */)
272 // Notification that a form has been submitted.
273 IPC_MESSAGE_ROUTED1(AutofillHostMsg_FormSubmitted,
274 autofill::FormData /* form */)
276 // Notification that a form field's value has changed.
277 IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange,
278 autofill::FormData /* the form */,
279 autofill::FormFieldData /* the form field */,
280 base::TimeTicks /* timestamp */)
282 // Queries the browser for Autofill suggestions for a form input field.
283 IPC_MESSAGE_ROUTED4(AutofillHostMsg_QueryFormFieldAutofill,
284 int /* id of this message */,
285 autofill::FormData /* the form */,
286 autofill::FormFieldData /* the form field */,
287 gfx::RectF /* input field bounds, window-relative */)
289 // Sent when a form is previewed with Autofill suggestions.
290 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidPreviewAutofillFormData)
292 // Sent immediately after the renderer receives a ping IPC.
293 IPC_MESSAGE_ROUTED0(AutofillHostMsg_PingAck)
295 // Sent when a form is filled with Autofill suggestions.
296 IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData,
297 base::TimeTicks /* timestamp */)
299 // Sent when a form receives a request to do interactive autocomplete.
300 IPC_MESSAGE_ROUTED1(AutofillHostMsg_RequestAutocomplete,
301 autofill::FormData /* form_data */)
303 // Send when a text field is done editing.
304 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidEndTextFieldEditing)
306 // Instructs the browser to hide the Autofill popup if it is open.
307 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePopup)
309 // Instructs the browser that generation is available for this particular form.
310 // This is used for UMA stats.
311 IPC_MESSAGE_ROUTED1(AutofillHostMsg_GenerationAvailableForForm,
312 autofill::PasswordForm)
314 // Instructs the browser to show the password generation popup at the
315 // specified location. This location should be specified in the renderers
316 // coordinate system. Form is the form associated with the password field.
317 IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup,
318 gfx::RectF /* source location */,
319 int /* max length of the password */,
320 autofill::PasswordForm)
322 // Instructs the browser to show the popup for editing a generated password.
323 // The location should be specified in the renderers coordinate system. Form
324 // is the form associated with the password field.
325 IPC_MESSAGE_ROUTED2(AutofillHostMsg_ShowPasswordEditingPopup,
326 gfx::RectF /* source location */,
327 autofill::PasswordForm)
329 // Instructs the browser to hide any password generation popups.
330 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePasswordGenerationPopup)
332 // Instructs the browsr that form no longer contains a generated password.
333 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordNoLongerGenerated,
334 autofill::PasswordForm)
336 // Instruct the browser to show a popup with suggestions filled from data
337 // associated with |key|. The popup will use |text_direction| for displaying
338 // text.
339 IPC_MESSAGE_ROUTED5(
340 AutofillHostMsg_ShowPasswordSuggestions,
341 int /* key */,
342 base::i18n::TextDirection /* text_direction */,
343 base::string16 /* username typed by user */,
344 int /* options bitmask of autofill::ShowPasswordSuggestionsOptions */,
345 gfx::RectF /* input field bounds, window-relative */)
347 // Inform browser of data list values for the curent field.
348 IPC_MESSAGE_ROUTED2(AutofillHostMsg_SetDataList,
349 std::vector<base::string16> /* values */,
350 std::vector<base::string16> /* labels */)
352 // Inform the browser which password form is currently focused, as a response
353 // to the |AutofillMsg_FindFocusedPasswordForm| request. If no password form
354 // is focused, the response will contain an empty |autofill::PasswordForm|.
355 IPC_MESSAGE_ROUTED1(AutofillHostMsg_FocusedPasswordFormFound,
356 autofill::PasswordForm)