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