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

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

Issue 10837044: Correct const accessors in base/values.(h|cc), Part II (ListValue) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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: 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);
« no previous file with comments | « chrome/browser/ui/webui/ntp/app_launcher_handler.cc ('k') | chrome/browser/ui/webui/options2/core_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698