summaryrefslogtreecommitdiffstats
path: root/components/autofill
diff options
context:
space:
mode:
authorkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 05:44:43 +0000
committerkaiwang@chromium.org <kaiwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-07 05:44:43 +0000
commitedf48d44a71f3c49a0d0d5e7574c340e843a7791 (patch)
treee242452cf026d4e92170fd6bcd26538346d57154 /components/autofill
parenta5a4e99ea504c2ee4f85b7d9cda746fcfcd3bf84 (diff)
downloadchromium_src-edf48d44a71f3c49a0d0d5e7574c340e843a7791.zip
chromium_src-edf48d44a71f3c49a0d0d5e7574c340e843a7791.tar.gz
chromium_src-edf48d44a71f3c49a0d0d5e7574c340e843a7791.tar.bz2
Establish components/autofill and move some files
Moving autofill related only files under chrome/common/ to components/autofill/common We are going to move autofill to components/autofill to componentize it. This is the first moving CL. BUG=140037 Review URL: https://chromiumcodereview.appspot.com/12543010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/autofill')
-rw-r--r--components/autofill/DEPS4
-rw-r--r--components/autofill/OWNERS5
-rw-r--r--components/autofill/common/autocheckout_status.h19
-rw-r--r--components/autofill/common/autofill_messages.h276
-rw-r--r--components/autofill/common/form_data.cc38
-rw-r--r--components/autofill/common/form_data.h41
-rw-r--r--components/autofill/common/form_data_predictions.cc18
-rw-r--r--components/autofill/common/form_data_predictions.h30
-rw-r--r--components/autofill/common/form_field_data.cc66
-rw-r--r--components/autofill/common/form_field_data.h62
-rw-r--r--components/autofill/common/form_field_data_predictions.cc20
-rw-r--r--components/autofill/common/form_field_data_predictions.h26
-rw-r--r--components/autofill/common/password_form_fill_data.cc45
-rw-r--r--components/autofill/common/password_form_fill_data.h46
-rw-r--r--components/autofill/common/web_element_descriptor.cc9
-rw-r--r--components/autofill/common/web_element_descriptor.h31
16 files changed, 736 insertions, 0 deletions
diff --git a/components/autofill/DEPS b/components/autofill/DEPS
new file mode 100644
index 0000000..9d52b11
--- /dev/null
+++ b/components/autofill/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+third_party/WebKit/Source/WebKit/chromium/public",
+ "+ui",
+]
diff --git a/components/autofill/OWNERS b/components/autofill/OWNERS
new file mode 100644
index 0000000..1957692
--- /dev/null
+++ b/components/autofill/OWNERS
@@ -0,0 +1,5 @@
+dhollowa@chromium.org
+isherman@chromium.org
+
+# Temporary owner, for refactoring changes only.
+joi@chromium.org
diff --git a/components/autofill/common/autocheckout_status.h b/components/autofill/common/autocheckout_status.h
new file mode 100644
index 0000000..80e6abf
--- /dev/null
+++ b/components/autofill/common/autocheckout_status.h
@@ -0,0 +1,19 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_AUTOCHECKOUT_STATUS_H_
+#define COMPONENTS_AUTOFILL_COMMON_AUTOCHECKOUT_STATUS_H_
+
+namespace autofill {
+
+enum AutocheckoutStatus {
+ SUCCESS,
+ MISSING_FIELDMAPPING,
+ MISSING_ADVANCE,
+ CANNOT_PROCEED,
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_COMMON_AUTOCHECKOUT_STATUS_H_
diff --git a/components/autofill/common/autofill_messages.h b/components/autofill/common/autofill_messages.h
new file mode 100644
index 0000000..0583eb0
--- /dev/null
+++ b/components/autofill/common/autofill_messages.h
@@ -0,0 +1,276 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Multiply-included message file, hence no include guard.
+
+#include <string>
+
+#include "base/time.h"
+#include "components/autofill/common/autocheckout_status.h"
+#include "components/autofill/common/form_data.h"
+#include "components/autofill/common/form_data_predictions.h"
+#include "components/autofill/common/form_field_data.h"
+#include "components/autofill/common/form_field_data_predictions.h"
+#include "components/autofill/common/password_form_fill_data.h"
+#include "components/autofill/common/web_element_descriptor.h"
+#include "content/public/common/common_param_traits_macros.h"
+#include "content/public/common/password_form.h"
+#include "content/public/common/ssl_status.h"
+#include "googleurl/src/gurl.h"
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_message_utils.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
+#include "ui/gfx/rect.h"
+
+#define IPC_MESSAGE_START AutofillMsgStart
+
+IPC_ENUM_TRAITS(autofill::AutocheckoutStatus)
+
+IPC_STRUCT_TRAITS_BEGIN(autofill::WebElementDescriptor)
+ IPC_STRUCT_TRAITS_MEMBER(descriptor)
+ IPC_STRUCT_TRAITS_MEMBER(retrieval_method)
+IPC_STRUCT_TRAITS_END()
+
+IPC_ENUM_TRAITS(autofill::WebElementDescriptor::RetrievalMethod)
+
+IPC_STRUCT_TRAITS_BEGIN(FormFieldData)
+ IPC_STRUCT_TRAITS_MEMBER(label)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(value)
+ IPC_STRUCT_TRAITS_MEMBER(form_control_type)
+ IPC_STRUCT_TRAITS_MEMBER(autocomplete_attribute)
+ IPC_STRUCT_TRAITS_MEMBER(max_length)
+ IPC_STRUCT_TRAITS_MEMBER(is_autofilled)
+ IPC_STRUCT_TRAITS_MEMBER(is_checked)
+ IPC_STRUCT_TRAITS_MEMBER(is_checkable)
+ IPC_STRUCT_TRAITS_MEMBER(is_focusable)
+ IPC_STRUCT_TRAITS_MEMBER(should_autocomplete)
+ IPC_STRUCT_TRAITS_MEMBER(option_values)
+ IPC_STRUCT_TRAITS_MEMBER(option_contents)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(FormFieldDataPredictions)
+ IPC_STRUCT_TRAITS_MEMBER(field)
+ IPC_STRUCT_TRAITS_MEMBER(signature)
+ IPC_STRUCT_TRAITS_MEMBER(heuristic_type)
+ IPC_STRUCT_TRAITS_MEMBER(server_type)
+ IPC_STRUCT_TRAITS_MEMBER(overall_type)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(FormData)
+ IPC_STRUCT_TRAITS_MEMBER(name)
+ IPC_STRUCT_TRAITS_MEMBER(method)
+ IPC_STRUCT_TRAITS_MEMBER(origin)
+ IPC_STRUCT_TRAITS_MEMBER(action)
+ IPC_STRUCT_TRAITS_MEMBER(user_submitted)
+ IPC_STRUCT_TRAITS_MEMBER(fields)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(FormDataPredictions)
+ IPC_STRUCT_TRAITS_MEMBER(data)
+ IPC_STRUCT_TRAITS_MEMBER(signature)
+ IPC_STRUCT_TRAITS_MEMBER(experiment_id)
+ IPC_STRUCT_TRAITS_MEMBER(fields)
+IPC_STRUCT_TRAITS_END()
+
+IPC_STRUCT_TRAITS_BEGIN(PasswordFormFillData)
+ IPC_STRUCT_TRAITS_MEMBER(basic_data)
+ IPC_STRUCT_TRAITS_MEMBER(additional_logins)
+ IPC_STRUCT_TRAITS_MEMBER(wait_for_username)
+IPC_STRUCT_TRAITS_END()
+
+IPC_ENUM_TRAITS(WebKit::WebFormElement::AutocompleteResult)
+
+// Autofill messages sent from the browser to the renderer.
+
+// Reply to the AutofillHostMsg_QueryFormFieldAutofill message with the
+// Autofill suggestions.
+IPC_MESSAGE_ROUTED5(AutofillMsg_SuggestionsReturned,
+ int /* id of the request message */,
+ std::vector<string16> /* names */,
+ std::vector<string16> /* labels */,
+ std::vector<string16> /* icons */,
+ std::vector<int> /* unique_ids */)
+
+// Reply to the AutofillHostMsg_FillAutofillFormData message with the
+// Autofill form data.
+IPC_MESSAGE_ROUTED2(AutofillMsg_FormDataFilled,
+ int /* id of the request message */,
+ FormData /* form data */)
+
+// Fill a password form and prepare field autocomplete for multiple
+// matching logins. Lets the renderer know if it should disable the popup
+// because the browser process will own the popup UI.
+IPC_MESSAGE_ROUTED2(AutofillMsg_FillPasswordForm,
+ PasswordFormFillData, /* the fill form data*/
+ bool /* disable popup */ )
+
+// Send the heuristic and server field type predictions to the renderer.
+IPC_MESSAGE_ROUTED1(
+ AutofillMsg_FieldTypePredictionsAvailable,
+ std::vector<FormDataPredictions> /* forms */)
+
+// Tells the renderer that the next form will be filled for real.
+IPC_MESSAGE_ROUTED0(AutofillMsg_SetAutofillActionFill)
+
+// Clears the currently displayed Autofill results.
+IPC_MESSAGE_ROUTED0(AutofillMsg_ClearForm)
+
+// Tells the renderer that the next form will be filled as a preview.
+IPC_MESSAGE_ROUTED0(AutofillMsg_SetAutofillActionPreview)
+
+// Tells the renderer that the Autofill previewed form should be cleared.
+IPC_MESSAGE_ROUTED0(AutofillMsg_ClearPreviewedForm)
+
+// Sets the currently selected node's value.
+IPC_MESSAGE_ROUTED1(AutofillMsg_SetNodeText,
+ string16 /* new node text */)
+
+// Sets the currently selected node's value to be the given data list value.
+IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptDataListSuggestion,
+ string16 /* accepted data list value */)
+
+// Tells the renderer to populate the correct password fields with this
+// generated password.
+IPC_MESSAGE_ROUTED1(AutofillMsg_GeneratedPasswordAccepted,
+ string16 /* generated_password */)
+
+// Tells the renderer whether password generation is enabled.
+IPC_MESSAGE_ROUTED1(AutofillMsg_PasswordGenerationEnabled,
+ bool /* is_enabled */)
+
+// Tells the renderer that the password field has accept the suggestion.
+IPC_MESSAGE_ROUTED1(AutofillMsg_AcceptPasswordAutofillSuggestion,
+ string16 /* username value*/)
+
+// Tells the renderer that this password form is not blacklisted. A form can
+// be blacklisted if a user chooses "never save passwords for this site".
+IPC_MESSAGE_ROUTED1(AutofillMsg_FormNotBlacklisted,
+ content::PasswordForm /* form checked */)
+
+// Sent when requestAutocomplete() finishes (either succesfully or with an
+// error). If it was a success, the renderer fills the form that requested
+// autocomplete with the |form_data| values input by the user.
+IPC_MESSAGE_ROUTED2(AutofillMsg_RequestAutocompleteResult,
+ WebKit::WebFormElement::AutocompleteResult /* result */,
+ FormData /* form_data */)
+
+// Sent when a page should be filled using Autocheckout. This happens when the
+// Autofill server hints that a page is Autocheckout enabled.
+IPC_MESSAGE_ROUTED2(AutofillMsg_FillFormsAndClick,
+ std::vector<FormData> /* form_data */,
+ autofill::WebElementDescriptor /* element_descriptor */)
+
+// Autofill messages sent from the renderer to the browser.
+
+// TODO(creis): check in the browser that the renderer actually has permission
+// for the URL to avoid compromised renderers talking to the browser.
+
+// Notification that forms have been seen that are candidates for
+// filling/submitting by the AutofillManager.
+IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormsSeen,
+ std::vector<FormData> /* forms */,
+ base::TimeTicks /* timestamp */)
+
+// Notification that password forms have been seen that are candidates for
+// filling/submitting by the password manager.
+IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsParsed,
+ std::vector<content::PasswordForm> /* forms */)
+
+// Notification that initial layout has occurred and the following password
+// forms are visible on the page (e.g. not set to display:none.)
+IPC_MESSAGE_ROUTED1(AutofillHostMsg_PasswordFormsRendered,
+ std::vector<content::PasswordForm> /* forms */)
+
+// Notification that a form has been submitted. The user hit the button.
+IPC_MESSAGE_ROUTED2(AutofillHostMsg_FormSubmitted,
+ FormData /* form */,
+ base::TimeTicks /* timestamp */)
+
+// Notification that a form field's value has changed.
+IPC_MESSAGE_ROUTED3(AutofillHostMsg_TextFieldDidChange,
+ FormData /* the form */,
+ FormFieldData /* the form field */,
+ base::TimeTicks /* timestamp */)
+
+// Queries the browser for Autofill suggestions for a form input field.
+IPC_MESSAGE_ROUTED5(AutofillHostMsg_QueryFormFieldAutofill,
+ int /* id of this message */,
+ FormData /* the form */,
+ FormFieldData /* the form field */,
+ gfx::RectF /* input field bounds, window-relative */,
+ bool /* display warning if autofill disabled */)
+
+// Sent when the popup with Autofill suggestions for a form is shown.
+IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidShowAutofillSuggestions,
+ bool /* is this a new popup? */)
+
+// Instructs the browser to fill in the values for a form using Autofill
+// profile data.
+IPC_MESSAGE_ROUTED4(AutofillHostMsg_FillAutofillFormData,
+ int /* id of this message */,
+ FormData /* the form */,
+ FormFieldData /* the form field */,
+ int /* profile unique ID */)
+
+// Sent when a form is previewed with Autofill suggestions.
+IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidPreviewAutofillFormData)
+
+// Sent when a form is filled with Autofill suggestions.
+IPC_MESSAGE_ROUTED1(AutofillHostMsg_DidFillAutofillFormData,
+ base::TimeTicks /* timestamp */)
+
+// Sent when a form receives a request to do interactive autocomplete.
+IPC_MESSAGE_ROUTED3(AutofillHostMsg_RequestAutocomplete,
+ FormData /* form_data */,
+ GURL /* frame_url */,
+ content::SSLStatus /* ssl_status */)
+
+// Instructs the browser to remove the specified Autocomplete entry from the
+// database.
+IPC_MESSAGE_ROUTED2(AutofillHostMsg_RemoveAutocompleteEntry,
+ string16 /* field name */,
+ string16 /* value */)
+
+// Instructs the browser to show the Autofill dialog.
+IPC_MESSAGE_ROUTED0(AutofillHostMsg_ShowAutofillDialog)
+
+// Send when a text field is done editing.
+IPC_MESSAGE_ROUTED0(AutofillHostMsg_DidEndTextFieldEditing)
+
+// Instructs the browser to hide the Autofill popup.
+IPC_MESSAGE_ROUTED0(AutofillHostMsg_HideAutofillPopup)
+
+// Sent when the renderer attempts to click an element in an Autocheckout flow
+// and either the element could not be found or the click did not have the
+// desired effect.
+IPC_MESSAGE_ROUTED1(AutofillHostMsg_ClickFailed,
+ autofill::AutocheckoutStatus /* status */)
+
+// Instructs the browser to show the password generation bubble at the
+// specified location. This location should be specified in the renderers
+// coordinate system. Form is the form associated with the password field.
+IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordGenerationPopup,
+ gfx::Rect /* source location */,
+ int /* max length of the password */,
+ content::PasswordForm)
+
+// Instruct the browser that a password mapping has been found for a field.
+IPC_MESSAGE_ROUTED2(AutofillHostMsg_AddPasswordFormMapping,
+ FormFieldData, /* the user name field */
+ PasswordFormFillData /* password pairings */)
+
+// Instruct the browser to show a popup with the following suggestions from the
+// password manager.
+IPC_MESSAGE_ROUTED3(AutofillHostMsg_ShowPasswordSuggestions,
+ FormFieldData /* the form field */,
+ gfx::RectF /* input field bounds, window-relative */,
+ std::vector<string16> /* suggestions */)
+
+// Inform browser of data list values for the curent field.
+IPC_MESSAGE_ROUTED4(AutofillHostMsg_SetDataList,
+ std::vector<string16> /* values */,
+ std::vector<string16> /* labels */,
+ std::vector<string16> /* icons */,
+ std::vector<int> /* unique ids */)
diff --git a/components/autofill/common/form_data.cc b/components/autofill/common/form_data.cc
new file mode 100644
index 0000000..c4ebbc3
--- /dev/null
+++ b/components/autofill/common/form_data.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/form_data.h"
+
+#include "base/string_util.h"
+
+FormData::FormData()
+ : user_submitted(false) {
+}
+
+FormData::FormData(const FormData& data)
+ : name(data.name),
+ method(data.method),
+ origin(data.origin),
+ action(data.action),
+ user_submitted(data.user_submitted),
+ fields(data.fields),
+ ssl_status(data.ssl_status) {
+}
+
+FormData::~FormData() {
+}
+
+bool FormData::operator==(const FormData& form) const {
+ return (name == form.name &&
+ StringToLowerASCII(method) == StringToLowerASCII(form.method) &&
+ origin == form.origin &&
+ action == form.action &&
+ user_submitted == form.user_submitted &&
+ fields == form.fields &&
+ ssl_status.Equals(form.ssl_status));
+}
+
+bool FormData::operator!=(const FormData& form) const {
+ return !operator==(form);
+}
diff --git a/components/autofill/common/form_data.h b/components/autofill/common/form_data.h
new file mode 100644
index 0000000..01ab98a
--- /dev/null
+++ b/components/autofill/common/form_data.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_FORM_DATA_H__
+#define COMPONENTS_AUTOFILL_COMMON_FORM_DATA_H__
+
+#include <vector>
+
+#include "base/string16.h"
+#include "components/autofill/common/form_field_data.h"
+#include "content/public/common/ssl_status.h"
+#include "googleurl/src/gurl.h"
+
+// Holds information about a form to be filled and/or submitted.
+struct FormData {
+ FormData();
+ FormData(const FormData& data);
+ ~FormData();
+
+ // Used by FormStructureTest.
+ bool operator==(const FormData& form) const;
+ bool operator!=(const FormData& form) const;
+
+ // The name of the form.
+ string16 name;
+ // GET or POST.
+ string16 method;
+ // The URL (minus query parameters) containing the form.
+ GURL origin;
+ // The action target of the form.
+ GURL action;
+ // true if this form was submitted by a user gesture and not javascript.
+ bool user_submitted;
+ // A vector of all the input fields in the form.
+ std::vector<FormFieldData> fields;
+ // SSL status of the frame contatining the form.
+ content::SSLStatus ssl_status;
+};
+
+#endif // COMPONENTS_AUTOFILL_COMMON_FORM_DATA_H__
diff --git a/components/autofill/common/form_data_predictions.cc b/components/autofill/common/form_data_predictions.cc
new file mode 100644
index 0000000..184d19f
--- /dev/null
+++ b/components/autofill/common/form_data_predictions.cc
@@ -0,0 +1,18 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/form_data_predictions.h"
+
+FormDataPredictions::FormDataPredictions() {
+}
+
+FormDataPredictions::FormDataPredictions(const FormDataPredictions& other)
+ : data(other.data),
+ signature(other.signature),
+ experiment_id(other.experiment_id),
+ fields(other.fields) {
+}
+
+FormDataPredictions::~FormDataPredictions() {
+}
diff --git a/components/autofill/common/form_data_predictions.h b/components/autofill/common/form_data_predictions.h
new file mode 100644
index 0000000..8196402
--- /dev/null
+++ b/components/autofill/common/form_data_predictions.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_FORM_DATA_PREDICTIONS_H__
+#define COMPONENTS_AUTOFILL_COMMON_FORM_DATA_PREDICTIONS_H__
+
+#include <string>
+#include <vector>
+
+#include "components/autofill/common/form_data.h"
+#include "components/autofill/common/form_field_data_predictions.h"
+
+// Holds information about a form to be filled and/or submitted.
+struct FormDataPredictions {
+ // Data for this form.
+ FormData data;
+ // The form signature for communication with the crowdsourcing server.
+ std::string signature;
+ // The experiment id for the server predictions.
+ std::string experiment_id;
+ // The form fields and their predicted field types.
+ std::vector<FormFieldDataPredictions> fields;
+
+ FormDataPredictions();
+ FormDataPredictions(const FormDataPredictions& other);
+ ~FormDataPredictions();
+};
+
+#endif // COMPONENTS_AUTOFILL_COMMON_FORM_DATA_PREDICTIONS_H__
diff --git a/components/autofill/common/form_field_data.cc b/components/autofill/common/form_field_data.cc
new file mode 100644
index 0000000..d78966d
--- /dev/null
+++ b/components/autofill/common/form_field_data.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/form_field_data.h"
+
+#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
+
+FormFieldData::FormFieldData()
+ : max_length(0),
+ is_autofilled(false),
+ is_checked(false),
+ is_checkable(false),
+ is_focusable(false),
+ should_autocomplete(true) {
+}
+
+FormFieldData::~FormFieldData() {
+}
+
+bool FormFieldData::operator==(const FormFieldData& field) const {
+ // A FormFieldData stores a value, but the value is not part of the identity
+ // of the field, so we don't want to compare the values.
+ return (label == field.label &&
+ name == field.name &&
+ form_control_type == field.form_control_type &&
+ autocomplete_attribute == field.autocomplete_attribute &&
+ max_length == field.max_length);
+}
+
+bool FormFieldData::operator!=(const FormFieldData& field) const {
+ return !operator==(field);
+}
+
+bool FormFieldData::operator<(const FormFieldData& field) const {
+ if (label == field.label)
+ return name < field.name;
+
+ return label < field.label;
+}
+
+std::ostream& operator<<(std::ostream& os, const FormFieldData& field) {
+ return os
+ << UTF16ToUTF8(field.label)
+ << " "
+ << UTF16ToUTF8(field.name)
+ << " "
+ << UTF16ToUTF8(field.value)
+ << " "
+ << field.form_control_type
+ << " "
+ << field.autocomplete_attribute
+ << " "
+ << field.max_length
+ << " "
+ << (field.is_autofilled ? "true" : "false")
+ << " "
+ << (field.is_checked ? "true" : "false")
+ << " "
+ << (field.is_checkable ? "true" : "false")
+ << " "
+ << (field.is_focusable ? "true" : "false")
+ << " "
+ << (field.should_autocomplete ? "true" : "false");
+}
diff --git a/components/autofill/common/form_field_data.h b/components/autofill/common/form_field_data.h
new file mode 100644
index 0000000..6d0d2f6
--- /dev/null
+++ b/components/autofill/common/form_field_data.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_
+#define COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_
+
+#include <vector>
+
+#include "base/string16.h"
+
+// Stores information about a field in a form.
+struct FormFieldData {
+ FormFieldData();
+ ~FormFieldData();
+
+ // Equality tests for identity which does not include |value| or
+ // |is_autofilled|.
+ // TODO(dhollowa): These operators need to be revised when we implement field
+ // ids.
+ bool operator==(const FormFieldData& field) const;
+ bool operator!=(const FormFieldData& field) const;
+ // Comparison operator exposed for STL map. Uses label, then name to sort.
+ bool operator<(const FormFieldData& field) const;
+
+ string16 label;
+ string16 name;
+ string16 value;
+ std::string form_control_type;
+ std::string autocomplete_attribute;
+ size_t max_length;
+ bool is_autofilled;
+ bool is_checked;
+ bool is_checkable;
+ bool is_focusable;
+ bool should_autocomplete;
+
+ // For the HTML snippet |<option value="US">United States</option>|, the
+ // value is "US" and the contents are "United States".
+ std::vector<string16> option_values;
+ std::vector<string16> option_contents;
+};
+
+// So we can compare FormFieldDatas with EXPECT_EQ().
+std::ostream& operator<<(std::ostream& os, const FormFieldData& field);
+
+// Prefer to use this macro in place of |EXPECT_EQ()| for comparing
+// |FormFieldData|s in test code.
+#define EXPECT_FORM_FIELD_DATA_EQUALS(expected, actual) \
+ do { \
+ EXPECT_EQ(expected.label, actual.label); \
+ EXPECT_EQ(expected.name, actual.name); \
+ EXPECT_EQ(expected.value, actual.value); \
+ EXPECT_EQ(expected.form_control_type, actual.form_control_type); \
+ EXPECT_EQ(expected.autocomplete_attribute, actual.autocomplete_attribute); \
+ EXPECT_EQ(expected.max_length, actual.max_length); \
+ EXPECT_EQ(expected.is_autofilled, actual.is_autofilled); \
+ EXPECT_EQ(expected.is_checked, actual.is_checked); \
+ EXPECT_EQ(expected.is_checkable, actual.is_checkable); \
+ } while (0)
+
+#endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_H_
diff --git a/components/autofill/common/form_field_data_predictions.cc b/components/autofill/common/form_field_data_predictions.cc
new file mode 100644
index 0000000..3c04564
--- /dev/null
+++ b/components/autofill/common/form_field_data_predictions.cc
@@ -0,0 +1,20 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/form_field_data_predictions.h"
+
+FormFieldDataPredictions::FormFieldDataPredictions() {
+}
+
+FormFieldDataPredictions::FormFieldDataPredictions(
+ const FormFieldDataPredictions& other)
+ : field(other.field),
+ signature(other.signature),
+ heuristic_type(other.heuristic_type),
+ server_type(other.server_type),
+ overall_type(other.overall_type) {
+}
+
+FormFieldDataPredictions::~FormFieldDataPredictions() {
+}
diff --git a/components/autofill/common/form_field_data_predictions.h b/components/autofill/common/form_field_data_predictions.h
new file mode 100644
index 0000000..3d0b982
--- /dev/null
+++ b/components/autofill/common/form_field_data_predictions.h
@@ -0,0 +1,26 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_PREDICTIONS_H_
+#define COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_PREDICTIONS_H_
+
+#include <string>
+#include <vector>
+
+#include "components/autofill/common/form_field_data.h"
+
+// Stores information about a field in a form.
+struct FormFieldDataPredictions {
+ FormFieldDataPredictions();
+ FormFieldDataPredictions(const FormFieldDataPredictions& other);
+ ~FormFieldDataPredictions();
+
+ FormFieldData field;
+ std::string signature;
+ std::string heuristic_type;
+ std::string server_type;
+ std::string overall_type;
+};
+
+#endif // COMPONENTS_AUTOFILL_COMMON_FORM_FIELD_DATA_PREDICTIONS_H_
diff --git a/components/autofill/common/password_form_fill_data.cc b/components/autofill/common/password_form_fill_data.cc
new file mode 100644
index 0000000..e6456e6
--- /dev/null
+++ b/components/autofill/common/password_form_fill_data.cc
@@ -0,0 +1,45 @@
+// Copyright 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/password_form_fill_data.h"
+
+#include "base/logging.h"
+#include "components/autofill/common/form_field_data.h"
+
+PasswordFormFillData::PasswordFormFillData() : wait_for_username(false) {
+}
+
+PasswordFormFillData::~PasswordFormFillData() {
+}
+
+void InitPasswordFormFillData(
+ const content::PasswordForm& form_on_page,
+ const content::PasswordFormMap& matches,
+ const content::PasswordForm* const preferred_match,
+ bool wait_for_username_before_autofill,
+ PasswordFormFillData* result) {
+ // Note that many of the |FormFieldData| members are not initialized for
+ // |username_field| and |password_field| because they are currently not used
+ // by the password autocomplete code.
+ FormFieldData username_field;
+ username_field.name = form_on_page.username_element;
+ username_field.value = preferred_match->username_value;
+ FormFieldData password_field;
+ password_field.name = form_on_page.password_element;
+ password_field.value = preferred_match->password_value;
+
+ // Fill basic form data.
+ result->basic_data.origin = form_on_page.origin;
+ result->basic_data.action = form_on_page.action;
+ result->basic_data.fields.push_back(username_field);
+ result->basic_data.fields.push_back(password_field);
+ result->wait_for_username = wait_for_username_before_autofill;
+
+ // Copy additional username/value pairs.
+ content::PasswordFormMap::const_iterator iter;
+ for (iter = matches.begin(); iter != matches.end(); iter++) {
+ if (iter->second != preferred_match)
+ result->additional_logins[iter->first] = iter->second->password_value;
+ }
+}
diff --git a/components/autofill/common/password_form_fill_data.h b/components/autofill/common/password_form_fill_data.h
new file mode 100644
index 0000000..288f9f8
--- /dev/null
+++ b/components/autofill/common/password_form_fill_data.h
@@ -0,0 +1,46 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H_
+#define COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H_
+
+#include <map>
+
+#include "base/memory/scoped_ptr.h"
+#include "components/autofill/common/form_data.h"
+#include "content/public/common/password_form.h"
+
+// Structure used for autofilling password forms.
+// basic_data identifies the HTML form on the page and preferred username/
+// password for login, while
+// additional_logins is a list of other matching user/pass pairs for the form.
+// wait_for_username tells us whether we need to wait for the user to enter
+// a valid username before we autofill the password. By default, this is off
+// unless the PasswordManager determined there is an additional risk
+// associated with this form. This can happen, for example, if action URI's
+// of the observed form and our saved representation don't match up.
+struct PasswordFormFillData {
+ typedef std::map<string16, string16> LoginCollection;
+
+ FormData basic_data;
+ LoginCollection additional_logins;
+ bool wait_for_username;
+ PasswordFormFillData();
+ ~PasswordFormFillData();
+};
+
+// Create a FillData structure in preparation for autofilling a form,
+// from basic_data identifying which form to fill, and a collection of
+// matching stored logins to use as username/password values.
+// preferred_match should equal (address) one of matches.
+// wait_for_username_before_autofill is true if we should not autofill
+// anything until the user typed in a valid username and blurred the field.
+void InitPasswordFormFillData(
+ const content::PasswordForm& form_on_page,
+ const content::PasswordFormMap& matches,
+ const content::PasswordForm* const preferred_match,
+ bool wait_for_username_before_autofill,
+ PasswordFormFillData* result);
+
+#endif // COMPONENTS_AUTOFILL_COMMON_PASSWORD_FORM_FILL_DATA_H__
diff --git a/components/autofill/common/web_element_descriptor.cc b/components/autofill/common/web_element_descriptor.cc
new file mode 100644
index 0000000..8b897b8
--- /dev/null
+++ b/components/autofill/common/web_element_descriptor.cc
@@ -0,0 +1,9 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/autofill/common/web_element_descriptor.h"
+
+autofill::WebElementDescriptor::WebElementDescriptor()
+ : retrieval_method(NONE) {}
+
diff --git a/components/autofill/common/web_element_descriptor.h b/components/autofill/common/web_element_descriptor.h
new file mode 100644
index 0000000..0e0aabf
--- /dev/null
+++ b/components/autofill/common/web_element_descriptor.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_AUTOFILL_COMMON_WEB_ELEMENT_DESCRIPTOR_H_
+#define COMPONENTS_AUTOFILL_COMMON_WEB_ELEMENT_DESCRIPTOR_H_
+
+#include <string>
+
+namespace autofill {
+
+// Holds information that can be used to retrieve an element.
+struct WebElementDescriptor {
+ enum RetrievalMethod {
+ CSS_SELECTOR,
+ ID,
+ NONE,
+ };
+
+ WebElementDescriptor();
+
+ // Information to retrieve element with.
+ std::string descriptor;
+
+ // Which retrieval method to use.
+ RetrievalMethod retrieval_method;
+};
+
+} // namespace autofill
+
+#endif // COMPONENTS_AUTOFILL_COMMON_WEB_ELEMENT_DESCRIPTOR_H_