From fafe725f5dfb6f97de65c3082294875c28ae53f7 Mon Sep 17 00:00:00 2001 From: "isherman@chromium.org" Date: Sat, 1 Oct 2011 00:09:05 +0000 Subject: Only show one placeholder row in 'Edit Autofill address' name list for profiles without name info. BUG=98280 TEST=none Review URL: http://codereview.chromium.org/8068014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103597 0039d316-1c4b-4281-b951-d872f2087c98 --- .../ui/webui/options/autofill_options_handler.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'chrome/browser/ui') diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index cab4023..9072702 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -99,9 +99,15 @@ DictionaryValue* GetCountryData() { void GetValueList(const AutofillProfile& profile, AutofillFieldType type, scoped_ptr* list) { + list->reset(new ListValue); + std::vector values; profile.GetMultiInfo(type, &values); - list->reset(new ListValue); + + // |GetMultiInfo()| always returns at least one, potentially empty, item. + if (values.size() == 1 && values.front().empty()) + return; + for (size_t i = 0; i < values.size(); ++i) { (*list)->Set(i, Value::CreateStringValue(values[i])); } @@ -123,6 +129,8 @@ void SetValueList(const ListValue* list, // Get the multi-valued element for |type| and return it in |ListValue| form. void GetNameList(const AutofillProfile& profile, scoped_ptr* names) { + names->reset(new ListValue); + std::vector first_names; std::vector middle_names; std::vector last_names; @@ -132,7 +140,12 @@ void GetNameList(const AutofillProfile& profile, DCHECK_EQ(first_names.size(), middle_names.size()); DCHECK_EQ(first_names.size(), last_names.size()); - names->reset(new ListValue); + // |GetMultiInfo()| always returns at least one, potentially empty, item. + if (first_names.size() == 1 && first_names.front().empty() && + middle_names.front().empty() && last_names.front().empty()) { + return; + } + for (size_t i = 0; i < first_names.size(); ++i) { ListValue* name = new ListValue; // owned by |list| name->Set(0, Value::CreateStringValue(first_names[i])); -- cgit v1.1