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