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

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

Issue 940723002: Fix Autofill crash on mac address book entries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 772585d68a8ee7e3cc02d5f8a7441ea8f37a7fe6..01e0e720d8c6312fd3460320094e0213d16b6f46 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -591,7 +591,7 @@ void AutofillManager::FillOrPreviewCreditCardForm(
credit_card_form_event_logger_->OnDidFillSuggestion(credit_card);
}
- FillOrPreviewDataModelForm(action, query_id, form, field, &credit_card,
+ FillOrPreviewDataModelForm(action, query_id, form, field, credit_card,
variant, true /* is_credit_card */);
}
@@ -605,7 +605,7 @@ void AutofillManager::FillOrPreviewProfileForm(
if (action == AutofillDriver::FORM_DATA_ACTION_FILL)
address_form_event_logger_->OnDidFillSuggestion(profile);
- FillOrPreviewDataModelForm(action, query_id, form, field, &profile, variant,
+ FillOrPreviewDataModelForm(action, query_id, form, field, profile, variant,
false /* is_credit_card */);
}
@@ -643,7 +643,7 @@ void AutofillManager::FillCreditCardForm(int query_id,
}
FillOrPreviewDataModelForm(AutofillDriver::FORM_DATA_ACTION_FILL, query_id,
- form, field, &credit_card, 0, true);
+ form, field, credit_card, 0, true);
}
void AutofillManager::OnDidPreviewAutofillFormData() {
@@ -1039,7 +1039,7 @@ void AutofillManager::FillOrPreviewDataModelForm(
int query_id,
const FormData& form,
const FormFieldData& field,
- const AutofillDataModel* data_model,
+ const AutofillDataModel& data_model,
size_t variant,
bool is_credit_card) {
FormStructure* form_structure = NULL;
@@ -1055,22 +1055,19 @@ void AutofillManager::FillOrPreviewDataModelForm(
base::string16 profile_full_name;
std::string profile_language_code;
if (!is_credit_card) {
- profile_full_name = data_model->GetInfo(
+ profile_full_name = data_model.GetInfo(
AutofillType(NAME_FULL), app_locale_);
profile_language_code =
- static_cast<const AutofillProfile*>(data_model)->language_code();
+ static_cast<const AutofillProfile*>(&data_model)->language_code();
}
- if (action == AutofillDriver::FORM_DATA_ACTION_FILL)
- personal_data_->RecordUseOf(*data_model);
-
// If the relevant section is auto-filled, we should fill |field| but not the
// rest of the form.
if (SectionIsAutofilled(*form_structure, form, autofill_field->section())) {
for (std::vector<FormFieldData>::iterator iter = result.fields.begin();
iter != result.fields.end(); ++iter) {
if (iter->SameFieldAs(field)) {
- base::string16 value = data_model->GetInfoForVariant(
+ base::string16 value = data_model.GetInfoForVariant(
autofill_field->Type(), variant, app_locale_);
if (AutofillField::FillFormField(*autofill_field,
value,
@@ -1094,6 +1091,12 @@ void AutofillManager::FillOrPreviewDataModelForm(
}
driver_->SendFormDataToRenderer(query_id, action, result);
+
+ // Note that this may invalidate |data_model|, particularly if it is a Mac
+ // address book entry.
+ if (action == AutofillDriver::FORM_DATA_ACTION_FILL)
+ personal_data_->RecordUseOf(data_model);
Evan Stade 2015/02/18 21:05:35 as you can see, the meat of the change is moving t
+
return;
}
@@ -1122,15 +1125,15 @@ void AutofillManager::FillOrPreviewDataModelForm(
field_group_type == initiating_group_type) {
use_variant = variant;
}
- base::string16 value = data_model->GetInfoForVariant(
+ base::string16 value = data_model.GetInfoForVariant(
cached_field->Type(), use_variant, app_locale_);
if (is_credit_card &&
cached_field->Type().GetStorableType() ==
CREDIT_CARD_VERIFICATION_CODE) {
- // If this is |unmasking_card_|, |unmask_response_,cvc| should be
+ // If this is |unmasking_card_|, |unmask_response_.cvc| should be
// non-empty and vice versa.
value = unmask_response_.cvc;
- DCHECK_EQ(&unmasking_card_ == data_model, value.empty());
+ DCHECK_EQ(unmasking_card_ == data_model, !value.empty());
}
// Must match ForEachMatchingFormField() in form_autofill_util.cc.
@@ -1168,6 +1171,11 @@ void AutofillManager::FillOrPreviewDataModelForm(
if (autofilled_form_signatures_.size() > kMaxRecentFormSignaturesToRemember)
autofilled_form_signatures_.pop_back();
+ // Note that this may invalidate |data_model|, particularly if it is a Mac
+ // address book entry.
+ if (action == AutofillDriver::FORM_DATA_ACTION_FILL)
+ personal_data_->RecordUseOf(data_model);
+
driver_->SendFormDataToRenderer(query_id, action, result);
}

Powered by Google App Engine
This is Rietveld 408576698