Chromium Code Reviews| 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 45087bfa6de7aa47af43f3685940c8fbdbc41499..09c8e7ec2e27c84b026c816d3fc59ada38a49159 100644 |
| --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc |
| @@ -36,6 +36,7 @@ |
| #include "ui/base/webui/web_ui_util.h" |
| using autofill::AutofillCountry; |
| +using autofill::AutofillType; |
| using autofill::ServerFieldType; |
| using autofill::AutofillProfile; |
| using autofill::CreditCard; |
| @@ -200,17 +201,14 @@ void GetValueList(const AutofillProfile& profile, |
| } |
| } |
| -// Set the multi-valued element for |type| from input |list| values. |
| -void SetValueList(const base::ListValue* list, |
| - ServerFieldType type, |
| - AutofillProfile* profile) { |
| - std::vector<base::string16> values(list->GetSize()); |
| - for (size_t i = 0; i < list->GetSize(); ++i) { |
| +void ListValueToStringVector(const base::ListValue& list, |
|
Ilya Sherman
2014/07/17 18:50:56
nit: Docs, plz.
Evan Stade
2014/07/22 01:50:53
Done.
|
| + std::vector<base::string16>* output) { |
| + output->resize(list.GetSize()); |
| + for (size_t i = 0; i < list.GetSize(); ++i) { |
| base::string16 value; |
| - if (list->GetString(i, &value)) |
| - values[i] = value; |
| + if (list.GetString(i, &value)) |
| + (*output)[i].swap(value); |
| } |
| - profile->SetRawMultiInfo(type, values); |
| } |
| // Pulls the phone number |index|, |phone_number_list|, and |country_code| from |
| @@ -601,8 +599,13 @@ void AutofillOptionsHandler::SetAddress(const base::ListValue* args) { |
| base::string16 value; |
| const base::ListValue* list_value; |
| - if (args->GetList(arg_counter++, &list_value)) |
| - SetValueList(list_value, autofill::NAME_FULL, &profile); |
| + if (args->GetList(arg_counter++, &list_value)) { |
| + std::vector<base::string16> values; |
| + ListValueToStringVector(*list_value, &values); |
| + profile.SetMultiInfo(AutofillType(autofill::NAME_FULL), |
| + values, |
| + g_browser_process->GetApplicationLocale()); |
| + } |
| if (args->GetString(arg_counter++, &value)) |
| profile.SetRawInfo(autofill::COMPANY_NAME, value); |
| @@ -628,11 +631,17 @@ void AutofillOptionsHandler::SetAddress(const base::ListValue* args) { |
| if (args->GetString(arg_counter++, &value)) |
| profile.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, value); |
| - if (args->GetList(arg_counter++, &list_value)) |
| - SetValueList(list_value, autofill::PHONE_HOME_WHOLE_NUMBER, &profile); |
| + if (args->GetList(arg_counter++, &list_value)) { |
| + std::vector<base::string16> values; |
| + ListValueToStringVector(*list_value, &values); |
| + profile.SetRawMultiInfo(autofill::PHONE_HOME_WHOLE_NUMBER, values); |
| + } |
| - if (args->GetList(arg_counter++, &list_value)) |
| - SetValueList(list_value, autofill::EMAIL_ADDRESS, &profile); |
| + if (args->GetList(arg_counter++, &list_value)) { |
| + std::vector<base::string16> values; |
| + ListValueToStringVector(*list_value, &values); |
| + profile.SetRawMultiInfo(autofill::EMAIL_ADDRESS, values); |
| + } |
| if (args->GetString(arg_counter++, &value)) |
| profile.set_language_code(base::UTF16ToUTF8(value)); |