Home | History | Annotate | Download | only in common
      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 
      9 #include "base/time/time.h"
     10 #include "components/autofill/core/common/autocheckout_status.h"
     11 #include "components/autofill/core/common/form_data.h"
     12 #include "components/autofill/core/common/form_data_predictions.h"
     13 #include "components/autofill/core/common/form_field_data.h"
     14 #include "components/autofill/core/common/form_field_data_predictions.h"
     15 #include "components/autofill/core/common/forms_seen_state.h"
     16 #include "components/autofill/core/common/password_form_fill_data.h"
     17 #include "components/autofill/core/common/web_element_descriptor.h"
     18 #include "content/public/common/common_param_traits.h"
     19 #include "content/public/common/common_param_traits_macros.h"
     20 #include "content/public/common/password_form.h"
     21 #include "ipc/ipc_message_macros.h"
     22 #include "ipc/ipc_message_utils.h"
     23 #include "third_party/WebKit/public/web/WebFormElement.h"
     24 #include "ui/gfx/rect.h"
     25 #include "url/gurl.h"
     26 
     27 #define IPC_MESSAGE_START AutofillMsgStart
     28 
     29 IPC_ENUM_TRAITS_MAX_VALUE(autofill::AutocheckoutStatus,
     30                           autofill::AUTOCHECKOUT_STATUS_NUM_STATUS - 1)
     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(autofill::WebElementDescriptor::RetrievalMethod)
     42 
     43 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldData)
     44   IPC_STRUCT_TRAITS_MEMBER(label)
     45   IPC_STRUCT_TRAITS_MEMBER(name)
     46   IPC_STRUCT_TRAITS_MEMBER(value)
     47   IPC_STRUCT_TRAITS_MEMBER(form_control_type)
     48   IPC_STRUCT_TRAITS_MEMBER(autocomplete_attribute)
     49   IPC_STRUCT_TRAITS_MEMBER(max_length)
     50   IPC_STRUCT_TRAITS_MEMBER(is_autofilled)
     51   IPC_STRUCT_TRAITS_MEMBER(is_checked)
     52   IPC_STRUCT_TRAITS_MEMBER(is_checkable)
     53   IPC_STRUCT_TRAITS_MEMBER(is_focusable)
     54   IPC_STRUCT_TRAITS_MEMBER(should_autocomplete)
     55   IPC_STRUCT_TRAITS_MEMBER(text_direction)
     56   IPC_STRUCT_TRAITS_MEMBER(option_values)
     57   IPC_STRUCT_TRAITS_MEMBER(option_contents)
     58 IPC_STRUCT_TRAITS_END()
     59 
     60 IPC_STRUCT_TRAITS_BEGIN(autofill::FormFieldDataPredictions)
     61   IPC_STRUCT_TRAITS_MEMBER(field)
     62   IPC_STRUCT_TRAITS_MEMBER(signature)
     63   IPC_STRUCT_TRAITS_MEMBER(heuristic_type)
     64   IPC_STRUCT_TRAITS_MEMBER(server_type)
     65   IPC_STRUCT_TRAITS_MEMBER(overall_type)
     66 IPC_STRUCT_TRAITS_END()
     67 
     68 IPC_STRUCT_TRAITS_BEGIN(autofill::FormData)
     69   IPC_STRUCT_TRAITS_MEMBER(name)
     70   IPC_STRUCT_TRAITS_MEMBER(method)
     71   IPC_STRUCT_TRAITS_MEMBER(origin)
     72   IPC_STRUCT_TRAITS_MEMBER(action)
     73   IPC_STRUCT_TRAITS_MEMBER(user_submitted)
     74   IPC_STRUCT_TRAITS_MEMBER(fields)
     75 IPC_STRUCT_TRAITS_END()
     76 
     77 IPC_STRUCT_TRAITS_BEGIN(autofill::FormDataPredictions)
     78   IPC_STRUCT_TRAITS_MEMBER(data)
     79   IPC_STRUCT_TRAITS_MEMBER(signature)
     80   IPC_STRUCT_TRAITS_MEMBER(experiment_id)
     81   IPC_STRUCT_TRAITS_MEMBER(fields)
     82 IPC_STRUCT_TRAITS_END()
     83 
     84 IPC_STRUCT_TRAITS_BEGIN(autofill::UsernamesCollectionKey)
     85   IPC_STRUCT_TRAITS_MEMBER(username)
     86   IPC_STRUCT_TRAITS_MEMBER(password)
     87 IPC_STRUCT_TRAITS_END()
     88 
     89 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordFormFillData)
     90   IPC_STRUCT_TRAITS_MEMBER(basic_data)
     91   IPC_STRUCT_TRAITS_MEMBER(preferred_realm)
     92   IPC_STRUCT_TRAITS_MEMBER(additional_logins)
     93   IPC_STRUCT_TRAITS_MEMBER(other_possible_usernames)
     94   IPC_STRUCT_TRAITS_MEMBER(wait_for_username)
     95 IPC_STRUCT_TRAITS_END()
     96 
     97 IPC_STRUCT_TRAITS_BEGIN(autofill::PasswordAndRealm)
     98   IPC_STRUCT_TRAITS_MEMBER(password)
     99   IPC_STRUCT_TRAITS_MEMBER(realm)
    100 IPC_STRUCT_TRAITS_END()
    101 
    102 IPC_ENUM_TRAITS(WebKit::WebFormElement::AutocompleteResult)
    103 
    104 // Autofill messages sent from the browser to the renderer.
    105 
    106 // Request to parse all the forms without field count limit.
    107 IPC_MESSAGE_ROUTED0(AutofillMsg_GetAllForms)
    108 
    109 // Reply to the AutofillHostMsg_FillAutofillFormData message with the
    110 // Autofill form data.
    111 IPC_MESSAGE_ROUTED2(AutofillMsg_FormDataFilled,
    112                     int /* id of the request message */,
    113                     autofill::FormData /* form data */)
    114 
    115 // Fill a password form and prepare field autocomplete for multiple
    116 // matching logins. Lets the renderer know if it should disable the popup
    117 // because the browser process will own the popup UI.
    118 IPC_MESSAGE_ROUTED1(AutofillMsg_FillPasswordForm,
    119                     autofill::PasswordFormFillData /* the fill form data*/)
    120 
    121 // Send the heuristic and server field type predictions to the renderer.
    122 IPC_MESSAGE_ROUTED1(
    123     AutofillMsg_FieldTypePredictionsAvailable,
    124     std::vector<autofill::FormDataPredictions> /* forms */)
    125 
    126 // Tells the renderer that the next form will be filled for real.
    127 IPC_MESSAGE_ROUTED0(AutofillMsg_SetAutofillActionFill)
    128 
    129 // Clears the currently displayed Autofill results.
    130 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearForm)
    131 
    132 // Tells the renderer that the next form will be filled as a preview.
    133 IPC_MESSAGE_ROUTED0(AutofillMsg_SetAutofillActionPreview)
    134 
    135 // Tells the renderer that the Autofill previewed form should be cleared.
    136 IPC_MESSAGE_ROUTED0(AutofillMsg_ClearPreviewedForm)
    137 
    138 // Sets the currently selected node's value.
    139 IPC_MESSAGE_ROUTED1(AutofillMsg_SetNodeText,
    140                     base::string16 /* new node text */)
    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 whether password generation is enabled.
    152 IPC_MESSAGE_ROUTED1(AutofillMsg_PasswordGenerationEnabled,
    153                     bool /* is_enabled */)
    154 
    155 // Tells the renderer that the password field has accept the suggestion.
    156 IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptPasswordAutofillSuggestion,
    157                     base::string16 /* username value*/)
    158 
    159 // Tells the renderer that this password form is not blacklisted.  A form can
    160 // be blacklisted if a user chooses "never save passwords for this site".
    161 IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted,
    162                     content::PasswordForm /* form checked */)
    163 
    164 // Sent when requestAutocomplete() finishes (either succesfully or with an
    165 // error). If it was a success, the renderer fills the form that requested
    166 // autocomplete with the |form_data| values input by the user.
    167 IPC_MESSAGE_ROUTED2(AutofillMsg_RequestAutocompleteResult,
    168                     WebKit::WebFormElement::AutocompleteResult /* result */,
    169                     autofill::FormData /* form_data */)
    170 
    171 // Sent when a page should be filled using Autocheckout. This happens when the
    172 // Autofill server hints that a page is Autocheckout enabled.
    173 IPC_MESSAGE_ROUTED4(AutofillMsg_FillFormsAndClick,
    174                     std::vector<autofill::FormData> /* form_data */,
    175                     std::vector<autofill::WebElementDescriptor> /*
    176                         click_elements_before_form_fill */,
    177                     std::vector<autofill::WebElementDescriptor> /*
    178                         click_elements_after_form_fill */,
    179                     autofill::WebElementDescriptor /* element_descriptor */)
    180 
    181 // Sent when Autocheckout is supported for the current page. The page has to
    182 // be whitelisted and the Autofill server must have returned Autocheckout page
    183 // metadata.
    184 IPC_MESSAGE_ROUTED0(AutofillMsg_AutocheckoutSupported)
    185 
    186 // Sent when the current page is actually displayed in the browser, possibly
    187 // after being preloaded.
    188 IPC_MESSAGE_ROUTED0(AutofillMsg_PageShown)
    189 
    190 // Autofill messages sent from the renderer to the browser.
    191 
    192 // TODO(creis): check in the browser that the renderer actually has permission
    193 // for the URL to avoid compromised renderers talking to the browser.
    194 
    195 // Notification that forms have been seen that are candidates for
    196 // filling/submitting by the AutofillManager.
    197 IPC_MESSAGE_ROUTED3(AutofillHostMsg_FormsSeen,
    198                     std::vector<autofill::FormData> /* forms */,
    199                     base::TimeTicks /* timestamp */,
    200                     autofill::FormsSeenState /* state */)
    201 
    202 // Notification that password forms have been seen that are candidates for
    203 // filling/submitting by the password manager.
    204 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed,
    205                     std::vector<content::PasswordForm> /* forms */)
    206 
    207 // Notification that initial layout has occurred and the following password
    208 // forms are visible on the page (e.g. not set to display:none.)
    209 IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsRendered,
    210                     std::vector<content::PasswordForm> /* forms */)
    211 
    212 // Notification that a form has been submitted.  The user hit the button.
    213 IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormSubmitted,
    214                     autofill::FormData /* form */,
    215                     base::TimeTicks /* timestamp */)
    216 
    217 // Notification that a form field's value has changed.
    218 IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange,
    219                     autofill::FormData /* the form */,
    220                     autofill::FormFieldData /* the form field */,
    221                     base::TimeTicks /* timestamp */)
    222 
    223 // Shows the Autocheckout bubble if the conditions are right.
    224 IPC_MESSAGE_ROUTED2(AutofillHostMsg_MaybeShowAutocheckoutBubble,
    225                     autofill::FormData /* form */,
    226                     gfx::RectF /* bounding_box */)
    227 
    228 // Queries the browser for Autofill suggestions for a form input field.
    229 IPC_MESSAGE_ROUTED5(AutofillHostMsg_QueryFormFieldAutofill,
    230                     int /* id of this message */,
    231                     autofill::FormData /* the form */,
    232                     autofill::FormFieldData /* the form field */,
    233                     gfx::RectF /* input field bounds, window-relative */,
    234                     bool /* display warning if autofill disabled */)
    235 
    236 // Instructs the browser to fill in the values for a form using Autofill
    237 // profile data.
    238 IPC_MESSAGE_ROUTED4(AutofillHostMsg_FillAutofillFormData,
    239                     int /* id of this message */,
    240                     autofill::FormData /* the form  */,
    241                     autofill::FormFieldData /* the form field  */,
    242                     int /* profile unique ID */)
    243 
    244 // Sent when a form is previewed with Autofill suggestions.
    245 IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidPreviewAutofillFormData)
    246 
    247 // Sent when a form is filled with Autofill suggestions.
    248 IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData,
    249                     base::TimeTicks /* timestamp */)
    250 
    251 // Sent when a form receives a request to do interactive autocomplete.
    252 IPC_MESSAGE_ROUTED2(AutofillHostMsg_RequestAutocomplete,
    253                     autofill::FormData /* form_data */,
    254                     GURL /* frame_url */)
    255 
    256 // Instructs the browser to show the Autofill dialog.
    257 IPC_MESSAGE_ROUTED0(AutofillHostMsg_ShowAutofillDialog)
    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 UI.
    263 IPC_MESSAGE_ROUTED0(AutofillHostMsg_HideAutofillUI)
    264 
    265 // Sent when the renderer filled an Autocheckout page and clicked the proceed
    266 // button or if there was an error.
    267 IPC_MESSAGE_ROUTED1(AutofillHostMsg_AutocheckoutPageCompleted,
    268                     autofill::AutocheckoutStatus /* status */)
    269 
    270 // Instructs the browser to show the password generation bubble at the
    271 // specified location. This location should be specified in the renderers
    272 // coordinate system. Form is the form associated with the password field.
    273 IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup,
    274                     gfx::Rect /* source location */,
    275                     int /* max length of the password */,
    276                     content::PasswordForm)
    277 
    278 // Instruct the browser that a password mapping has been found for a field.
    279 IPC_MESSAGE_ROUTED2(AutofillHostMsg_AddPasswordFormMapping,
    280                     autofill::FormFieldData, /* the user name field */
    281                     autofill::PasswordFormFillData /* password pairings */)
    282 
    283 // Instruct the browser to show a popup with the following suggestions from the
    284 // password manager.
    285 IPC_MESSAGE_ROUTED4(AutofillHostMsg_ShowPasswordSuggestions,
    286                     autofill::FormFieldData /* the form field */,
    287                     gfx::RectF /* input field bounds, window-relative */,
    288                     std::vector<base::string16> /* suggestions */,
    289                     std::vector<base::string16> /* realms */)
    290 
    291 // Inform browser of data list values for the curent field.
    292 IPC_MESSAGE_ROUTED2(AutofillHostMsg_SetDataList,
    293                     std::vector<base::string16> /* values */,
    294                     std::vector<base::string16> /* labels */)
    295