summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill/autofill_field.cc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 23:42:34 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-09 23:42:34 +0000
commite2d8667b7a2bb47a25ddd9a74cbd627bf17b5c7e (patch)
tree776a15005671831ab776df8e0deb7d2a366aa23e /chrome/browser/autofill/autofill_field.cc
parent7d01a10bbf5887f4d095f53f5a7b376aa99f4635 (diff)
downloadchromium_src-e2d8667b7a2bb47a25ddd9a74cbd627bf17b5c7e.zip
chromium_src-e2d8667b7a2bb47a25ddd9a74cbd627bf17b5c7e.tar.gz
chromium_src-e2d8667b7a2bb47a25ddd9a74cbd627bf17b5c7e.tar.bz2
autofill: Add the FormField interface. Classes that implement the FormField interface provide heuristics for determining the type of a form field. An initial implementation, EmailField, is provided.
BUG=none TEST=none Review URL: http://codereview.chromium.org/469013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_field.cc')
-rw-r--r--chrome/browser/autofill/autofill_field.cc32
1 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/autofill/autofill_field.cc b/chrome/browser/autofill/autofill_field.cc
index fba28a0..0fcfdc6 100644
--- a/chrome/browser/autofill/autofill_field.cc
+++ b/chrome/browser/autofill/autofill_field.cc
@@ -25,8 +25,28 @@ static std::string Hash32Bit(const std::string& str) {
} // namespace
-AutoFillField::AutoFillField(const webkit_glue::FormField& field)
- : webkit_glue::FormField(field) {
+AutoFillField::AutoFillField()
+ : server_type_(NO_SERVER_DATA),
+ heuristic_type_(UNKNOWN_TYPE) {
+}
+
+AutoFillField::AutoFillField(const webkit_glue::FormField& field,
+ const string16& unique_name)
+ : webkit_glue::FormField(field),
+ unique_name_(unique_name),
+ server_type_(NO_SERVER_DATA),
+ heuristic_type_(UNKNOWN_TYPE) {
+}
+
+AutoFillFieldType AutoFillField::type() const {
+ if (server_type_ != NO_SERVER_DATA)
+ return server_type_;
+
+ return heuristic_type_;
+}
+
+bool AutoFillField::IsEmpty() const {
+ return value().empty();
}
std::string AutoFillField::FieldSignature() const {
@@ -35,3 +55,11 @@ std::string AutoFillField::FieldSignature() const {
std::string field_string = field_name + "&" + type;
return Hash32Bit(field_string);
}
+
+void AutoFillField::set_heuristic_type(const AutoFillFieldType& type) {
+ DCHECK(type >= 0 && type < MAX_VALID_FIELD_TYPE);
+ if (type >= 0 && type < MAX_VALID_FIELD_TYPE)
+ heuristic_type_ = type;
+ else
+ heuristic_type_ = UNKNOWN_TYPE;
+}