Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(547)

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 1029233002: Autofill - don't prompt to unmask a credit card if the number isn't needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update histograms.xml Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index 0ccf7d90feb92c60ca7d0ad4e271d7536f116b81..677dfde4b9344280d2787f04a402d989486a43cd 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -551,6 +551,33 @@ void AutofillManager::OnQueryFormFieldAutofill(int query_id,
}
}
+bool AutofillManager::WillFillCreditCardNumber(const FormData& form,
+ const FormFieldData& field) {
+ FormStructure* form_structure = NULL;
brettw 2015/03/24 22:30:47 I thought we were preferring nullptr for new code.
Evan Stade 2015/03/24 22:34:01 old habits die hard
+ AutofillField* autofill_field = NULL;
+ if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field))
+ return false;
+
+ if (autofill_field->Type().GetStorableType() == CREDIT_CARD_NUMBER)
+ return true;
+
+ // If the relevant section is autofilled, we'll only fill |autofill_field|.
brettw 2015/03/24 22:30:47 Everything here makes sense to me except these thr
Evan Stade 2015/03/24 22:34:01 your understanding is correct, I'll apply your new
+ if (SectionIsAutofilled(*form_structure, form, autofill_field->section()))
+ return false;
+
+ DCHECK_EQ(form_structure->field_count(), form.fields.size());
+ for (size_t i = 0; i < form_structure->field_count(); ++i) {
+ if (form_structure->field(i)->section() == autofill_field->section() &&
+ form_structure->field(i)->Type().GetStorableType() ==
+ CREDIT_CARD_NUMBER &&
+ form.fields[i].value.empty()) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
void AutofillManager::FillOrPreviewCreditCardForm(
AutofillDriver::RendererFormDataAction action,
int query_id,
@@ -559,7 +586,8 @@ void AutofillManager::FillOrPreviewCreditCardForm(
const CreditCard& credit_card,
size_t variant) {
if (action == AutofillDriver::FORM_DATA_ACTION_FILL) {
- if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD) {
+ if (credit_card.record_type() == CreditCard::MASKED_SERVER_CARD &&
+ WillFillCreditCardNumber(form, field)) {
unmasking_card_ = credit_card;
unmasking_query_id_ = query_id;
unmasking_form_ = form;
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698