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

Unified Diff: chrome/browser/ui/webui/options/autofill_options_handler.cc

Issue 1924863002: Rescoping prior profile data in Autofill settings to correct regression. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/autofill_options_handler.cc
diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc
index 397c110c872432edc967b943a30545e534ffa5f9..b387f8b4fdc424ab55ad4547aeccb9627b79bb90 100644
--- a/chrome/browser/ui/webui/options/autofill_options_handler.cc
+++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc
@@ -204,8 +204,7 @@ void SetCountryData(const PersonalDataManager& manager,
namespace options {
-AutofillOptionsHandler::AutofillOptionsHandler()
- : personal_data_(nullptr), prior_profile_(nullptr) {}
+AutofillOptionsHandler::AutofillOptionsHandler() : personal_data_(nullptr) {}
AutofillOptionsHandler::~AutofillOptionsHandler() {
if (personal_data_)
@@ -391,8 +390,8 @@ void AutofillOptionsHandler::LoadAddressEditor(const base::ListValue* args) {
return;
}
- prior_profile_ = personal_data_->GetProfileByGUID(guid);
- if (!prior_profile_) {
+ const AutofillProfile* prior_profile = personal_data_->GetProfileByGUID(guid);
+ if (!prior_profile) {
// There is a race where a user can click once on the close button and
// quickly click again on the list item before the item is removed (since
// the list is not updated until the model tells the list an item has been
@@ -402,7 +401,7 @@ void AutofillOptionsHandler::LoadAddressEditor(const base::ListValue* args) {
}
base::DictionaryValue address;
- AutofillProfileToDictionary(*prior_profile_, &address);
+ AutofillProfileToDictionary(*prior_profile, &address);
web_ui()->CallJavascriptFunction("AutofillOptions.editAddress", address);
}
@@ -480,20 +479,25 @@ void AutofillOptionsHandler::SetAddress(const base::ListValue* args) {
base::string16 full_name;
if (args->GetString(arg_counter++, &full_name)) {
// Although First/Middle/Last are not displayed on the form, we transfer
- // this information when they match the full name given. This is because it
- // may not be possible later to correctly tokenize the concatenated full
- // name; e.g., when the last name contains a space, the first word would be
- // treated as a middle name.
- if (prior_profile_ && autofill::data_util::ProfileMatchesFullName(
- full_name, *prior_profile_)) {
+ // this information when they match the full name in the old version of the
+ // profile, if one exists. This is because it may not be possible later to
+ // correctly tokenize the concatenated full name; e.g., when the last name
+ // contains a space, the first word would be treated as a middle name.
+ const AutofillProfile* prior_profile =
+ base::IsValidGUID(profile.guid())
+ ? personal_data_->GetProfileByGUID(guid)
+ : nullptr;
+
+ if (prior_profile && autofill::data_util::ProfileMatchesFullName(
+ full_name, *prior_profile)) {
profile.SetRawInfo(autofill::NAME_FULL, full_name);
profile.SetRawInfo(autofill::NAME_FIRST,
- prior_profile_->GetRawInfo(autofill::NAME_FIRST));
+ prior_profile->GetRawInfo(autofill::NAME_FIRST));
profile.SetRawInfo(autofill::NAME_MIDDLE,
- prior_profile_->GetRawInfo(autofill::NAME_MIDDLE));
+ prior_profile->GetRawInfo(autofill::NAME_MIDDLE));
profile.SetRawInfo(autofill::NAME_LAST,
- prior_profile_->GetRawInfo(autofill::NAME_LAST));
+ prior_profile->GetRawInfo(autofill::NAME_LAST));
} else {
// In contrast to SetRawInfo, SetInfo will naively attempt to populate the
// First/Middle/Last fields by tokenization.
« no previous file with comments | « chrome/browser/ui/webui/options/autofill_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698