diff options
author | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 18:46:04 +0000 |
---|---|---|
committer | tsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-08 18:46:04 +0000 |
commit | e2aaa812cbc54389409ca9363d11497d49f69f2f (patch) | |
tree | 6fd3282047ade50bd02a37a5b6b35f645ead739e /chrome/browser | |
parent | f353bede76468b89fc69f3b823e567e6da87d3f7 (diff) | |
download | chromium_src-e2aaa812cbc54389409ca9363d11497d49f69f2f.zip chromium_src-e2aaa812cbc54389409ca9363d11497d49f69f2f.tar.gz chromium_src-e2aaa812cbc54389409ca9363d11497d49f69f2f.tar.bz2 |
Make FormField be a struct rather than a class per c++ standards.
This makes automatic generation of IPC messages much easier.
Convert autofill messsage to automatic generation in the process.
Attempt #2: fix build on chromeos, see http://codereview.chromium.org/6633001
for original CL.
Review URL: http://codereview.chromium.org/6625087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77307 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
23 files changed, 141 insertions, 141 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc index e93bd8c..bbc3387 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 06fb859..5d4d0cc 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 0a1dcfc..72f0a14 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 { -class FormField; +struct 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 1127031..ce5fc83 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 7723551..697e86c 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.set_value(ASCIIToUTF16("Value")); + field.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.set_name(ASCIIToUTF16("Name")); + field.name = ASCIIToUTF16("Name"); EXPECT_EQ("1606968241", field.FieldSignature()); // Field form control type is set. - field.set_form_control_type(ASCIIToUTF16("Text")); + field.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 8d46c84..b7752fb 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->set_value(year + ASCIIToUTF16("-") + month); + field->value = year + ASCIIToUTF16("-") + month; } } else { - field->set_value(credit_card->GetFieldText(type)); + field->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->set_value(profile->GetFieldText(type)); + field->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->set_value(number); + field->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->set_value(number); + field->value = number; } else { - field->set_value(number); + field->value = number; } } diff --git a/chrome/browser/autofill/autofill_manager.h b/chrome/browser/autofill/autofill_manager.h index c9697c3..c2d93d7 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; -class FormField; +struct 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 422f676..e3d912b 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].set_autofilled(true); + form.fields[2].is_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.set_autofilled(true); + field.is_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].set_name(form.fields[i].name() + ASCIIToUTF16("_")); + form.fields[i].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].set_name(original_name); + secondSection.fields[i].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].set_autofilled(true); + form.fields[4].is_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->set_autofilled(true); + iter->is_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.set_max_length(1); + field.max_length = 1; form.fields.push_back(field); autofill_test::CreateTestFormField( "area code", "area code", "", "text", &field); - field.set_max_length(3); + field.max_length = 3; form.fields.push_back(field); autofill_test::CreateTestFormField( "phone", "phone prefix", "1", "text", &field); - field.set_max_length(3); + field.max_length = 3; form.fields.push_back(field); autofill_test::CreateTestFormField( "-", "phone suffix", "", "text", &field); - field.set_max_length(4); + field.max_length = 4; form.fields.push_back(field); autofill_test::CreateTestFormField( "Phone Extension", "ext", "", "text", &field); - field.set_max_length(3); + field.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 0ce01b2..b5897f2 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 ce12e4f..44f0db5 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.set_autofilled(true); + field.is_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.set_autofilled(true); + field.is_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.set_autofilled(true); + field.is_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.set_autofilled(true); + field.is_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 0a0ac43..79bf1fb 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 c34e27d..1126fad 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 ef68eb8..9a0e291 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.set_label(ASCIIToUTF16("a")); + field.label = ASCIIToUTF16("a"); EXPECT_TRUE(FormField::Match(&field, string16(), true)); // Strictly empty pattern matches empty string. - field.set_label(ASCIIToUTF16("")); + field.label = ASCIIToUTF16(""); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^$"), true)); // Strictly empty pattern does not match non-empty string. - field.set_label(ASCIIToUTF16("a")); + field.label = ASCIIToUTF16("a"); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^$"), true)); // Non-empty pattern doesn't match empty string. - field.set_label(string16()); + field.label = string16(); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("a"), true)); // Beginning of line. - field.set_label(ASCIIToUTF16("head_tail")); + field.label = ASCIIToUTF16("head_tail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("^head"), true)); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("^tail"), true)); // End of line. - field.set_label(ASCIIToUTF16("head_tail")); + field.label = ASCIIToUTF16("head_tail"); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head$"), true)); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("tail$"), true)); // Exact. - field.set_label(ASCIIToUTF16("head_tail")); + field.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.set_label(ASCIIToUTF16("m.i.")); + field.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.set_label(ASCIIToUTF16("mXiX")); + field.label = ASCIIToUTF16("mXiX"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("m.i."), true)); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("m\\.i\\."), true)); // Repetition. - field.set_label(ASCIIToUTF16("headtail")); + field.label = ASCIIToUTF16("headtail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true)); - field.set_label(ASCIIToUTF16("headXtail")); + field.label = ASCIIToUTF16("headXtail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true)); - field.set_label(ASCIIToUTF16("headXXXtail")); + field.label = ASCIIToUTF16("headXXXtail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.*tail"), true)); - field.set_label(ASCIIToUTF16("headtail")); + field.label = ASCIIToUTF16("headtail"); EXPECT_FALSE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true)); - field.set_label(ASCIIToUTF16("headXtail")); + field.label = ASCIIToUTF16("headXtail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true)); - field.set_label(ASCIIToUTF16("headXXXtail")); + field.label = ASCIIToUTF16("headXXXtail"); EXPECT_TRUE(FormField::Match(&field, ASCIIToUTF16("head.+tail"), true)); // Alternation. - field.set_label(ASCIIToUTF16("head_tail")); + field.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.set_label(ASCIIToUTF16("xxxHeAd_tAiLxxx")); + field.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 cef629d..a6a64dd 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 7962529..392507a 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 a075abc..9eca163 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.set_max_length(3); + field.max_length = 3; form.fields.push_back(field); autofill_test::CreateTestFormField( "Phone #:", "home_phone_prefix", "555", "text", &field); - field.set_max_length(3); + field.max_length = 3; form.fields.push_back(field); autofill_test::CreateTestFormField( "Phone #:", "home_phone_suffix", "0000", "text", &field); - field.set_max_length(4); + field.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 cd7e493..8b59203 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 cf1ed31..b92433a 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->set_value(*iter); + field->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->set_value(*iter); + field->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->set_value(value); + field->value = value; return; } diff --git a/chrome/browser/autofill/select_control_handler.h b/chrome/browser/autofill/select_control_handler.h index bb27148..f920af8 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 { -class FormField; +struct 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 c2edd8c..a11859b 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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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.set_form_control_type(ASCIIToUTF16("select-one")); - field.set_option_strings(options); + field.form_control_type = ASCIIToUTF16("select-one"); + field.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/chromeos/login/account_creation_view.cc b/chrome/browser/chromeos/login/account_creation_view.cc index d9d5124..1f0a3a6 100644 --- a/chrome/browser/chromeos/login/account_creation_view.cc +++ b/chrome/browser/chromeos/login/account_creation_view.cc @@ -51,11 +51,11 @@ class AccountCreationTabContents : public WizardWebPageViewTabContents { std::string user_name; std::string domain; for (size_t i = 0; i < form.fields.size(); i++) { - std::string name = UTF16ToASCII(form.fields[i].name()); + std::string name = UTF16ToASCII(form.fields[i].name); if (name == kEmailFieldName) { - user_name = UTF16ToASCII(form.fields[i].value()); + user_name = UTF16ToASCII(form.fields[i].value); } else if (name == kDomainFieldName) { - domain = UTF16ToASCII(form.fields[i].value()); + domain = UTF16ToASCII(form.fields[i].value); } } if (!user_name.empty()) { diff --git a/chrome/browser/webdata/web_database.cc b/chrome/browser/webdata/web_database.cc index 5ec1cb0..167c830d 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 7e315bc..6aeca08 100644 --- a/chrome/browser/webdata/web_database.h +++ b/chrome/browser/webdata/web_database.h @@ -32,7 +32,7 @@ class Time; } namespace webkit_glue { -class FormField; +struct FormField; struct PasswordForm; } |