summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/webdata/web_database_unittest.cc44
-rw-r--r--chrome/common/render_messages.h6
-rw-r--r--webkit/glue/form_field.cc6
-rw-r--r--webkit/glue/form_field.h5
-rw-r--r--webkit/glue/form_field_values.cc4
5 files changed, 47 insertions, 18 deletions
diff --git a/chrome/browser/webdata/web_database_unittest.cc b/chrome/browser/webdata/web_database_unittest.cc
index 14f52e1..4a54d76 100644
--- a/chrome/browser/webdata/web_database_unittest.cc
+++ b/chrome/browser/webdata/web_database_unittest.cc
@@ -392,23 +392,29 @@ TEST_F(WebDatabaseTest, Autofill) {
// Simulate the submission of a handful of entries in a field called "Name",
// some more often than others.
EXPECT_TRUE(db.AddFormFieldValue(
- FormField(ASCIIToUTF16("Name"), string16(), ASCIIToUTF16("Superman"))));
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
+ string16(),
+ ASCIIToUTF16("Superman"))));
std::vector<string16> v;
for (int i = 0; i < 5; i++) {
EXPECT_TRUE(db.AddFormFieldValue(
- FormField(ASCIIToUTF16("Name"),
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
string16(),
ASCIIToUTF16("Clark Kent"))));
}
for (int i = 0; i < 3; i++) {
EXPECT_TRUE(db.AddFormFieldValue(
- FormField(ASCIIToUTF16("Name"),
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
string16(),
ASCIIToUTF16("Clark Sutter"))));
}
for (int i = 0; i < 2; i++) {
EXPECT_TRUE(db.AddFormFieldValue(
- FormField(ASCIIToUTF16("Favorite Color"),
+ FormField(string16(),
+ ASCIIToUTF16("Favorite Color"),
string16(),
ASCIIToUTF16("Green"))));
}
@@ -419,7 +425,10 @@ TEST_F(WebDatabaseTest, Autofill) {
// We have added the name Clark Kent 5 times, so count should be 5 and pair_id
// should be somthing non-zero.
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- FormField(ASCIIToUTF16("Name"), string16(), ASCIIToUTF16("Clark Kent")),
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
+ string16(),
+ ASCIIToUTF16("Clark Kent")),
&pair_id, &count));
EXPECT_EQ(5, count);
EXPECT_NE(0, pair_id);
@@ -427,12 +436,16 @@ TEST_F(WebDatabaseTest, Autofill) {
// Storing in the data base should be case sensitive, so there should be no
// database entry for clark kent lowercase.
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- FormField(ASCIIToUTF16("Name"), string16(), ASCIIToUTF16("clark kent")),
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
+ string16(),
+ ASCIIToUTF16("clark kent")),
&pair_id, &count));
EXPECT_EQ(0, count);
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- FormField(ASCIIToUTF16("Favorite Color"),
+ FormField(string16(),
+ ASCIIToUTF16("Favorite Color"),
string16(),
ASCIIToUTF16("Green")),
&pair_id, &count));
@@ -475,7 +488,10 @@ TEST_F(WebDatabaseTest, Autofill) {
EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time()));
EXPECT_TRUE(db.GetIDAndCountOfFormElement(
- FormField(ASCIIToUTF16("Name"), string16(), ASCIIToUTF16("Clark Kent")),
+ FormField(string16(),
+ ASCIIToUTF16("Name"),
+ string16(),
+ ASCIIToUTF16("Clark Kent")),
&pair_id, &count));
EXPECT_EQ(0, count);
@@ -485,16 +501,20 @@ TEST_F(WebDatabaseTest, Autofill) {
// Now add some values with empty strings.
const string16 kValue = ASCIIToUTF16(" toto ");
- EXPECT_TRUE(db.AddFormFieldValue(FormField(ASCIIToUTF16("blank"),
+ EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(),
+ ASCIIToUTF16("blank"),
string16(),
string16())));
- EXPECT_TRUE(db.AddFormFieldValue(FormField(ASCIIToUTF16("blank"),
+ EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(),
+ ASCIIToUTF16("blank"),
string16(),
ASCIIToUTF16(" "))));
- EXPECT_TRUE(db.AddFormFieldValue(FormField(ASCIIToUTF16("blank"),
+ EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(),
+ ASCIIToUTF16("blank"),
string16(),
ASCIIToUTF16(" "))));
- EXPECT_TRUE(db.AddFormFieldValue(FormField(ASCIIToUTF16("blank"),
+ EXPECT_TRUE(db.AddFormFieldValue(FormField(string16(),
+ ASCIIToUTF16("blank"),
string16(),
kValue)));
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 3403448..b6ccc67 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -827,6 +827,7 @@ struct ParamTraits<webkit_glue::FormFieldValues> {
WriteParam(m, p.elements.size());
std::vector<webkit_glue::FormField>::const_iterator itr;
for (itr = p.elements.begin(); itr != p.elements.end(); itr++) {
+ WriteParam(m, itr->label());
WriteParam(m, itr->name());
WriteParam(m, itr->html_input_type());
WriteParam(m, itr->value());
@@ -843,11 +844,12 @@ struct ParamTraits<webkit_glue::FormFieldValues> {
result = result && ReadParam(m, iter, &elements_size);
p->elements.resize(elements_size);
for (size_t i = 0; i < elements_size; i++) {
- string16 name, type, value;
+ string16 label, name, type, value;
+ result = result && ReadParam(m, iter, &label);
result = result && ReadParam(m, iter, &name);
result = result && ReadParam(m, iter, &type);
result = result && ReadParam(m, iter, &value);
- p->elements[i] = webkit_glue::FormField(name, type, value);
+ p->elements[i] = webkit_glue::FormField(label, name, type, value);
}
return result;
}
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc
index 6d49054..a87644f 100644
--- a/webkit/glue/form_field.cc
+++ b/webkit/glue/form_field.cc
@@ -9,10 +9,12 @@ namespace webkit_glue {
FormField::FormField() {
}
-FormField::FormField(const string16& name,
+FormField::FormField(const string16& label,
+ const string16& name,
const string16& html_input_type,
const string16& value)
- : name_(name),
+ : label_(label),
+ name_(name),
html_input_type_(html_input_type),
value_(value) {
}
diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h
index 92e8faea..9711c38 100644
--- a/webkit/glue/form_field.h
+++ b/webkit/glue/form_field.h
@@ -13,10 +13,12 @@ namespace webkit_glue {
class FormField {
public:
FormField();
- FormField(const string16& name,
+ FormField(const string16& label,
+ const string16& name,
const string16& html_input_type,
const string16& value);
+ string16 label() const { return label_; }
string16 name() const { return name_; }
string16 html_input_type() const { return html_input_type_; }
string16 value() const { return value_; }
@@ -24,6 +26,7 @@ class FormField {
void set_value(const string16& value) { value_ = value; }
private:
+ string16 label_;
string16 name_;
string16 html_input_type_;
string16 value_;
diff --git a/webkit/glue/form_field_values.cc b/webkit/glue/form_field_values.cc
index 66d6b0a..6118889 100644
--- a/webkit/glue/form_field_values.cc
+++ b/webkit/glue/form_field_values.cc
@@ -62,7 +62,9 @@ void FormFieldValues::ExtractFormFieldValues(
if (type.empty())
continue;
- elements.push_back(FormField(name, type, value));
+ // TODO(jhawkins): Extract the field label. For now we just use the field
+ // name.
+ elements.push_back(FormField(name, name, type, value));
}
}