Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / components / autofill / content / common / autofill_messages.h
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.
4
5 // Multiply-included message file, hence no include guard.
6
7 #include <string>
8 #include <vector>
9
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/forms_seen_state.h"
18 #include "components/autofill/core/common/password_form.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/rect.h"
27 #include "url/gurl.h"
28
29 #define IPC_MESSAGE_START AutofillMsgStart
30
31 IPC_ENUM_TRAITS_MAX_VALUE(autofill::FormsSeenState,
32                           autofill::FORMS_SEEN_STATE_NUM_STATES - 1)
33 IPC_ENUM_TRAITS_MAX_VALUE(base::i18n::TextDirection,
34                           base::i18n::TEXT_DIRECTION_NUM_DIRECTIONS - 1)
35
36 IPC_STRUCT_TRAITS_BEGIN(autofill::WebElementDescriptor)
37   IPC_STRUCT_TRAITS_MEMBER(descriptor)
38   IPC_STRUCT_TRAITS_MEMBER(retrieval_method)
39 IPC_STRUCT_TRAITS_END()
40
41 IPC_ENUM_TRAITS_MAX_VALUE(autofill::WebElementDescriptor::RetrievalMethod,
42                           autofill::WebElementDescriptor::NONE)
43
44 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData)
45   IPC_STRUCT_TRAITS_MEMBER(label)
46   IPC_STRUCT_TRAITS_MEMBER(name)
47   IPC_STRUCT_TRAITS_MEMBER(value)
48   IPC_STRUCT_TRAITS_MEMBER(form_control_type)
49   IPC_STRUCT_TRAITS_MEMBER(autocomplete_attribute)
50   IPC_STRUCT_TRAITS_MEMBER(max_length)
51   IPC_STRUCT_TRAITS_MEMBER(is_autofilled)
52   IPC_STRUCT_TRAITS_MEMBER(is_checked)
53   IPC_STRUCT_TRAITS_MEMBER(is_checkable)
54   IPC_STRUCT_TRAITS_MEMBER(is_focusable)
55   IPC_STRUCT_TRAITS_MEMBER(should_autocomplete)
56   IPC_STRUCT_TRAITS_MEMBER(text_direction)
57   IPC_STRUCT_TRAITS_MEMBER(option_values)
58   IPC_STRUCT_TRAITS_MEMBER(option_contents)
59 IPC_STRUCT_TRAITS_END()
60
61 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldDataPredictions)
62   IPC_STRUCT_TRAITS_MEMBER(field)
63   IPC_STRUCT_TRAITS_MEMBER(signature)
64   IPC_STRUCT_TRAITS_MEMBER(heuristic_type)
65   IPC_STRUCT_TRAITS_MEMBER(server_type)
66   IPC_STRUCT_TRAITS_MEMBER(overall_type)
67 IPC_STRUCT_TRAITS_END()
68
69 IPC_STRUCT_TRAITS_BEGIN(autofill::FormDataPredictions)
70   IPC_STRUCT_TRAITS_MEMBER(data)
71   IPC_STRUCT_TRAITS_MEMBER(signature)
72   IPC_STRUCT_TRAITS_MEMBER(experiment_id)
73   IPC_STRUCT_TRAITS_MEMBER(fields)
74 IPC_STRUCT_TRAITS_END()
75
76 IPC_STRUCT_TRAITS_BEGIN(autofill::UsernamesCollectionKey)
77   IPC_STRUCT_TRAITS_MEMBER(username)
78   IPC_STRUCT_TRAITS_MEMBER(password)
79 IPC_STRUCT_TRAITS_END()
80
81 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordFormFillData)
82   IPC_STRUCT_TRAITS_MEMBER(basic_data)
83   IPC_STRUCT_TRAITS_MEMBER(preferred_realm)
84   IPC_STRUCT_TRAITS_MEMBER(additional_logins)
85   IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames)
86   IPC_STRUCT_TRAITS_MEMBER(wait_for_username)
87 IPC_STRUCT_TRAITS_END()
88
89 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordAndRealm)
90   IPC_STRUCT_TRAITS_MEMBER(password)
91   IPC_STRUCT_TRAITS_MEMBER(realm)
92 IPC_STRUCT_TRAITS_END()
93
94 IPC_ENUM_TRAITS_MAX_VALUE(
95     blink::WebFormElement::AutocompleteResult,
96     blink::WebFormElement::AutocompleteResultErrorInvalid)
97
98 // Autofill messages sent from the browser to the renderer.
99
100 // Instructs the renderer to fill the active form with the given form data.
101 IPC_MESSAGE_ROUTED2(AutofillMsg_FillForm,
102                     int /* query_id */,
103                     autofill::FormData /* form */)
104
105 // Instructs the renderer to preview the active form with the given form data.
106 IPC_MESSAGE_ROUTED2(AutofillMsg_PreviewForm,
107                     int /* query_id */,
108                     autofill::FormData /* form */)
109
110 // Fill a password form and prepare field autocomplete for multiple
111 // matching logins. Lets the renderer know if it should disable the popup
112 // because the browser process will own the popup UI.
113 IPC_MESSAGE_ROUTED1(AutofillMsg_FillPasswordForm,
114                     autofill::PasswordFormFillData /* the fill form data*/)
115
116 // Notification to start (|active| == true) or stop (|active| == false) logging
117 // the decisions made about saving the password.
118 IPC_MESSAGE_ROUTED1(AutofillMsg_ChangeLoggingState, bool /* active */)
119
120 // Send the heuristic and server field type predictions to the renderer.
121 IPC_MESSAGE_ROUTED1(
122     AutofillMsg_FieldTypePredictionsAvailable,
123     std::vector<autofill::FormDataPredictions> /* forms */)
124
125 // Clears the currently displayed Autofill results.
126 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearForm)
127
128 // Tells the renderer that the Autofill previewed form should be cleared.
129 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearPreviewedForm)
130
131 // Sets the currently selected node's value.
132 IPC_MESSAGE_ROUTED1(AutofillMsg_FillFieldWithValue,
133                     base::string16 /* value */)
134
135 // Sets the suggested value for the currently previewed node.
136 IPC_MESSAGE_ROUTED1(AutofillMsg_PreviewFieldWithValue,
137                     base::string16 /* value */)
138
139 // Sets the currently selected node's value to be the given data list value.
140 IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptDataListSuggestion,
141                     base::string16 /* accepted data list value */)
142
143 // Tells the renderer to populate the correct password fields with this
144 // generated password.
145 IPC_MESSAGE_ROUTED1(AutofillMsg_GeneratedPasswordAccepted,
146                     base::string16 /* generated_password */)
147
148 // Tells the renderer that the user accepted a password autofill suggestion,
149 // and that renderer should set the username and password to the given values.
150 IPC_MESSAGE_ROUTED2(AutofillMsg_AcceptPasswordAutofillSuggestion,
151                     base::string16 /* username */,
152                     base::string16 /* password */)
153
154 // Tells the renderer that this password form is not blacklisted.  A form can
155 // be blacklisted if a user chooses "never save passwords for this site".
156 IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted,
157                     autofill::PasswordForm /* form checked */)
158
159 // Sent when requestAutocomplete() finishes (either succesfully or with an
160 // error). If it was a success, the renderer fills the form that requested
161 // autocomplete with the |form_data| values input by the user. |message|
162 // is printed to the console if non-empty.
163 IPC_MESSAGE_ROUTED3(AutofillMsg_RequestAutocompleteResult,
164                     blink::WebFormElement::AutocompleteResult /* result */,
165                     base::string16 /* message */,
166                     autofill::FormData /* form_data */)
167
168 // Sent when Autofill manager gets the query response from the Autofill server
169 // and there are fields classified as ACCOUNT_CREATION_PASSWORD in the response.
170 IPC_MESSAGE_ROUTED1(AutofillMsg_AccountCreationFormsDetected,
171                     std::vector<autofill::FormData> /* forms */)
172
173 // Autofill messages sent from the renderer to the browser.
174
175 // TODO(creis): check in the browser that the renderer actually has permission
176 // for the URL to avoid compromised renderers talking to the browser.
177
178 // Notification that forms have been seen that are candidates for
179 // filling/submitting by the AutofillManager.
180 IPC_MESSAGE_ROUTED3(AutofillHostMsg_FormsSeen,
181                     std::vector<autofill::FormData> /* forms */,
182                     base::TimeTicks /* timestamp */,
183                     autofill::FormsSeenState /* state */)
184
185 // Notification that password forms have been seen that are candidates for
186 // filling/submitting by the password manager.
187 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed,
188                     std::vector<autofill::PasswordForm> /* forms */)
189
190 // Notification that initial layout has occurred and the following password
191 // forms are visible on the page (e.g. not set to display:none.)
192 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsRendered,
193                     std::vector<autofill::PasswordForm> /* forms */)
194
195 // Notification that this password form was submitted by the user.
196 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormSubmitted,
197                     autofill::PasswordForm /* form */)
198
199 // Sends |log| to browser for displaying to the user. Only strings passed as an
200 // argument to methods overriding SavePasswordProgressLogger::SendLog may become
201 // |log|, because those are guaranteed to be sanitized. Never pass a free-form
202 // string as |log|.
203 IPC_MESSAGE_ROUTED1(AutofillHostMsg_RecordSavePasswordProgress,
204                     std::string /* log */)
205
206 // Notification that a form has been submitted.  The user hit the button.
207 IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormSubmitted,
208                     autofill::FormData /* form */,
209                     base::TimeTicks /* timestamp */)
210
211 // Notification that a form field's value has changed.
212 IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange,
213                     autofill::FormData /* the form */,
214                     autofill::FormFieldData /* the form field */,
215                     base::TimeTicks /* timestamp */)
216
217 // Queries the browser for Autofill suggestions for a form input field.
218 IPC_MESSAGE_ROUTED5(AutofillHostMsg_QueryFormFieldAutofill,
219                     int /* id of this message */,
220                     autofill::FormData /* the form */,
221                     autofill::FormFieldData /* the form field */,
222                     gfx::RectF /* input field bounds, window-relative */,
223                     bool /* display warning if autofill disabled */)
224
225 // Sent when a form is previewed with Autofill suggestions.
226 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidPreviewAutofillFormData)
227
228 // Sent when a form is filled with Autofill suggestions.
229 IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData,
230                     base::TimeTicks /* timestamp */)
231
232 // Sent when a form receives a request to do interactive autocomplete.
233 IPC_MESSAGE_ROUTED2(AutofillHostMsg_RequestAutocomplete,
234                     autofill::FormData /* form_data */,
235                     GURL /* frame_url */)
236
237 // Sent when interactive autocomplete is cancelled (e.g. because the invoking
238 // frame was navigated to a different URL).
239 IPC_MESSAGE_ROUTED0(AutofillHostMsg_CancelRequestAutocomplete);
240
241 // Send when a text field is done editing.
242 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidEndTextFieldEditing)
243
244 // Instructs the browser to hide the Autofill popup if it is open.
245 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePopup)
246
247 // Instructs the browser to show the password generation popup at the
248 // specified location. This location should be specified in the renderers
249 // coordinate system. Form is the form associated with the password field.
250 IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup,
251                     gfx::RectF /* source location */,
252                     int /* max length of the password */,
253                     autofill::PasswordForm)
254
255 // Instructs the browser to show the popup for editing a generated password.
256 // The location should be specified in the renderers coordinate system. Form
257 // is the form associated with the password field.
258 IPC_MESSAGE_ROUTED2(AutofillHostMsg_ShowPasswordEditingPopup,
259                     gfx::RectF /* source location */,
260                     autofill::PasswordForm)
261
262 // Instructs the browser to hide any password generation popups.
263 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HidePasswordGenerationPopup)
264
265 // Instruct the browser that a password mapping has been found for a field.
266 IPC_MESSAGE_ROUTED2(AutofillHostMsg_AddPasswordFormMapping,
267                     autofill::FormFieldData, /* the user name field */
268                     autofill::PasswordFormFillData /* password pairings */)
269
270 // Instruct the browser to show a popup with the following suggestions from the
271 // password manager.
272 IPC_MESSAGE_ROUTED4(AutofillHostMsg_ShowPasswordSuggestions,
273                     autofill::FormFieldData /* the form field */,
274                     gfx::RectF /* input field bounds, window-relative */,
275                     std::vector<base::string16> /* suggestions */,
276                     std::vector<base::string16> /* realms */)
277
278 // Inform browser of data list values for the curent field.
279 IPC_MESSAGE_ROUTED2(AutofillHostMsg_SetDataList,
280                     std::vector<base::string16> /* values */,
281                     std::vector<base::string16> /* labels */)