summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-27 21:09:46 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-27 21:09:46 +0000
commitf2d7d646f95a01bac784758e7f7f483e4c04b6c1 (patch)
treec9b415985262be761cd59d2758f82941728066ee /components
parent0b477f60f07224c4bafcf959ac66c7c22c86bfc5 (diff)
downloadchromium_src-f2d7d646f95a01bac784758e7f7f483e4c04b6c1.zip
chromium_src-f2d7d646f95a01bac784758e7f7f483e4c04b6c1.tar.gz
chromium_src-f2d7d646f95a01bac784758e7f7f483e4c04b6c1.tar.bz2
Android: adds end-to-end test for Autofill logger.
BUG=b/13118743 TEST=build/android/test_runner.py instrumentation --test-apk ChromiumTestShellTest --test-filter="AutofillPopupTest*" Review URL: https://codereview.chromium.org/178013005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/autofill/core/browser/autofill_field.cc42
-rw-r--r--components/autofill/core/browser/autofill_field.h4
-rw-r--r--components/autofill/core/browser/autofill_manager.cc34
3 files changed, 44 insertions, 36 deletions
diff --git a/components/autofill/core/browser/autofill_field.cc b/components/autofill/core/browser/autofill_field.cc
index a548c25..ffd6145 100644
--- a/components/autofill/core/browser/autofill_field.cc
+++ b/components/autofill/core/browser/autofill_field.cc
@@ -224,7 +224,7 @@ void FillPhoneNumberField(const AutofillField& field,
// Fills in the select control |field| with |value|. If an exact match is not
// found, falls back to alternate filling strategies based on the |type|.
-void FillSelectControl(const AutofillType& type,
+bool FillSelectControl(const AutofillType& type,
const base::string16& value,
const std::string& app_locale,
FormFieldData* field) {
@@ -232,29 +232,31 @@ void FillSelectControl(const AutofillType& type,
// Guard against corrupted values passed over IPC.
if (field->option_values.size() != field->option_contents.size())
- return;
+ return false;
if (value.empty())
- return;
+ return false;
// First, search for exact matches.
if (SetSelectControlValue(value, field))
- return;
+ return true;
// If that fails, try specific fallbacks based on the field type.
ServerFieldType storable_type = type.GetStorableType();
if (storable_type == ADDRESS_HOME_STATE) {
- FillStateSelectControl(value, field);
+ return FillStateSelectControl(value, field);
} else if (storable_type == ADDRESS_HOME_COUNTRY) {
- FillCountrySelectControl(value, app_locale, field);
+ return FillCountrySelectControl(value, app_locale, field);
} else if (storable_type == CREDIT_CARD_EXP_MONTH) {
- FillExpirationMonthSelectControl(value, field);
+ return FillExpirationMonthSelectControl(value, field);
} else if (storable_type == CREDIT_CARD_EXP_2_DIGIT_YEAR ||
storable_type == CREDIT_CARD_EXP_4_DIGIT_YEAR) {
- FillYearSelectControl(value, field);
+ return FillYearSelectControl(value, field);
} else if (storable_type == CREDIT_CARD_TYPE) {
- FillCreditCardTypeSelectControl(value, field);
+ return FillCreditCardTypeSelectControl(value, field);
}
+
+ return false;
}
// Fills in the month control |field| with |value|. |value| should be a date
@@ -389,22 +391,26 @@ bool AutofillField::IsFieldFillable() const {
}
// static
-void AutofillField::FillFormField(const AutofillField& field,
+bool AutofillField::FillFormField(const AutofillField& field,
const base::string16& value,
const std::string& app_locale,
FormFieldData* field_data) {
AutofillType type = field.Type();
- if (type.GetStorableType() == PHONE_HOME_NUMBER)
+ if (type.GetStorableType() == PHONE_HOME_NUMBER) {
FillPhoneNumberField(field, value, field_data);
- else if (field_data->form_control_type == "select-one")
- FillSelectControl(type, value, app_locale, field_data);
- else if (field_data->form_control_type == "month")
- FillMonthControl(value, field_data);
- else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS)
+ return true;
+ } else if (field_data->form_control_type == "select-one") {
+ return FillSelectControl(type, value, app_locale, field_data);
+ } else if (field_data->form_control_type == "month") {
+ return FillMonthControl(value, field_data);
+ } else if (type.GetStorableType() == ADDRESS_HOME_STREET_ADDRESS) {
FillStreetAddress(value, field_data);
- else
- field_data->value = value;
+ return true;
+ }
+
+ field_data->value = value;
+ return true;
}
} // namespace autofill
diff --git a/components/autofill/core/browser/autofill_field.h b/components/autofill/core/browser/autofill_field.h
index 38aeaea..f0b1e7e 100644
--- a/components/autofill/core/browser/autofill_field.h
+++ b/components/autofill/core/browser/autofill_field.h
@@ -67,8 +67,8 @@ class AutofillField : public FormFieldData {
// Set |field_data|'s value to |value|. Uses |field| and |app_locale| as
// hints when filling exceptional cases like phone number values and <select>
- // fields.
- static void FillFormField(const AutofillField& field,
+ // fields. Returns |true| if the field has been filled, |false| otherwise.
+ static bool FillFormField(const AutofillField& field,
const base::string16& value,
const std::string& app_locale,
FormFieldData* field_data);
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 80902aa7..d40eb8f 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -497,14 +497,15 @@ void AutofillManager::FillOrPreviewForm(
if ((*iter) == field) {
base::string16 value = data_model->GetInfoForVariant(
autofill_field->Type(), variant, app_locale_);
- AutofillField::FillFormField(*autofill_field, value, app_locale_,
- &(*iter));
- // Mark the cached field as autofilled, so that we can detect when a
- // user edits an autofilled field (for metrics).
- autofill_field->is_autofilled = true;
-
- if (!is_credit_card && !value.empty())
- manager_delegate_->DidFillOrPreviewField(value, profile_full_name);
+ if (AutofillField::FillFormField(
+ *autofill_field, value, app_locale_, &(*iter))) {
+ // Mark the cached field as autofilled, so that we can detect when a
+ // user edits an autofilled field (for metrics).
+ autofill_field->is_autofilled = true;
+
+ if (!is_credit_card && !value.empty())
+ manager_delegate_->DidFillOrPreviewField(value, profile_full_name);
+ }
break;
}
}
@@ -548,14 +549,15 @@ void AutofillManager::FillOrPreviewForm(
(result.fields[i] == field ||
result.fields[i].form_control_type == "select-one" ||
result.fields[i].value.empty());
- AutofillField::FillFormField(*cached_field, value, app_locale_,
- &result.fields[i]);
- // Mark the cached field as autofilled, so that we can detect when a user
- // edits an autofilled field (for metrics).
- form_structure->field(i)->is_autofilled = true;
-
- if (should_notify)
- manager_delegate_->DidFillOrPreviewField(value, profile_full_name);
+ if (AutofillField::FillFormField(
+ *cached_field, value, app_locale_, &result.fields[i])) {
+ // Mark the cached field as autofilled, so that we can detect when a
+ // user edits an autofilled field (for metrics).
+ form_structure->field(i)->is_autofilled = true;
+
+ if (should_notify)
+ manager_delegate_->DidFillOrPreviewField(value, profile_full_name);
+ }
}
}