Commit 840036e2 authored by Vidhan's avatar Vidhan Committed by Chromium LUCI CQ

[Autofill] Removed AutofillDataModel::ShouldSkipFillingOrSuggesting

AutofillDataModel::ShouldSkipFillingOrSuggesting always returns false
for the CreditCard whereas AutofillProfile::ShouldSkipFillingOrSuggesting
overrides it.

With this CL, ShouldSkipFillingOrSuggesting is now a member of only
AutofillProfile and never called for CreditCard.

Change-Id: Ie86f5cac7eb7f46f2eb8a9193208783484dd0aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2627487
Commit-Queue: Vidhan Jain <vidhanj@google.com>
Reviewed-by: default avatarChristoph Schwering <schwering@google.com>
Cr-Commit-Position: refs/heads/master@{#843474}
parent 33435f37
......@@ -87,9 +87,4 @@ AutofillDataModel::ValidityState AutofillDataModel::GetValidityState(
return AutofillDataModel::UNSUPPORTED;
}
bool AutofillDataModel::ShouldSkipFillingOrSuggesting(
ServerFieldType type) const {
return false;
}
} // namespace autofill
......@@ -94,10 +94,6 @@ class AutofillDataModel : public FormGroup {
virtual ValidityState GetValidityState(ServerFieldType type,
ValidationSource source) const;
// Check for the validity of the data. Leave the field empty if the data is
// invalid and the relevant feature is enabled.
virtual bool ShouldSkipFillingOrSuggesting(ServerFieldType type) const;
protected:
// Called to update |use_count_| and |use_date_| when this data model is
// the subject of user interaction (usually, when it's used to fill a form).
......
......@@ -279,7 +279,7 @@ class AutofillProfile : public AutofillDataModel {
// Check for the validity of the data. Leave the field empty if the data is
// invalid and the relevant feature is enabled.
bool ShouldSkipFillingOrSuggesting(ServerFieldType type) const override;
bool ShouldSkipFillingOrSuggesting(ServerFieldType type) const;
base::WeakPtr<const AutofillProfile> GetWeakPtr() const {
return weak_ptr_factory_.GetWeakPtr();
......
......@@ -821,22 +821,28 @@ bool FieldFiller::FillFormField(
const base::string16& cvc,
std::string* failure_to_fill) {
const AutofillType type = field.Type();
const AutofillDataModel& data_model = [&]() -> const AutofillDataModel& {
if (absl::holds_alternative<const AutofillProfile*>(profile_or_credit_card))
return *absl::get<const AutofillProfile*>(profile_or_credit_card);
else
return *absl::get<const CreditCard*>(profile_or_credit_card);
}();
if (data_model.ShouldSkipFillingOrSuggesting(type.GetStorableType())) {
base::string16 value;
if (absl::holds_alternative<const AutofillProfile*>(profile_or_credit_card)) {
const AutofillProfile* profile =
absl::get<const AutofillProfile*>(profile_or_credit_card);
if (profile->ShouldSkipFillingOrSuggesting(type.GetStorableType())) {
if (failure_to_fill)
*failure_to_fill += "ShouldSkipFillingOrSuggesting() returned true. ";
return false;
}
base::string16 value = data_model.GetInfo(type, app_locale_);
if (type.GetStorableType() == CREDIT_CARD_VERIFICATION_CODE)
value = profile->GetInfo(type, app_locale_);
} else {
DCHECK(absl::holds_alternative<const CreditCard*>(profile_or_credit_card));
if (type.GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) {
value = cvc;
} else {
value = absl::get<const CreditCard*>(profile_or_credit_card)
->GetInfo(type, app_locale_);
}
}
// Do not attempt to fill empty values as it would skew the metrics.
if (value.empty()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment