Chromium Code Reviews| Index: chrome/browser/ui/webui/options2/autofill_options_handler.cc |
| diff --git a/chrome/browser/ui/webui/options2/autofill_options_handler.cc b/chrome/browser/ui/webui/options2/autofill_options_handler.cc |
| index f1491a2a71c571389dd0350ebac5a9d5e9872575..f04eda6371de9a73ab65f8b4662e28b8a85775ca 100644 |
| --- a/chrome/browser/ui/webui/options2/autofill_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options2/autofill_options_handler.cc |
| @@ -166,7 +166,7 @@ void SetNameList(const ListValue* names, |
| std::vector<string16> last_names(size); |
| for (size_t i = 0; i < size; ++i) { |
| - ListValue* name; |
| + const ListValue* name; |
| bool success = names->GetList(i, &name); |
| DCHECK(success); |
| @@ -195,7 +195,7 @@ void SetNameList(const ListValue* names, |
| // the |args| input. |
| void ExtractPhoneNumberInformation(const ListValue* args, |
| size_t* index, |
| - ListValue** phone_number_list, |
| + const ListValue** phone_number_list, |
| std::string* country_code) { |
| // Retrieve index as a |double|, as that is how it comes across from |
| // JavaScript. |
| @@ -249,12 +249,15 @@ void RemoveDuplicatePhoneNumberAtIndex(size_t index, |
| list->Remove(index, NULL); |
| } |
| -void ValidatePhoneArguments(const ListValue* args, ListValue** list) { |
| +scoped_ptr<ListValue> ValidatePhoneArguments(const ListValue* args) { |
| size_t index = 0; |
| std::string country_code; |
| - ExtractPhoneNumberInformation(args, &index, list, &country_code); |
| + const ListValue* extracted_list = NULL; |
| + ExtractPhoneNumberInformation(args, &index, &extracted_list, &country_code); |
| - RemoveDuplicatePhoneNumberAtIndex(index, country_code, *list); |
| + ListValue* list = extracted_list->DeepCopy(); |
|
dhollowa
2012/08/01 16:11:56
optional: I have a slight preference for creating
vabr (Chromium)
2012/08/03 07:08:24
Done.
|
| + RemoveDuplicatePhoneNumberAtIndex(index, country_code, list); |
| + return scoped_ptr<ListValue>(list); |
| } |
| } // namespace |
| @@ -550,7 +553,7 @@ void AutofillOptionsHandler::SetAddress(const ListValue* args) { |
| std::string country_code; |
| string16 value; |
| - ListValue* list_value; |
| + const ListValue* list_value; |
| if (args->GetList(1, &list_value)) |
| SetNameList(list_value, &profile); |
| if (args->GetString(2, &value)) |
| @@ -614,8 +617,7 @@ void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) { |
| if (!IsPersonalDataLoaded()) |
| return; |
| - ListValue* list_value = NULL; |
| - ValidatePhoneArguments(args, &list_value); |
| + scoped_ptr<ListValue> list_value = ValidatePhoneArguments(args); |
| web_ui()->CallJavascriptFunction( |
| "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); |