summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/autocomplete_history_manager.cc10
-rw-r--r--chrome/browser/autofill/address_field.cc4
-rw-r--r--chrome/browser/autofill/autofill_common_test.h2
-rw-r--r--chrome/browser/autofill/autofill_field.cc6
-rw-r--r--chrome/browser/autofill/autofill_field_unittest.cc12
-rw-r--r--chrome/browser/autofill/autofill_manager.cc40
-rw-r--r--chrome/browser/autofill/autofill_manager.h2
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc36
-rw-r--r--chrome/browser/autofill/autofill_merge_unittest.cc2
-rw-r--r--chrome/browser/autofill/autofill_metrics_unittest.cc8
-rw-r--r--chrome/browser/autofill/credit_card_field.cc4
-rw-r--r--chrome/browser/autofill/form_field.cc6
-rw-r--r--chrome/browser/autofill/form_field_unittest.cc34
-rw-r--r--chrome/browser/autofill/form_structure.cc4
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc4
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc6
-rw-r--r--chrome/browser/autofill/phone_field.cc4
-rw-r--r--chrome/browser/autofill/select_control_handler.cc24
-rw-r--r--chrome/browser/autofill/select_control_handler.h2
-rw-r--r--chrome/browser/autofill/select_control_handler_unittest.cc48
-rw-r--r--chrome/browser/webdata/web_database.cc16
-rw-r--r--chrome/browser/webdata/web_database.h2
-rw-r--r--chrome/chrome_common.gypi1
-rw-r--r--chrome/common/autofill_messages.cc105
-rw-r--r--chrome/common/autofill_messages.h71
-rw-r--r--chrome/common/common_message_generator.h2
-rw-r--r--chrome/renderer/autofill/autofill_agent.cc4
-rw-r--r--chrome/renderer/autofill/form_autocomplete_browsertest.cc12
-rw-r--r--chrome/renderer/autofill/form_manager.cc34
-rw-r--r--chrome/renderer/autofill/form_manager.h2
-rw-r--r--chrome/renderer/autofill/form_manager_browsertest.cc92
-rw-r--r--chrome/renderer/autofill/password_autofill_manager.cc20
-rw-r--r--content/browser/renderer_host/render_view_host_delegate.h2
-rw-r--r--webkit/glue/form_field.cc72
-rw-r--r--webkit/glue/form_field.h43
-rw-r--r--webkit/glue/webpasswordautocompletelistener_impl.cc14
36 files changed, 446 insertions, 304 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc
index bbc3387..e93bd8c 100644
--- a/chrome/browser/autocomplete_history_manager.cc
+++ b/chrome/browser/autocomplete_history_manager.cc
@@ -119,11 +119,11 @@ void AutocompleteHistoryManager::OnFormSubmitted(const FormData& form) {
for (std::vector<webkit_glue::FormField>::const_iterator iter =
form.fields.begin();
iter != form.fields.end(); ++iter) {
- if (!iter->value.empty() &&
- !iter->name.empty() &&
- iter->form_control_type == ASCIIToUTF16("text") &&
- !CreditCard::IsCreditCardNumber(iter->value) &&
- !IsSSN(iter->value))
+ if (!iter->value().empty() &&
+ !iter->name().empty() &&
+ iter->form_control_type() == ASCIIToUTF16("text") &&
+ !CreditCard::IsCreditCardNumber(iter->value()) &&
+ !IsSSN(iter->value()))
values.push_back(*iter);
}
diff --git a/chrome/browser/autofill/address_field.cc b/chrome/browser/autofill/address_field.cc
index 5d4d0cc..06fb859 100644
--- a/chrome/browser/autofill/address_field.cc
+++ b/chrome/browser/autofill/address_field.cc
@@ -148,7 +148,7 @@ AddressType AddressField::FindType() const {
// "bill" or "ship". We could check for the ECML type prefixes
// here, but there's no need to since ECML's prefixes Ecom_BillTo
// and Ecom_ShipTo contain "bill" and "ship" anyway.
- string16 name = StringToLowerASCII(address1_->name);
+ string16 name = StringToLowerASCII(address1_->name());
return AddressTypeFromText(name);
}
@@ -294,7 +294,7 @@ bool AddressField::ParseZipCode(
}
AddressType tempType;
- string16 name = (**iter)->name;
+ string16 name = (**iter)->name();
// Note: comparisons using the ecml compliant name as a prefix must be used in
// order to accommodate Google Checkout. See FormFieldSet::GetEcmlPattern for
diff --git a/chrome/browser/autofill/autofill_common_test.h b/chrome/browser/autofill/autofill_common_test.h
index 72f0a14..0a1dcfc 100644
--- a/chrome/browser/autofill/autofill_common_test.h
+++ b/chrome/browser/autofill/autofill_common_test.h
@@ -11,7 +11,7 @@ class CreditCard;
class Profile;
namespace webkit_glue {
-struct FormField;
+class FormField;
} // namespace webkit_glue
// Common utilities shared amongst AutoFill tests.
diff --git a/chrome/browser/autofill/autofill_field.cc b/chrome/browser/autofill/autofill_field.cc
index ce5fc83..1127031 100644
--- a/chrome/browser/autofill/autofill_field.cc
+++ b/chrome/browser/autofill/autofill_field.cc
@@ -59,12 +59,12 @@ AutofillFieldType AutofillField::type() const {
}
bool AutofillField::IsEmpty() const {
- return value.empty();
+ return value().empty();
}
std::string AutofillField::FieldSignature() const {
- std::string field_name = UTF16ToUTF8(name);
- std::string type = UTF16ToUTF8(form_control_type);
+ std::string field_name = UTF16ToUTF8(name());
+ std::string type = UTF16ToUTF8(form_control_type());
std::string field_string = field_name + "&" + type;
return Hash32Bit(field_string);
}
diff --git a/chrome/browser/autofill/autofill_field_unittest.cc b/chrome/browser/autofill/autofill_field_unittest.cc
index 697e86c..7723551 100644
--- a/chrome/browser/autofill/autofill_field_unittest.cc
+++ b/chrome/browser/autofill/autofill_field_unittest.cc
@@ -33,30 +33,30 @@ TEST(AutofillFieldTest, Type) {
TEST(AutofillFieldTest, IsEmpty) {
AutofillField field;
- ASSERT_EQ(string16(), field.value);
+ ASSERT_EQ(string16(), field.value());
// Field value is empty.
EXPECT_TRUE(field.IsEmpty());
// Field value is non-empty.
- field.value = ASCIIToUTF16("Value");
+ field.set_value(ASCIIToUTF16("Value"));
EXPECT_FALSE(field.IsEmpty());
}
TEST(AutofillFieldTest, FieldSignature) {
AutofillField field;
- ASSERT_EQ(string16(), field.name);
- ASSERT_EQ(string16(), field.form_control_type);
+ ASSERT_EQ(string16(), field.name());
+ ASSERT_EQ(string16(), field.form_control_type());
// Signature is empty.
EXPECT_EQ("2085434232", field.FieldSignature());
// Field name is set.
- field.name = ASCIIToUTF16("Name");
+ field.set_name(ASCIIToUTF16("Name"));
EXPECT_EQ("1606968241", field.FieldSignature());
// Field form control type is set.
- field.form_control_type = ASCIIToUTF16("Text");
+ field.set_form_control_type(ASCIIToUTF16("Text"));
EXPECT_EQ("4246049809", field.FieldSignature());
// Heuristic type does not affect FieldSignature.
diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc
index b7752fb..8d46c84 100644
--- a/chrome/browser/autofill/autofill_manager.cc
+++ b/chrome/browser/autofill/autofill_manager.cc
@@ -193,7 +193,7 @@ bool SectionIsAutoFilled(const FormStructure* form_structure,
continue;
AutofillType autofill_type(form_structure->field(k)->type());
- if (form.fields[j].is_autofilled)
+ if (form.fields[j].is_autofilled())
return true;
// We found a matching field in the |form_structure| so we
@@ -382,7 +382,7 @@ void AutofillManager::OnQueryFormFieldAutoFill(
// hand off what we generated and they will send the results back to the
// renderer.
tab_contents()->autocomplete_history_manager()->OnGetAutocompleteSuggestions(
- query_id, field.name, field.value, values, labels, icons, unique_ids);
+ query_id, field.name(), field.value(), values, labels, icons, unique_ids);
}
void AutofillManager::OnFillAutoFillFormData(int query_id,
@@ -577,7 +577,7 @@ void AutofillManager::DeterminePossibleFieldTypesForUpload(
for (size_t i = 0; i < submitted_form->field_count(); i++) {
const AutofillField* field = submitted_form->field(i);
FieldTypeSet field_types;
- personal_data_->GetPossibleFieldTypes(field->value, &field_types);
+ personal_data_->GetPossibleFieldTypes(field->value(), &field_types);
DCHECK(!field_types.empty());
submitted_form->set_possible_types(i, field_types);
@@ -604,11 +604,11 @@ void AutofillManager::LogMetricsAboutSubmittedForm(
for (size_t i = 0; i < submitted_form->field_count(); ++i) {
const AutofillField* field = submitted_form->field(i);
FieldTypeSet field_types;
- personal_data_->GetPossibleFieldTypes(field->value, &field_types);
+ personal_data_->GetPossibleFieldTypes(field->value(), &field_types);
DCHECK(!field_types.empty());
- if (field->form_control_type == ASCIIToUTF16("select-one")) {
- // TODO(isherman): <select> fields don't support |is_autofilled|. Since
+ if (field->form_control_type() == ASCIIToUTF16("select-one")) {
+ // TODO(isherman): <select> fields don't support |is_autofilled()|. Since
// this is heavily relied upon by our metrics, we just don't log anything
// for all <select> fields. Better to have less data than misleading data.
continue;
@@ -618,7 +618,7 @@ void AutofillManager::LogMetricsAboutSubmittedForm(
metric_logger_->Log(AutofillMetrics::FIELD_SUBMITTED, experiment_id);
if (field_types.find(EMPTY_TYPE) == field_types.end() &&
field_types.find(UNKNOWN_TYPE) == field_types.end()) {
- if (field->is_autofilled) {
+ if (field->is_autofilled()) {
metric_logger_->Log(AutofillMetrics::FIELD_AUTOFILLED, experiment_id);
} else {
metric_logger_->Log(AutofillMetrics::FIELD_AUTOFILL_FAILED,
@@ -817,7 +817,7 @@ void AutofillManager::GetProfileSuggestions(FormStructure* form,
string16 profile_field_value = profile->GetFieldText(type);
if (!profile_field_value.empty() &&
- StartsWith(profile_field_value, field.value, false)) {
+ StartsWith(profile_field_value, field.value(), false)) {
matched_profiles.push_back(profile);
values->push_back(profile_field_value);
unique_ids->push_back(PackGUIDs(std::string(), profile->guid()));
@@ -857,7 +857,7 @@ void AutofillManager::GetCreditCardSuggestions(FormStructure* form,
// The value of the stored data for this field type in the |credit_card|.
string16 creditcard_field_value = credit_card->GetFieldText(type);
if (!creditcard_field_value.empty() &&
- StartsWith(creditcard_field_value, field.value, false)) {
+ StartsWith(creditcard_field_value, field.value(), false)) {
if (type.field_type() == CREDIT_CARD_NUMBER)
creditcard_field_value = credit_card->ObfuscatedNumber();
@@ -876,9 +876,9 @@ void AutofillManager::FillCreditCardFormField(const CreditCard* credit_card,
DCHECK_EQ(AutofillType::CREDIT_CARD, type.group());
DCHECK(field);
- if (field->form_control_type == ASCIIToUTF16("select-one")) {
+ if (field->form_control_type() == ASCIIToUTF16("select-one")) {
autofill::FillSelectControl(*credit_card, type, field);
- } else if (field->form_control_type == ASCIIToUTF16("month")) {
+ } else if (field->form_control_type() == ASCIIToUTF16("month")) {
// HTML5 input="month" consists of year-month.
string16 year = credit_card->GetFieldText(
AutofillType(CREDIT_CARD_EXP_4_DIGIT_YEAR));
@@ -887,10 +887,10 @@ void AutofillManager::FillCreditCardFormField(const CreditCard* credit_card,
if (!year.empty() && !month.empty()) {
// Fill the value only if |credit_card| includes both year and month
// information.
- field->value = year + ASCIIToUTF16("-") + month;
+ field->set_value(year + ASCIIToUTF16("-") + month);
}
} else {
- field->value = credit_card->GetFieldText(type);
+ field->set_value(credit_card->GetFieldText(type));
}
}
@@ -904,10 +904,10 @@ void AutofillManager::FillFormField(const AutoFillProfile* profile,
if (type.subgroup() == AutofillType::PHONE_NUMBER) {
FillPhoneNumberField(profile, type, field);
} else {
- if (field->form_control_type == ASCIIToUTF16("select-one"))
+ if (field->form_control_type() == ASCIIToUTF16("select-one"))
autofill::FillSelectControl(*profile, type, field);
else
- field->value = profile->GetFieldText(type);
+ field->set_value(profile->GetFieldText(type));
}
}
@@ -921,17 +921,17 @@ void AutofillManager::FillPhoneNumberField(const AutoFillProfile* profile,
static_cast<size_t>(PhoneNumber::kPrefixLength +
PhoneNumber::kSuffixLength));
if (has_valid_suffix_and_prefix &&
- field->max_length == PhoneNumber::kPrefixLength) {
+ field->max_length() == PhoneNumber::kPrefixLength) {
number = number.substr(PhoneNumber::kPrefixOffset,
PhoneNumber::kPrefixLength);
- field->value = number;
+ field->set_value(number);
} else if (has_valid_suffix_and_prefix &&
- field->max_length == PhoneNumber::kSuffixLength) {
+ field->max_length() == PhoneNumber::kSuffixLength) {
number = number.substr(PhoneNumber::kSuffixOffset,
PhoneNumber::kSuffixLength);
- field->value = number;
+ field->set_value(number);
} else {
- field->value = number;
+ field->set_value(number);
}
}
diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h
index c2d93d7..c9697c3 100644
--- a/chrome/browser/autofill/autofill_manager.h
+++ b/chrome/browser/autofill/autofill_manager.h
@@ -28,7 +28,7 @@ class RenderViewHost;
namespace webkit_glue {
struct FormData;
-struct FormField;
+class FormField;
} // namespace webkit_glue
// Manages saving and restoring the user's personal information entered into web
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index e3d912b..422f676 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -1178,7 +1178,7 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsWhenFormIsAutoFilled) {
FormsSeen(forms);
// Mark one of the fields as filled.
- form.fields[2].is_autofilled = true;
+ form.fields[2].set_autofilled(true);
const FormField& field = form.fields[0];
GetAutoFillSuggestions(form, field);
@@ -1266,7 +1266,7 @@ TEST_F(AutofillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
autofill_manager_->AddProfile(profile);
FormField& field = form.fields[0];
- field.is_autofilled = true;
+ field.set_autofilled(true);
GetAutoFillSuggestions(form, field);
// No suggestions provided, so send an empty vector as the results.
@@ -1477,7 +1477,7 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) {
CreateTestAddressFormData(&form);
for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) {
// Make sure the fields have distinct names.
- form.fields[i].name = form.fields[i].name + ASCIIToUTF16("_");
+ form.fields[i].set_name(form.fields[i].name() + ASCIIToUTF16("_"));
}
std::vector<FormData> forms(1, form);
FormsSeen(forms);
@@ -1496,7 +1496,7 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) {
// The second address section should be empty.
ASSERT_EQ(results.fields.size(), 2*kAddressFormSize);
for (size_t i = kAddressFormSize; i < form.fields.size(); ++i) {
- EXPECT_EQ(string16(), results.fields[i].value);
+ EXPECT_EQ(string16(), results.fields[i].value());
}
// The first address section should be filled with Elvis's data.
@@ -1521,7 +1521,7 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) {
// The first address section should be empty.
ASSERT_EQ(results.fields.size(), 2*kAddressFormSize);
for (size_t i = 0; i < kAddressFormSize; ++i) {
- EXPECT_EQ(string16(), results.fields[i].value);
+ EXPECT_EQ(string16(), results.fields[i].value());
}
// The second address section should be filled with Elvis's data.
@@ -1530,9 +1530,9 @@ TEST_F(AutofillManagerTest, FillFormWithMultipleSections) {
secondSection.fields.begin() + kAddressFormSize);
for (size_t i = 0; i < kAddressFormSize; ++i) {
// Restore the expected field names.
- string16 name = secondSection.fields[i].name;
+ string16 name = secondSection.fields[i].name();
string16 original_name = name.substr(0, name.size() - 1);
- secondSection.fields[i].name = original_name;
+ secondSection.fields[i].set_name(original_name);
}
ExpectFilledAddressFormElvis(page_id, secondSection, kPageID2, false);
}
@@ -1544,7 +1544,7 @@ TEST_F(AutofillManagerTest, FillAutoFilledForm) {
FormData form;
CreateTestAddressFormData(&form);
// Mark one of the address fields as autofilled.
- form.fields[4].is_autofilled = true;
+ form.fields[4].set_autofilled(true);
CreateTestCreditCardFormData(&form, true, false);
std::vector<FormData> forms(1, form);
FormsSeen(forms);
@@ -1584,7 +1584,7 @@ TEST_F(AutofillManagerTest, FillAutoFilledForm) {
for (std::vector<FormField>::iterator iter = form.fields.begin();
iter != form.fields.end();
++iter) {
- iter->is_autofilled = true;
+ iter->set_autofilled(true);
}
const int kPageID3 = 3;
@@ -1615,23 +1615,23 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) {
FormField field;
autofill_test::CreateTestFormField(
"country code", "country code", "", "text", &field);
- field.max_length = 1;
+ field.set_max_length(1);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"area code", "area code", "", "text", &field);
- field.max_length = 3;
+ field.set_max_length(3);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"phone", "phone prefix", "1", "text", &field);
- field.max_length = 3;
+ field.set_max_length(3);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"-", "phone suffix", "", "text", &field);
- field.max_length = 4;
+ field.set_max_length(4);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Phone Extension", "ext", "", "text", &field);
- field.max_length = 3;
+ field.set_max_length(3);
form.fields.push_back(field);
std::vector<FormData> forms(1, form);
@@ -1659,12 +1659,12 @@ TEST_F(AutofillManagerTest, FillPhoneNumber) {
EXPECT_TRUE(GetAutoFillFormDataFilledMessage(&page_id, &results));
if (i != 7) {
- EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[2].value);
- EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[3].value);
+ EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[2].value());
+ EXPECT_EQ(ASCIIToUTF16(test_data), results.fields[3].value());
} else {
// The only size that is parsed and split, right now is 7:
- EXPECT_EQ(ASCIIToUTF16("123"), results.fields[2].value);
- EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value);
+ EXPECT_EQ(ASCIIToUTF16("123"), results.fields[2].value());
+ EXPECT_EQ(ASCIIToUTF16("4567"), results.fields[3].value());
}
}
diff --git a/chrome/browser/autofill/autofill_merge_unittest.cc b/chrome/browser/autofill/autofill_merge_unittest.cc
index b5897f2..0ce01b2 100644
--- a/chrome/browser/autofill/autofill_merge_unittest.cc
+++ b/chrome/browser/autofill/autofill_merge_unittest.cc
@@ -198,7 +198,7 @@ void AutoFillMergeTest::MergeProfiles(const std::string& profiles,
AutofillField* field =
const_cast<AutofillField*>(form_structure.field(i));
AutofillFieldType type =
- AutofillType::StringToFieldType(UTF16ToUTF8(field->name));
+ AutofillType::StringToFieldType(UTF16ToUTF8(field->name()));
field->set_heuristic_type(type);
}
std::vector<const FormStructure*> form_structures(1, &form_structure);
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc
index 44f0db5..ce12e4f 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -225,7 +225,7 @@ TEST_F(AutofillMetricsTest, QualityMetrics) {
FormField field;
autofill_test::CreateTestFormField(
"Autofilled", "autofilled", "Elvis Presley", "text", &field);
- field.is_autofilled = true;
+ field.set_autofilled(true);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
@@ -395,7 +395,7 @@ TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
FormField field;
autofill_test::CreateTestFormField(
"Both match", "match", "Elvis Presley", "text", &field);
- field.is_autofilled = true;
+ field.set_autofilled(true);
form.fields.push_back(field);
heuristic_types.push_back(NAME_FULL);
server_types.push_back(NAME_FULL);
@@ -484,7 +484,7 @@ TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) {
FormField field;
autofill_test::CreateTestFormField(
"Autofilled", "autofilled", "Elvis Presley", "text", &field);
- field.is_autofilled = true;
+ field.set_autofilled(true);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
@@ -520,7 +520,7 @@ TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) {
FormField field;
autofill_test::CreateTestFormField(
"Autofilled", "autofilled", "Elvis Presley", "text", &field);
- field.is_autofilled = true;
+ field.set_autofilled(true);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
diff --git a/chrome/browser/autofill/credit_card_field.cc b/chrome/browser/autofill/credit_card_field.cc
index 79bf1fb..0a0ac43 100644
--- a/chrome/browser/autofill/credit_card_field.cc
+++ b/chrome/browser/autofill/credit_card_field.cc
@@ -118,7 +118,7 @@ CreditCardField* CreditCardField::Parse(
&credit_card_field->number_))
continue;
- if ((*q) && LowerCaseEqualsASCII((*q)->form_control_type, "month")) {
+ if ((*q) && LowerCaseEqualsASCII((*q)->form_control_type(), "month")) {
credit_card_field->expiration_month_ = *q++;
} else {
// "Expiration date" is the most common label here, but some pages have
@@ -187,7 +187,7 @@ CreditCardField* CreditCardField::Parse(
credit_card_field->expiration_month_ &&
(credit_card_field->expiration_year_ ||
(LowerCaseEqualsASCII(
- credit_card_field->expiration_month_->form_control_type,
+ credit_card_field->expiration_month_->form_control_type(),
"month")))) {
*iter = q;
return credit_card_field.release();
diff --git a/chrome/browser/autofill/form_field.cc b/chrome/browser/autofill/form_field.cc
index 1126fad..c34e27d 100644
--- a/chrome/browser/autofill/form_field.cc
+++ b/chrome/browser/autofill/form_field.cc
@@ -124,7 +124,7 @@ bool FormField::MatchName(AutofillField* field, const string16& pattern) {
WebKit::WebRegularExpression re(WebKit::WebString(pattern),
WebKit::WebTextCaseInsensitive);
bool match = re.match(
- WebKit::WebString(StringToLowerASCII(field->name))) != -1;
+ WebKit::WebString(StringToLowerASCII(field->name()))) != -1;
return match;
}
@@ -135,7 +135,7 @@ bool FormField::MatchLabel(AutofillField* field, const string16& pattern) {
WebKit::WebRegularExpression re(WebKit::WebString(pattern),
WebKit::WebTextCaseInsensitive);
bool match = re.match(
- WebKit::WebString(StringToLowerASCII(field->label))) != -1;
+ WebKit::WebString(StringToLowerASCII(field->label()))) != -1;
return match;
}
@@ -350,7 +350,7 @@ bool FormFieldSet::CheckECML(FormStructure* fields) {
const string16 ecom(ASCIIToUTF16("ecom"));
for (size_t index = 0; index < num_fields; ++index) {
- const string16& utf16_name = fields->field(index)->name;
+ const string16& utf16_name = fields->field(index)->name();
if (StartsWith(utf16_name, ecom, true)) {
std::string name(UTF16ToASCII(utf16_name));
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(form_fields); ++i) {
diff --git a/chrome/browser/autofill/form_field_unittest.cc b/chrome/browser/autofill/form_field_unittest.cc
index 9a0e291..ef68eb8 100644
--- a/chrome/browser/autofill/form_field_unittest.cc
+++ b/chrome/browser/autofill/form_field_unittest.cc
@@ -15,68 +15,68 @@ TEST(FormFieldTest, Match) {
EXPECT_TRUE(FormField::Match(&field, string16(), true));
// Empty pattern matches non-empty string.
- field.label = ASCIIToUTF16("a");
+ field.set_label(ASCIIToUTF16("a"));
EXPECT_TRUE(FormField::Match(&field, string16(), true));
// Strictly empty pattern matches empty string.
- field.label = ASCIIToUTF16("");
+ field.set_label(ASCIIToUTF16(""));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"), true));
// Strictly empty pattern does not match non-empty string.
- field.label = ASCIIToUTF16("a");
+ field.set_label(ASCIIToUTF16("a"));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"), true));
// Non-empty pattern doesn't match empty string.
- field.label = string16();
+ field.set_label(string16());
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"), true));
// Beginning of line.
- field.label = ASCIIToUTF16("head_tail");
+ field.set_label(ASCIIToUTF16("head_tail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"), true));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"), true));
// End of line.
- field.label = ASCIIToUTF16("head_tail");
+ field.set_label(ASCIIToUTF16("head_tail"));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head$"), true));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail$"), true));
// Exact.
- field.label = ASCIIToUTF16("head_tail");
+ field.set_label(ASCIIToUTF16("head_tail"));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^head$"), true));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail$"), true));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head_tail$"), true));
// Escaped dots.
- field.label = ASCIIToUTF16("m.i.");
+ field.set_label(ASCIIToUTF16("m.i."));
// Note: This pattern is misleading as the "." characters are wild cards.
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), true));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), true));
- field.label = ASCIIToUTF16("mXiX");
+ field.set_label(ASCIIToUTF16("mXiX"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), true));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), true));
// Repetition.
- field.label = ASCIIToUTF16("headtail");
+ field.set_label(ASCIIToUTF16("headtail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
- field.label = ASCIIToUTF16("headXtail");
+ field.set_label(ASCIIToUTF16("headXtail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
- field.label = ASCIIToUTF16("headXXXtail");
+ field.set_label(ASCIIToUTF16("headXXXtail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true));
- field.label = ASCIIToUTF16("headtail");
+ field.set_label(ASCIIToUTF16("headtail"));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
- field.label = ASCIIToUTF16("headXtail");
+ field.set_label(ASCIIToUTF16("headXtail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
- field.label = ASCIIToUTF16("headXXXtail");
+ field.set_label(ASCIIToUTF16("headXXXtail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true));
// Alternation.
- field.label = ASCIIToUTF16("head_tail");
+ field.set_label(ASCIIToUTF16("head_tail"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head|other"), true));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail|other"), true));
EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("bad|good"), true));
// Case sensitivity.
- field.label = ASCIIToUTF16("xxxHeAd_tAiLxxx");
+ field.set_label(ASCIIToUTF16("xxxHeAd_tAiLxxx"));
EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head_tail"), true));
}
diff --git a/chrome/browser/autofill/form_structure.cc b/chrome/browser/autofill/form_structure.cc
index a6a64dd..cef629d 100644
--- a/chrome/browser/autofill/form_structure.cc
+++ b/chrome/browser/autofill/form_structure.cc
@@ -58,10 +58,10 @@ FormStructure::FormStructure(const FormData& form)
// Add all supported form fields (including with empty names) to the
// signature. This is a requirement for AutoFill servers.
form_signature_field_names_.append("&");
- form_signature_field_names_.append(UTF16ToUTF8(field->name));
+ form_signature_field_names_.append(UTF16ToUTF8(field->name()));
// Generate a unique name for this field by appending a counter to the name.
- string16 unique_name = field->name +
+ string16 unique_name = field->name() +
base::IntToString16(fields_.size() + 1);
fields_.push_back(new AutofillField(*field, unique_name));
}
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 392507a..7962529 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -182,7 +182,7 @@ bool PersonalDataManager::ImportFormData(
const FormStructure* form = *iter;
for (size_t i = 0; i < form->field_count(); ++i) {
const AutofillField* field = form->field(i);
- string16 value = CollapseWhitespace(field->value, false);
+ string16 value = CollapseWhitespace(field->value(), false);
// If we don't know the type of the field, or the user hasn't entered any
// information into the field, then skip it.
@@ -196,7 +196,7 @@ bool PersonalDataManager::ImportFormData(
// If the user has a password set, we have no way of setting credit
// card numbers.
if (!HasPassword()) {
- if (LowerCaseEqualsASCII(field->form_control_type, "month")) {
+ if (LowerCaseEqualsASCII(field->form_control_type(), "month")) {
DCHECK_EQ(CREDIT_CARD_EXP_MONTH, field_type.field_type());
local_imported_credit_card->SetInfoForMonthInputType(value);
} else {
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index 9eca163..a075abc 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -651,15 +651,15 @@ TEST_F(PersonalDataManagerTest, ImportPhoneNumberSplitAcrossMultipleFields) {
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Phone #:", "home_phone_area_code", "650", "text", &field);
- field.max_length = 3;
+ field.set_max_length(3);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Phone #:", "home_phone_prefix", "555", "text", &field);
- field.max_length = 3;
+ field.set_max_length(3);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Phone #:", "home_phone_suffix", "0000", "text", &field);
- field.max_length = 4;
+ field.set_max_length(4);
form.fields.push_back(field);
autofill_test::CreateTestFormField(
"Address:", "address1", "21 Laussat St", "text", &field);
diff --git a/chrome/browser/autofill/phone_field.cc b/chrome/browser/autofill/phone_field.cc
index 8b59203..cd7e493 100644
--- a/chrome/browser/autofill/phone_field.cc
+++ b/chrome/browser/autofill/phone_field.cc
@@ -281,9 +281,9 @@ bool PhoneField::ParseInternal(
&parsed_fields[phone_field_grammars_[i].phone_part]))
break;
if (phone_field_grammars_[i].max_size &&
- (!parsed_fields[phone_field_grammars_[i].phone_part]->max_length ||
+ (!parsed_fields[phone_field_grammars_[i].phone_part]->max_length() ||
phone_field_grammars_[i].max_size <
- parsed_fields[phone_field_grammars_[i].phone_part]->max_length)) {
+ parsed_fields[phone_field_grammars_[i].phone_part]->max_length())) {
break;
}
}
diff --git a/chrome/browser/autofill/select_control_handler.cc b/chrome/browser/autofill/select_control_handler.cc
index b92433a..cf1ed31 100644
--- a/chrome/browser/autofill/select_control_handler.cc
+++ b/chrome/browser/autofill/select_control_handler.cc
@@ -125,10 +125,10 @@ bool SetSelectControlValue(const string16& value,
string16 value_lowercase = StringToLowerASCII(value);
for (std::vector<string16>::const_iterator iter =
- field->option_strings.begin();
- iter != field->option_strings.end(); ++iter) {
+ field->option_strings().begin();
+ iter != field->option_strings().end(); ++iter) {
if (value_lowercase == StringToLowerASCII(*iter)) {
- field->value = *iter;
+ field->set_value(*iter);
return true;
}
}
@@ -165,13 +165,13 @@ bool FillCountrySelectControl(const FormGroup& form_group,
std::string app_locale = AutofillCountry::ApplicationLocale();
for (std::vector<string16>::const_iterator iter =
- field->option_strings.begin();
- iter != field->option_strings.end();
+ field->option_strings().begin();
+ iter != field->option_strings().end();
++iter) {
// Canonicalize each <option> value to a country code, and compare to the
// target country code.
if (country_code == AutofillCountry::GetCountryCode(*iter, app_locale)) {
- field->value = *iter;
+ field->set_value(*iter);
return true;
}
}
@@ -202,30 +202,30 @@ void FillSelectControl(const FormGroup& form_group,
AutofillType type,
webkit_glue::FormField* field) {
DCHECK(field);
- DCHECK_EQ(ASCIIToUTF16("select-one"), field->form_control_type);
+ DCHECK_EQ(ASCIIToUTF16("select-one"), field->form_control_type());
string16 field_text = form_group.GetFieldText(type);
if (field_text.empty())
return;
string16 value;
- for (size_t i = 0; i < field->option_strings.size(); ++i) {
- if (field_text == field->option_strings[i]) {
+ for (size_t i = 0; i < field->option_strings().size(); ++i) {
+ if (field_text == field->option_strings()[i]) {
// An exact match, use it.
value = field_text;
break;
}
- if (StringToLowerASCII(field->option_strings[i]) ==
+ if (StringToLowerASCII(field->option_strings()[i]) ==
StringToLowerASCII(field_text)) {
// A match, but not in the same case. Save it in case an exact match is
// not found.
- value = field->option_strings[i];
+ value = field->option_strings()[i];
}
}
if (!value.empty()) {
- field->value = value;
+ field->set_value(value);
return;
}
diff --git a/chrome/browser/autofill/select_control_handler.h b/chrome/browser/autofill/select_control_handler.h
index f920af8..bb27148 100644
--- a/chrome/browser/autofill/select_control_handler.h
+++ b/chrome/browser/autofill/select_control_handler.h
@@ -11,7 +11,7 @@
class FormGroup;
namespace webkit_glue {
-struct FormField;
+class FormField;
} // namespace webkit_glue
namespace autofill {
diff --git a/chrome/browser/autofill/select_control_handler_unittest.cc b/chrome/browser/autofill/select_control_handler_unittest.cc
index a11859b..c2edd8c 100644
--- a/chrome/browser/autofill/select_control_handler_unittest.cc
+++ b/chrome/browser/autofill/select_control_handler_unittest.cc
@@ -19,15 +19,15 @@ TEST(SelectControlHandlerTest, CreditCardMonthExact) {
options[i] = ASCIIToUTF16(kMonthsNumeric[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
CreditCard credit_card;
credit_card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
autofill::FillSelectControl(credit_card,
AutofillType(CREDIT_CARD_EXP_MONTH),
&field);
- EXPECT_EQ(ASCIIToUTF16("01"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("01"), field.value());
}
TEST(SelectControlHandlerTest, CreditCardMonthAbbreviated) {
@@ -40,15 +40,15 @@ TEST(SelectControlHandlerTest, CreditCardMonthAbbreviated) {
options[i] = ASCIIToUTF16(kMonthsAbbreviated[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
CreditCard credit_card;
credit_card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
autofill::FillSelectControl(credit_card,
AutofillType(CREDIT_CARD_EXP_MONTH),
&field);
- EXPECT_EQ(ASCIIToUTF16("Jan"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("Jan"), field.value());
}
TEST(SelectControlHandlerTest, CreditCardMonthFull) {
@@ -61,15 +61,15 @@ TEST(SelectControlHandlerTest, CreditCardMonthFull) {
options[i] = ASCIIToUTF16(kMonthsFull[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
CreditCard credit_card;
credit_card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
autofill::FillSelectControl(credit_card,
AutofillType(CREDIT_CARD_EXP_MONTH),
&field);
- EXPECT_EQ(ASCIIToUTF16("January"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("January"), field.value());
}
TEST(SelectControlHandlerTest, CreditCardMonthNumeric) {
@@ -81,15 +81,15 @@ TEST(SelectControlHandlerTest, CreditCardMonthNumeric) {
options[i] = ASCIIToUTF16(kMonthsNumeric[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
CreditCard credit_card;
credit_card.SetInfo(AutofillType(CREDIT_CARD_EXP_MONTH), ASCIIToUTF16("01"));
autofill::FillSelectControl(credit_card,
AutofillType(CREDIT_CARD_EXP_MONTH),
&field);
- EXPECT_EQ(ASCIIToUTF16("1"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("1"), field.value());
}
TEST(SelectControlHandlerTest, AddressCountryFull) {
@@ -101,15 +101,15 @@ TEST(SelectControlHandlerTest, AddressCountryFull) {
options[i] = ASCIIToUTF16(kCountries[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
AutoFillProfile profile;
profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("CA"));
autofill::FillSelectControl(profile,
AutofillType(ADDRESS_HOME_COUNTRY),
&field);
- EXPECT_EQ(ASCIIToUTF16("Canada"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("Canada"), field.value());
}
TEST(SelectControlHandlerTest, AddressCountryAbbrev) {
@@ -121,15 +121,15 @@ TEST(SelectControlHandlerTest, AddressCountryAbbrev) {
options[i] = ASCIIToUTF16(kCountries[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
AutoFillProfile profile;
profile.SetInfo(AutofillType(ADDRESS_HOME_COUNTRY), ASCIIToUTF16("Canada"));
autofill::FillSelectControl(profile,
AutofillType(ADDRESS_HOME_COUNTRY),
&field);
- EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("CA"), field.value());
}
TEST(SelectControlHandlerTest, AddressStateFull) {
@@ -141,15 +141,15 @@ TEST(SelectControlHandlerTest, AddressStateFull) {
options[i] = ASCIIToUTF16(kStates[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
AutoFillProfile profile;
profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), ASCIIToUTF16("CA"));
autofill::FillSelectControl(profile,
AutofillType(ADDRESS_HOME_STATE),
&field);
- EXPECT_EQ(ASCIIToUTF16("California"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("California"), field.value());
}
TEST(SelectControlHandlerTest, AddressStateAbbrev) {
@@ -161,13 +161,13 @@ TEST(SelectControlHandlerTest, AddressStateAbbrev) {
options[i] = ASCIIToUTF16(kStates[i]);
webkit_glue::FormField field;
- field.form_control_type = ASCIIToUTF16("select-one");
- field.option_strings = options;
+ field.set_form_control_type(ASCIIToUTF16("select-one"));
+ field.set_option_strings(options);
AutoFillProfile profile;
profile.SetInfo(AutofillType(ADDRESS_HOME_STATE), ASCIIToUTF16("California"));
autofill::FillSelectControl(profile,
AutofillType(ADDRESS_HOME_STATE),
&field);
- EXPECT_EQ(ASCIIToUTF16("CA"), field.value);
+ EXPECT_EQ(ASCIIToUTF16("CA"), field.value());
}
diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc
index 167c830d..5ec1cb0 100644
--- a/chrome/browser/webdata/web_database.cc
+++ b/chrome/browser/webdata/web_database.cc
@@ -1401,10 +1401,10 @@ bool WebDatabase::AddFormFieldValuesTime(const std::vector<FormField>& elements,
itr++) {
if (seen_names.size() >= kMaximumUniqueNames)
break;
- if (seen_names.find(itr->name) != seen_names.end())
+ if (seen_names.find(itr->name()) != seen_names.end())
continue;
result = result && AddFormFieldValueTime(*itr, changes, time);
- seen_names.insert(itr->name);
+ seen_names.insert(itr->name());
}
return result;
}
@@ -1443,8 +1443,8 @@ bool WebDatabase::GetIDAndCountOfFormElement(
return false;
}
- s.BindString16(0, element.name);
- s.BindString16(1, element.value);
+ s.BindString16(0, element.name());
+ s.BindString16(1, element.value());
*pair_id = 0;
*count = 0;
@@ -1622,9 +1622,9 @@ bool WebDatabase::InsertFormElement(const FormField& element,
return false;
}
- s.BindString16(0, element.name);
- s.BindString16(1, element.value);
- s.BindString16(2, l10n_util::ToLower(element.value));
+ s.BindString16(0, element.name());
+ s.BindString16(1, element.value());
+ s.BindString16(2, l10n_util::ToLower(element.value()));
if (!s.Run()) {
NOTREACHED();
@@ -1701,7 +1701,7 @@ bool WebDatabase::AddFormFieldValueTime(const FormField& element,
count == 0 ? AutofillChange::ADD : AutofillChange::UPDATE;
changes->push_back(
AutofillChange(change_type,
- AutofillKey(element.name, element.value)));
+ AutofillKey(element.name(), element.value())));
return true;
}
diff --git a/chrome/browser/webdata/web_database.h b/chrome/browser/webdata/web_database.h
index 6aeca08..7e315bc 100644
--- a/chrome/browser/webdata/web_database.h
+++ b/chrome/browser/webdata/web_database.h
@@ -32,7 +32,7 @@ class Time;
}
namespace webkit_glue {
-struct FormField;
+class FormField;
struct PasswordForm;
}
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index f1a6c1c..d2e6f9d 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -29,6 +29,7 @@
'common/app_mode_common_mac.mm',
'common/auto_start_linux.cc',
'common/auto_start_linux.h',
+ 'common/autofill_messages.cc',
'common/autofill_messages.h',
'common/bindings_policy.h',
'common/child_process_info.cc',
diff --git a/chrome/common/autofill_messages.cc b/chrome/common/autofill_messages.cc
new file mode 100644
index 0000000..1243f1f
--- /dev/null
+++ b/chrome/common/autofill_messages.cc
@@ -0,0 +1,105 @@
+// 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 "chrome/common/common_param_traits.h"
+#include "content/common/common_param_traits.h"
+#include "webkit/glue/form_data.h"
+#include "webkit/glue/form_field.h"
+#include "webkit/glue/password_form.h"
+#include "webkit/glue/password_form_dom_manager.h"
+
+#define IPC_MESSAGE_IMPL
+#include "chrome/common/autofill_messages.h"
+
+namespace IPC {
+
+void ParamTraits<webkit_glue::FormField>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.label());
+ WriteParam(m, p.name());
+ WriteParam(m, p.value());
+ WriteParam(m, p.form_control_type());
+ WriteParam(m, p.max_length());
+ WriteParam(m, p.is_autofilled());
+ WriteParam(m, p.option_strings());
+}
+
+bool ParamTraits<webkit_glue::FormField>::Read(const Message* m, void** iter,
+ param_type* p) {
+ string16 label, name, value, form_control_type;
+ int max_length = 0;
+ bool is_autofilled;
+ std::vector<string16> options;
+ bool result = ReadParam(m, iter, &label);
+ result = result && ReadParam(m, iter, &name);
+ result = result && ReadParam(m, iter, &value);
+ result = result && ReadParam(m, iter, &form_control_type);
+ result = result && ReadParam(m, iter, &max_length);
+ result = result && ReadParam(m, iter, &is_autofilled);
+ result = result && ReadParam(m, iter, &options);
+ if (!result)
+ return false;
+
+ p->set_label(label);
+ p->set_name(name);
+ p->set_value(value);
+ p->set_form_control_type(form_control_type);
+ p->set_max_length(max_length);
+ p->set_autofilled(is_autofilled);
+ p->set_option_strings(options);
+ return true;
+}
+
+void ParamTraits<webkit_glue::FormField>::Log(const param_type& p,
+ std::string* l) {
+ l->append("<FormField>");
+}
+
+void ParamTraits<webkit_glue::FormData>::Write(Message* m,
+ const param_type& p) {
+ WriteParam(m, p.name);
+ WriteParam(m, p.method);
+ WriteParam(m, p.origin);
+ WriteParam(m, p.action);
+ WriteParam(m, p.user_submitted);
+ WriteParam(m, p.fields);
+}
+
+bool ParamTraits<webkit_glue::FormData>::Read(const Message* m, void** iter,
+ param_type* p) {
+ return
+ ReadParam(m, iter, &p->name) &&
+ ReadParam(m, iter, &p->method) &&
+ ReadParam(m, iter, &p->origin) &&
+ ReadParam(m, iter, &p->action) &&
+ ReadParam(m, iter, &p->user_submitted) &&
+ ReadParam(m, iter, &p->fields);
+}
+
+void ParamTraits<webkit_glue::FormData>::Log(const param_type& p,
+ std::string* l) {
+ l->append("<FormData>");
+}
+
+void ParamTraits<webkit_glue::PasswordFormFillData>::Write(
+ Message* m, const param_type& p) {
+ WriteParam(m, p.basic_data);
+ WriteParam(m, p.additional_logins);
+ WriteParam(m, p.wait_for_username);
+}
+
+bool ParamTraits<webkit_glue::PasswordFormFillData>::Read(
+ const Message* m, void** iter, param_type* r) {
+ return
+ ReadParam(m, iter, &r->basic_data) &&
+ ReadParam(m, iter, &r->additional_logins) &&
+ ReadParam(m, iter, &r->wait_for_username);
+}
+
+void ParamTraits<webkit_glue::PasswordFormFillData>::Log(const param_type& p,
+ std::string* l) {
+ l->append("<PasswordFormFillData>");
+}
+
+} // namespace IPC
diff --git a/chrome/common/autofill_messages.h b/chrome/common/autofill_messages.h
index cd86d75..dd1776f 100644
--- a/chrome/common/autofill_messages.h
+++ b/chrome/common/autofill_messages.h
@@ -2,43 +2,52 @@
// 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.
+#ifndef CHROME_COMMON_AUTOFILL_MESSAGES_H_
+#define CHROME_COMMON_AUTOFILL_MESSAGES_H_
+#pragma once
#include <string>
-#include "chrome/common/common_param_traits.h"
#include "ipc/ipc_message_macros.h"
-#include "webkit/glue/form_data.h"
-#include "webkit/glue/form_field.h"
-#include "webkit/glue/password_form.h"
-#include "webkit/glue/password_form_dom_manager.h"
#define IPC_MESSAGE_START AutoFillMsgStart
-IPC_STRUCT_TRAITS_BEGIN(webkit_glue::FormField)
- 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(max_length)
- IPC_STRUCT_TRAITS_MEMBER(is_autofilled)
- IPC_STRUCT_TRAITS_MEMBER(option_strings)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(webkit_glue::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(webkit_glue::PasswordFormFillData)
- IPC_STRUCT_TRAITS_MEMBER(basic_data)
- IPC_STRUCT_TRAITS_MEMBER(additional_logins)
- IPC_STRUCT_TRAITS_MEMBER(wait_for_username)
-IPC_STRUCT_TRAITS_END()
+namespace webkit_glue {
+class FormField;
+struct FormData;
+struct PasswordForm;
+struct PasswordFormFillData;
+}
+
+namespace IPC {
+
+template <>
+struct ParamTraits<webkit_glue::FormField> {
+ typedef webkit_glue::FormField param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+
+// Traits for FormData structure to pack/unpack.
+template <>
+struct ParamTraits<webkit_glue::FormData> {
+ typedef webkit_glue::FormData param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* p);
+ static void Log(const param_type& p, std::string* l);
+};
+
+template <>
+struct ParamTraits<webkit_glue::PasswordFormFillData> {
+ typedef webkit_glue::PasswordFormFillData param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::string* l);
+};
+
+} // namespace IPC
// AutoFill messages sent from the browser to the renderer.
@@ -113,4 +122,4 @@ IPC_MESSAGE_ROUTED2(AutoFillHostMsg_RemoveAutocompleteEntry,
// Instructs the browser to show the AutoFill dialog.
IPC_MESSAGE_ROUTED0(AutoFillHostMsg_ShowAutoFillDialog)
-
+#endif // CHROME_COMMON_AUTOFILL_MESSAGES_H_
diff --git a/chrome/common/common_message_generator.h b/chrome/common/common_message_generator.h
index c8abe08..a59e82e 100644
--- a/chrome/common/common_message_generator.h
+++ b/chrome/common/common_message_generator.h
@@ -4,7 +4,6 @@
// Multiply-included file, hence no include guard.
-#include "chrome/common/autofill_messages.h"
#include "chrome/common/database_messages.h"
#include "chrome/common/file_utilities_messages.h"
#include "chrome/common/indexed_db_messages.h"
@@ -16,6 +15,7 @@
#if 0 // This feature is not yet enabled for these files.
+#include "chrome/common/autofill_messages.h"
#include "chrome/common/automation_messages.h"
#include "chrome/common/devtools_messages.h"
#include "chrome/common/dom_storage_messages.h"
diff --git a/chrome/renderer/autofill/autofill_agent.cc b/chrome/renderer/autofill/autofill_agent.cc
index 2c087a6..da8e2c3 100644
--- a/chrome/renderer/autofill/autofill_agent.cc
+++ b/chrome/renderer/autofill/autofill_agent.cc
@@ -351,7 +351,7 @@ void AutoFillAgent::FillAutoFillFormData(const WebNode& node,
return;
autofill_action_ = action;
- was_query_node_autofilled_ = field.is_autofilled;
+ was_query_node_autofilled_ = field.is_autofilled();
Send(new AutoFillHostMsg_FillAutoFillFormData(
routing_id(), autofill_query_id_, form, field, unique_id));
}
@@ -381,7 +381,7 @@ bool AutoFillAgent::FindFormAndFieldForNode(const WebNode& node,
// label, so find the label here.
// TODO(jhawkins): Add form and field identities so we can use the cached form
// data in FormManager.
- field->label = FormManager::LabelForElement(element);
+ field->set_label(FormManager::LabelForElement(element));
return true;
}
diff --git a/chrome/renderer/autofill/form_autocomplete_browsertest.cc b/chrome/renderer/autofill/form_autocomplete_browsertest.cc
index 15b4c92..1041e76 100644
--- a/chrome/renderer/autofill/form_autocomplete_browsertest.cc
+++ b/chrome/renderer/autofill/form_autocomplete_browsertest.cc
@@ -40,12 +40,12 @@ TEST_F(FormAutocompleteTest, NormalFormSubmit) {
ASSERT_EQ(2U, forms.a.fields.size());
webkit_glue::FormField& form_field = forms.a.fields[0];
- EXPECT_EQ(WebString("fname"), form_field.name);
- EXPECT_EQ(WebString("Rick"), form_field.value);
+ EXPECT_EQ(WebString("fname"), form_field.name());
+ EXPECT_EQ(WebString("Rick"), form_field.value());
form_field = forms.a.fields[1];
- EXPECT_EQ(WebString("lname"), form_field.name);
- EXPECT_EQ(WebString("Deckard"), form_field.value);
+ EXPECT_EQ(WebString("lname"), form_field.name());
+ EXPECT_EQ(WebString("Deckard"), form_field.value());
}
// Tests that submitting a form that has autocomplete="off" does not generate a
@@ -88,8 +88,8 @@ TEST_F(FormAutocompleteTest, AutoCompleteOffInputSubmit) {
ASSERT_EQ(1U, forms.a.fields.size());
webkit_glue::FormField& form_field = forms.a.fields[0];
- EXPECT_EQ(WebString("fname"), form_field.name);
- EXPECT_EQ(WebString("Rick"), form_field.value);
+ EXPECT_EQ(WebString("fname"), form_field.name());
+ EXPECT_EQ(WebString("Rick"), form_field.value());
}
// Tests that submitting a form that has been dynamically set as autocomplete
diff --git a/chrome/renderer/autofill/form_manager.cc b/chrome/renderer/autofill/form_manager.cc
index 889b4cc..5c41eb6 100644
--- a/chrome/renderer/autofill/form_manager.cc
+++ b/chrome/renderer/autofill/form_manager.cc
@@ -334,23 +334,23 @@ void FormManager::WebFormControlElementToFormField(
// The label is not officially part of a WebFormControlElement; however, the
// labels for all form control elements are scraped from the DOM and set in
// WebFormElementToFormData.
- field->name = element.nameForAutofill();
- field->form_control_type = element.formControlType();
+ field->set_name(element.nameForAutofill());
+ field->set_form_control_type(element.formControlType());
if (!IsAutoFillableElement(element))
return;
const WebInputElement* input_element = toWebInputElement(&element);
if (IsTextInput(input_element)) {
- field->max_length = input_element->maxLength();
- field->is_autofilled = input_element->isAutofilled();
+ field->set_max_length(input_element->maxLength());
+ field->set_autofilled(input_element->isAutofilled());
} else if (extract_mask & EXTRACT_OPTIONS) {
// Set option strings on the field if available.
DCHECK(IsSelectElement(element));
const WebSelectElement select_element = element.toConst<WebSelectElement>();
std::vector<string16> option_strings;
GetOptionStringsFromElement(select_element, &option_strings);
- field->option_strings = option_strings;
+ field->set_option_strings(option_strings);
}
if (!(extract_mask & EXTRACT_VALUE))
@@ -387,7 +387,7 @@ void FormManager::WebFormControlElementToFormField(
if (value.size() > kMaxDataLength)
value = value.substr(0, kMaxDataLength);
- field->value = value;
+ field->set_value(value);
}
// static
@@ -468,7 +468,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
// TODO(jhawkins): A label element is mapped to a form control element's id.
// field->name() will contain the id only if the name does not exist. Add
// an id() method to WebFormControlElement and use that here.
- name_map[field->name] = field;
+ name_map[field->name()] = field;
fields_extracted[i] = true;
}
@@ -494,7 +494,7 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
std::map<string16, FormField*>::iterator iter =
name_map.find(field_element.nameForAutofill());
if (iter != name_map.end())
- iter->second->label = FindChildText(label);
+ iter->second->set_label(FindChildText(label));
}
// Loop through the form control elements, extracting the label text from the
@@ -509,8 +509,8 @@ bool FormManager::WebFormElementToFormData(const WebFormElement& element,
continue;
const WebFormControlElement& control_element = control_elements[i];
- if (form_fields[field_idx]->label.empty())
- form_fields[field_idx]->label = InferLabelForElement(control_element);
+ if (form_fields[field_idx]->label().empty())
+ form_fields[field_idx]->set_label(InferLabelForElement(control_element));
++field_idx;
}
@@ -833,13 +833,13 @@ void FormManager::ForEachMatchingFormField(FormElement* form,
// Search forward in the |form| for a corresponding field.
size_t k = j;
- while (k < data.fields.size() && element_name != data.fields[k].name)
+ while (k < data.fields.size() && element_name != data.fields[k].name())
k++;
if (k >= data.fields.size())
continue;
- DCHECK_EQ(data.fields[k].name, element_name);
+ DCHECK_EQ(data.fields[k].name(), element_name);
bool is_initiating_node = false;
@@ -880,7 +880,7 @@ void FormManager::FillFormField(WebFormControlElement* field,
const FormField* data,
bool is_initiating_node) {
// Nothing to fill.
- if (data->value.empty())
+ if (data->value().empty())
return;
WebInputElement* input_element = toWebInputElement(field);
@@ -888,7 +888,7 @@ void FormManager::FillFormField(WebFormControlElement* field,
// If the maxlength attribute contains a negative value, maxLength()
// returns the default maxlength value.
input_element->setValue(
- data->value.substr(0, input_element->maxLength()));
+ data->value().substr(0, input_element->maxLength()));
input_element->setAutofilled(true);
if (is_initiating_node) {
int length = input_element->value().length();
@@ -897,7 +897,7 @@ void FormManager::FillFormField(WebFormControlElement* field,
} else {
DCHECK(IsSelectElement(*field));
WebSelectElement select_element = field->to<WebSelectElement>();
- select_element.setValue(data->value);
+ select_element.setValue(data->value());
}
}
@@ -905,7 +905,7 @@ void FormManager::PreviewFormField(WebFormControlElement* field,
const FormField* data,
bool is_initiating_node) {
// Nothing to preview.
- if (data->value.empty())
+ if (data->value().empty())
return;
// Only preview input fields.
@@ -916,7 +916,7 @@ void FormManager::PreviewFormField(WebFormControlElement* field,
// If the maxlength attribute contains a negative value, maxLength()
// returns the default maxlength value.
input_element->setSuggestedValue(
- data->value.substr(0, input_element->maxLength()));
+ data->value().substr(0, input_element->maxLength()));
input_element->setAutofilled(true);
if (is_initiating_node) {
// Select the part of the text that the user didn't type.
diff --git a/chrome/renderer/autofill/form_manager.h b/chrome/renderer/autofill/form_manager.h
index 0558bbb..18110c3 100644
--- a/chrome/renderer/autofill/form_manager.h
+++ b/chrome/renderer/autofill/form_manager.h
@@ -16,7 +16,7 @@
namespace webkit_glue {
struct FormData;
-struct FormField;
+class FormField;
} // namespace webkit_glue
namespace WebKit {
diff --git a/chrome/renderer/autofill/form_manager_browsertest.cc b/chrome/renderer/autofill/form_manager_browsertest.cc
index d8e18ba..a89b6ba 100644
--- a/chrome/renderer/autofill/form_manager_browsertest.cc
+++ b/chrome/renderer/autofill/form_manager_browsertest.cc
@@ -249,9 +249,9 @@ TEST_F(FormManagerTest, WebFormControlElementToFormFieldSelect) {
ASCIIToUTF16("select-one"),
0,
false)));
- ASSERT_EQ(2U, result3.option_strings.size());
- EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings[0]);
- EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings[1]);
+ ASSERT_EQ(2U, result3.option_strings().size());
+ EXPECT_EQ(ASCIIToUTF16("CA"), result3.option_strings()[0]);
+ EXPECT_EQ(ASCIIToUTF16("TX"), result3.option_strings()[1]);
}
// We should be not extract the value for non-text and non-select fields.
@@ -793,11 +793,11 @@ TEST_F(FormManagerTest, FillForm) {
fields[4]);
// Fill the form.
- form.fields[0].value = ASCIIToUTF16("Wyatt");
- form.fields[1].value = ASCIIToUTF16("Earp");
- form.fields[2].value = ASCIIToUTF16("Alpha");
- form.fields[3].value = ASCIIToUTF16("Beta");
- form.fields[4].value = ASCIIToUTF16("Gamma");
+ form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
+ form.fields[1].set_value(ASCIIToUTF16("Earp"));
+ form.fields[2].set_value(ASCIIToUTF16("Alpha"));
+ form.fields[3].set_value(ASCIIToUTF16("Beta"));
+ form.fields[4].set_value(ASCIIToUTF16("Gamma"));
EXPECT_TRUE(form_manager.FillForm(form, input_element));
// Verify the filled elements.
@@ -905,11 +905,11 @@ TEST_F(FormManagerTest, PreviewForm) {
fields[4]);
// Preview the form.
- form.fields[0].value = ASCIIToUTF16("Wyatt");
- form.fields[1].value = ASCIIToUTF16("Earp");
- form.fields[2].value = ASCIIToUTF16("Alpha");
- form.fields[3].value = ASCIIToUTF16("Beta");
- form.fields[4].value = ASCIIToUTF16("Gamma");
+ form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
+ form.fields[1].set_value(ASCIIToUTF16("Earp"));
+ form.fields[2].set_value(ASCIIToUTF16("Alpha"));
+ form.fields[3].set_value(ASCIIToUTF16("Beta"));
+ form.fields[4].set_value(ASCIIToUTF16("Gamma"));
EXPECT_TRUE(form_manager.PreviewForm(form, input_element));
// Verify the previewed elements.
@@ -1484,9 +1484,9 @@ TEST_F(FormManagerTest, FillFormMaxLength) {
fields[2]);
// Fill the form.
- form.fields[0].value = ASCIIToUTF16("Brother");
- form.fields[1].value = ASCIIToUTF16("Jonathan");
- form.fields[2].value = ASCIIToUTF16("brotherj@example.com");
+ form.fields[0].set_value(ASCIIToUTF16("Brother"));
+ form.fields[1].set_value(ASCIIToUTF16("Jonathan"));
+ form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com"));
EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
// Find the newly-filled form that contains the input element.
@@ -1578,9 +1578,9 @@ TEST_F(FormManagerTest, FillFormNegativeMaxLength) {
fields[2]);
// Fill the form.
- form.fields[0].value = ASCIIToUTF16("Brother");
- form.fields[1].value = ASCIIToUTF16("Jonathan");
- form.fields[2].value = ASCIIToUTF16("brotherj@example.com");
+ form.fields[0].set_value(ASCIIToUTF16("Brother"));
+ form.fields[1].set_value(ASCIIToUTF16("Jonathan"));
+ form.fields[2].set_value(ASCIIToUTF16("brotherj@example.com"));
EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
// Find the newly-filled form that contains the input element.
@@ -1681,13 +1681,13 @@ TEST_F(FormManagerTest, FillFormMoreFormDataFields) {
form->fields.insert(form->fields.begin() + 6, field4);
// Fill the form.
- form->fields[0].value = ASCIIToUTF16("Alpha");
- form->fields[1].value = ASCIIToUTF16("Brother");
- form->fields[2].value = ASCIIToUTF16("Abracadabra");
- form->fields[3].value = ASCIIToUTF16("Joseph");
- form->fields[4].value = ASCIIToUTF16("Beta");
- form->fields[5].value = ASCIIToUTF16("Jonathan");
- form->fields[6].value = ASCIIToUTF16("Omega");
+ form->fields[0].set_value(ASCIIToUTF16("Alpha"));
+ form->fields[1].set_value(ASCIIToUTF16("Brother"));
+ form->fields[2].set_value(ASCIIToUTF16("Abracadabra"));
+ form->fields[3].set_value(ASCIIToUTF16("Joseph"));
+ form->fields[4].set_value(ASCIIToUTF16("Beta"));
+ form->fields[5].set_value(ASCIIToUTF16("Jonathan"));
+ form->fields[6].set_value(ASCIIToUTF16("Omega"));
EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
// Get the input element we want to find.
@@ -1764,9 +1764,9 @@ TEST_F(FormManagerTest, FillFormFewerFormDataFields) {
form->fields.erase(form->fields.begin() + 3);
// Fill the form.
- form->fields[0].value = ASCIIToUTF16("Brother");
- form->fields[1].value = ASCIIToUTF16("Joseph");
- form->fields[2].value = ASCIIToUTF16("Jonathan");
+ form->fields[0].set_value(ASCIIToUTF16("Brother"));
+ form->fields[1].set_value(ASCIIToUTF16("Joseph"));
+ form->fields[2].set_value(ASCIIToUTF16("Jonathan"));
EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
// Get the input element we want to find.
@@ -1863,13 +1863,13 @@ TEST_F(FormManagerTest, FillFormChangedFormDataFields) {
FormData* form = &forms[0];
// Fill the form.
- form->fields[0].value = ASCIIToUTF16("Brother");
- form->fields[1].value = ASCIIToUTF16("Joseph");
- form->fields[2].value = ASCIIToUTF16("Jonathan");
+ form->fields[0].set_value(ASCIIToUTF16("Brother"));
+ form->fields[1].set_value(ASCIIToUTF16("Joseph"));
+ form->fields[2].set_value(ASCIIToUTF16("Jonathan"));
// Alter the label and name used for matching.
- form->fields[1].label = ASCIIToUTF16("bogus");
- form->fields[1].name = ASCIIToUTF16("bogus");
+ form->fields[1].set_label(ASCIIToUTF16("bogus"));
+ form->fields[1].set_name(ASCIIToUTF16("bogus"));
EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
@@ -1938,9 +1938,9 @@ TEST_F(FormManagerTest, FillFormExtraFieldInCache) {
form->fields.pop_back();
// Fill the form.
- form->fields[0].value = ASCIIToUTF16("Brother");
- form->fields[1].value = ASCIIToUTF16("Joseph");
- form->fields[2].value = ASCIIToUTF16("Jonathan");
+ form->fields[0].set_value(ASCIIToUTF16("Brother"));
+ form->fields[1].set_value(ASCIIToUTF16("Joseph"));
+ form->fields[2].set_value(ASCIIToUTF16("Jonathan"));
EXPECT_TRUE(form_manager.FillForm(*form, WebNode()));
// Get the input element we want to find.
@@ -2043,9 +2043,9 @@ TEST_F(FormManagerTest, FillFormEmptyName) {
fields[2]);
// Fill the form.
- form.fields[0].value = ASCIIToUTF16("Wyatt");
- form.fields[1].value = ASCIIToUTF16("Earp");
- form.fields[2].value = ASCIIToUTF16("wyatt@example.com");
+ form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
+ form.fields[1].set_value(ASCIIToUTF16("Earp"));
+ form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com"));
EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
// Find the newly-filled form that contains the input element.
@@ -2143,9 +2143,9 @@ TEST_F(FormManagerTest, FillFormEmptyFormNames) {
fields[2]);
// Fill the form.
- form.fields[0].value = ASCIIToUTF16("Red");
- form.fields[1].value = ASCIIToUTF16("Yellow");
- form.fields[2].value = ASCIIToUTF16("Also Yellow");
+ form.fields[0].set_value(ASCIIToUTF16("Red"));
+ form.fields[1].set_value(ASCIIToUTF16("Yellow"));
+ form.fields[2].set_value(ASCIIToUTF16("Also Yellow"));
EXPECT_TRUE(form_manager.FillForm(form, WebNode()));
// Find the newly-filled form that contains the input element.
@@ -2386,9 +2386,9 @@ TEST_F(FormManagerTest, FillFormNonEmptyField) {
fields[2]);
// Preview the form and verify that the cursor position has been updated.
- form.fields[0].value = ASCIIToUTF16("Wyatt");
- form.fields[1].value = ASCIIToUTF16("Earp");
- form.fields[2].value = ASCIIToUTF16("wyatt@example.com");
+ form.fields[0].set_value(ASCIIToUTF16("Wyatt"));
+ form.fields[1].set_value(ASCIIToUTF16("Earp"));
+ form.fields[2].set_value(ASCIIToUTF16("wyatt@example.com"));
EXPECT_TRUE(form_manager.PreviewForm(form, input_element));
EXPECT_EQ(2, input_element.selectionStart());
EXPECT_EQ(5, input_element.selectionEnd());
diff --git a/chrome/renderer/autofill/password_autofill_manager.cc b/chrome/renderer/autofill/password_autofill_manager.cc
index a7e03fb..7b397fb 100644
--- a/chrome/renderer/autofill/password_autofill_manager.cc
+++ b/chrome/renderer/autofill/password_autofill_manager.cc
@@ -52,7 +52,7 @@ static bool FindFormInputElements(WebKit::WebFormElement* fe,
// form; it can't be the right one.
for (size_t j = 0; j < data.fields.size(); j++) {
WebKit::WebVector<WebKit::WebNode> temp_elements;
- fe->getNamedElements(data.fields[j].name, temp_elements);
+ fe->getNamedElements(data.fields[j].name(), temp_elements);
// Match the first input element, if any.
// |getNamedElements| may return non-input elements where the names match,
@@ -73,7 +73,7 @@ static bool FindFormInputElements(WebKit::WebFormElement* fe,
// one suffices and if some function needs to deal with multiple
// matching elements it can get at them through the FormElement*.
// Note: This assignment adds a reference to the InputElement.
- result->input_elements[data.fields[j].name] =
+ result->input_elements[data.fields[j].name()] =
temp_elements[i].to<WebKit::WebInputElement>();
found_input = true;
}
@@ -143,7 +143,7 @@ bool FillForm(FormElements* fe, const webkit_glue::FormData& data) {
std::map<string16, string16> data_map;
for (size_t i = 0; i < data.fields.size(); i++)
- data_map[data.fields[i].name] = data.fields[i].value;
+ data_map[data.fields[i].name()] = data.fields[i].value();
for (FormInputElementMap::iterator it = fe->input_elements.begin();
it != fe->input_elements.end(); ++it) {
@@ -409,12 +409,12 @@ void PasswordAutofillManager::OnFillPasswordForm(
// Attach autocomplete listener to enable selecting alternate logins.
// First, get pointers to username element.
WebKit::WebInputElement username_element =
- form_elements->input_elements[form_data.basic_data.fields[0].name];
+ form_elements->input_elements[form_data.basic_data.fields[0].name()];
// Get pointer to password element. (We currently only support single
// password forms).
WebKit::WebInputElement password_element =
- form_elements->input_elements[form_data.basic_data.fields[1].name];
+ form_elements->input_elements[form_data.basic_data.fields[1].name()];
DCHECK(login_to_password_info_.find(username_element) ==
login_to_password_info_.end());
@@ -432,8 +432,8 @@ void PasswordAutofillManager::GetSuggestions(
const webkit_glue::PasswordFormFillData& fill_data,
const string16& input,
std::vector<string16>* suggestions) {
- if (StartsWith(fill_data.basic_data.fields[0].value, input, false))
- suggestions->push_back(fill_data.basic_data.fields[0].value);
+ if (StartsWith(fill_data.basic_data.fields[0].value(), input, false))
+ suggestions->push_back(fill_data.basic_data.fields[0].value());
webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter;
for (iter = fill_data.additional_logins.begin();
@@ -477,10 +477,10 @@ bool PasswordAutofillManager::FillUserNameAndPassword(
string16 password;
// Look for any suitable matches to current field text.
- if (DoUsernamesMatch(fill_data.basic_data.fields[0].value, current_username,
+ if (DoUsernamesMatch(fill_data.basic_data.fields[0].value(), current_username,
exact_username_match)) {
- username = fill_data.basic_data.fields[0].value;
- password = fill_data.basic_data.fields[1].value;
+ username = fill_data.basic_data.fields[0].value();
+ password = fill_data.basic_data.fields[1].value();
} else {
// Scan additional logins for a match.
webkit_glue::PasswordFormFillData::LoginCollection::const_iterator iter;
diff --git a/content/browser/renderer_host/render_view_host_delegate.h b/content/browser/renderer_host/render_view_host_delegate.h
index 888fecf..e4c5f46 100644
--- a/content/browser/renderer_host/render_view_host_delegate.h
+++ b/content/browser/renderer_host/render_view_host_delegate.h
@@ -76,7 +76,7 @@ class CookieOptions;
namespace webkit_glue {
struct FormData;
-struct FormField;
+class FormField;
struct PasswordForm;
}
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc
index 0de8446..82cac6a 100644
--- a/webkit/glue/form_field.cc
+++ b/webkit/glue/form_field.cc
@@ -20,41 +20,41 @@ using WebKit::WebVector;
namespace webkit_glue {
FormField::FormField()
- : max_length(0),
- is_autofilled(false) {
+ : max_length_(0),
+ is_autofilled_(false) {
}
// TODO(jhawkins): This constructor should probably be deprecated and the
// functionality moved to FormManager.
FormField::FormField(WebFormControlElement element)
- : max_length(0),
- is_autofilled(false) {
- name = element.nameForAutofill();
+ : max_length_(0),
+ is_autofilled_(false) {
+ name_ = element.nameForAutofill();
// TODO(jhawkins): Extract the field label. For now we just use the field
// name.
- label = name;
+ label_ = name_;
- form_control_type = element.formControlType();
- if (form_control_type == ASCIIToUTF16("text")) {
+ form_control_type_ = element.formControlType();
+ if (form_control_type_ == ASCIIToUTF16("text")) {
const WebInputElement& input_element = element.toConst<WebInputElement>();
- value = input_element.value();
- max_length = input_element.size();
- is_autofilled = input_element.isAutofilled();
- } else if (form_control_type == ASCIIToUTF16("select-one")) {
+ value_ = input_element.value();
+ max_length_ = input_element.size();
+ is_autofilled_ = input_element.isAutofilled();
+ } else if (form_control_type_ == ASCIIToUTF16("select-one")) {
WebSelectElement select_element = element.to<WebSelectElement>();
- value = select_element.value();
+ value_ = select_element.value();
// For select-one elements copy option strings.
WebVector<WebElement> list_items = select_element.listItems();
- option_strings.reserve(list_items.size());
+ option_strings_.reserve(list_items.size());
for (size_t i = 0; i < list_items.size(); ++i) {
if (list_items[i].hasTagName("option"))
- option_strings.push_back(list_items[i].to<WebOptionElement>().value());
+ option_strings_.push_back(list_items[i].to<WebOptionElement>().value());
}
}
- TrimWhitespace(value, TRIM_LEADING, &value);
+ TrimWhitespace(value_, TRIM_LEADING, &value_);
}
FormField::FormField(const string16& label,
@@ -63,12 +63,12 @@ FormField::FormField(const string16& label,
const string16& form_control_type,
int max_length,
bool is_autofilled)
- : label(label),
- name(name),
- value(value),
- form_control_type(form_control_type),
- max_length(max_length),
- is_autofilled(is_autofilled) {
+ : label_(label),
+ name_(name),
+ value_(value),
+ form_control_type_(form_control_type),
+ max_length_(max_length),
+ is_autofilled_(is_autofilled) {
}
FormField::~FormField() {
@@ -77,10 +77,10 @@ FormField::~FormField() {
bool FormField::operator==(const FormField& field) const {
// A FormField 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 &&
- max_length == field.max_length);
+ return (label_ == field.label_ &&
+ name_ == field.name_ &&
+ form_control_type_ == field.form_control_type_ &&
+ max_length_ == field.max_length_);
}
bool FormField::operator!=(const FormField& field) const {
@@ -88,24 +88,24 @@ bool FormField::operator!=(const FormField& field) const {
}
bool FormField::StrictlyEqualsHack(const FormField& field) const {
- return (label == field.label &&
- name == field.name &&
- value == field.value &&
- form_control_type == field.form_control_type &&
- max_length == field.max_length);
+ return (label_ == field.label_ &&
+ name_ == field.name_ &&
+ value_ == field.value_ &&
+ form_control_type_ == field.form_control_type_ &&
+ max_length_ == field.max_length_);
}
std::ostream& operator<<(std::ostream& os, const FormField& field) {
return os
- << UTF16ToUTF8(field.label)
+ << UTF16ToUTF8(field.label())
<< " "
- << UTF16ToUTF8(field.name)
+ << UTF16ToUTF8(field.name())
<< " "
- << UTF16ToUTF8(field.value)
+ << UTF16ToUTF8(field.value())
<< " "
- << UTF16ToUTF8(field.form_control_type)
+ << UTF16ToUTF8(field.form_control_type())
<< " "
- << field.max_length;
+ << field.max_length();
}
} // namespace webkit_glue
diff --git a/webkit/glue/form_field.h b/webkit/glue/form_field.h
index c246091..1874c44 100644
--- a/webkit/glue/form_field.h
+++ b/webkit/glue/form_field.h
@@ -13,7 +13,8 @@
namespace webkit_glue {
// Stores information about a field in a form.
-struct FormField {
+class FormField {
+ public:
FormField();
explicit FormField(WebKit::WebFormControlElement element);
FormField(const string16& label,
@@ -24,6 +25,31 @@ struct FormField {
bool is_autofilled);
virtual ~FormField();
+ const string16& label() const { return label_; }
+ const string16& name() const { return name_; }
+ const string16& value() const { return value_; }
+ const string16& form_control_type() const { return form_control_type_; }
+ int max_length() const { return max_length_; }
+ bool is_autofilled() const { return is_autofilled_; }
+
+ // Returns option string for elements for which they make sense (select-one,
+ // for example) for the rest of elements return an empty array.
+ const std::vector<string16>& option_strings() const {
+ return option_strings_;
+ }
+
+ void set_label(const string16& label) { label_ = label; }
+ void set_name(const string16& name) { name_ = name; }
+ void set_value(const string16& value) { value_ = value; }
+ void set_form_control_type(const string16& form_control_type) {
+ form_control_type_ = form_control_type;
+ }
+ void set_max_length(int max_length) { max_length_ = max_length; }
+ void set_autofilled(bool is_autofilled) { is_autofilled_ = is_autofilled; }
+ void set_option_strings(const std::vector<string16>& strings) {
+ option_strings_ = strings;
+ }
+
// Equality tests for identity which does not include |value_| or |size_|.
// Use |StrictlyEqualsHack| method to test all members.
// TODO(dhollowa): These operators need to be revised when we implement field
@@ -35,13 +61,14 @@ struct FormField {
// TODO(dhollowa): This will be removed when we implement field ids.
bool StrictlyEqualsHack(const FormField& field) const;
- string16 label;
- string16 name;
- string16 value;
- string16 form_control_type;
- int max_length;
- bool is_autofilled;
- std::vector<string16> option_strings;
+ private:
+ string16 label_;
+ string16 name_;
+ string16 value_;
+ string16 form_control_type_;
+ int max_length_;
+ bool is_autofilled_;
+ std::vector<string16> option_strings_;
};
// So we can compare FormFields with EXPECT_EQ().
diff --git a/webkit/glue/webpasswordautocompletelistener_impl.cc b/webkit/glue/webpasswordautocompletelistener_impl.cc
index f584532..20ecf60 100644
--- a/webkit/glue/webpasswordautocompletelistener_impl.cc
+++ b/webkit/glue/webpasswordautocompletelistener_impl.cc
@@ -110,10 +110,10 @@ void WebPasswordAutocompleteListenerImpl::didBlurInputElement(
string16 user_input16 = user_input;
// If enabled, set the password field to match the current username.
- if (data_.basic_data.fields[0].value == user_input16) {
- if (password_delegate_->IsValidValue(data_.basic_data.fields[1].value)) {
+ if (data_.basic_data.fields[0].value() == user_input16) {
+ if (password_delegate_->IsValidValue(data_.basic_data.fields[1].value())) {
// Preferred username/login is selected.
- password_delegate_->SetValue(data_.basic_data.fields[1].value);
+ password_delegate_->SetValue(data_.basic_data.fields[1].value());
password_delegate_->SetAutofilled(true);
}
} else if (data_.additional_logins.find(user_input16) !=
@@ -160,8 +160,8 @@ void WebPasswordAutocompleteListenerImpl::performInlineAutocomplete(
// to simplify lookup and save string conversions (see SetValue) on each
// successful call to OnInlineAutocompleteNeeded.
if (TryToMatch(user_input16,
- data_.basic_data.fields[0].value,
- data_.basic_data.fields[1].value)) {
+ data_.basic_data.fields[0].value(),
+ data_.basic_data.fields[1].value())) {
return;
}
@@ -209,8 +209,8 @@ bool WebPasswordAutocompleteListenerImpl::TryToMatch(const string16& input,
void WebPasswordAutocompleteListenerImpl::GetSuggestions(
const string16& input, std::vector<string16>* suggestions) {
- if (StartsWith(data_.basic_data.fields[0].value, input, false))
- suggestions->push_back(data_.basic_data.fields[0].value);
+ if (StartsWith(data_.basic_data.fields[0].value(), input, false))
+ suggestions->push_back(data_.basic_data.fields[0].value());
for (PasswordFormFillData::LoginCollection::iterator it =
data_.additional_logins.begin();