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

Side by Side Diff: chrome/browser/ui/webui/options/autofill_options_handler.cc

Issue 399003002: Parse full name set in chrome://settings/autofill (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: stop breaking things Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 18 matching lines...) Expand all
29 #include "grit/components_strings.h" 29 #include "grit/components_strings.h"
30 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
31 #include "third_party/libaddressinput/messages.h" 31 #include "third_party/libaddressinput/messages.h"
32 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h" 32 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h"
33 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h" 33 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui _component.h"
34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h" 34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati on.h"
35 #include "ui/base/l10n/l10n_util.h" 35 #include "ui/base/l10n/l10n_util.h"
36 #include "ui/base/webui/web_ui_util.h" 36 #include "ui/base/webui/web_ui_util.h"
37 37
38 using autofill::AutofillCountry; 38 using autofill::AutofillCountry;
39 using autofill::AutofillType;
39 using autofill::ServerFieldType; 40 using autofill::ServerFieldType;
40 using autofill::AutofillProfile; 41 using autofill::AutofillProfile;
41 using autofill::CreditCard; 42 using autofill::CreditCard;
42 using autofill::PersonalDataManager; 43 using autofill::PersonalDataManager;
43 using i18n::addressinput::AddressUiComponent; 44 using i18n::addressinput::AddressUiComponent;
44 45
45 namespace { 46 namespace {
46 47
47 const char kSettingsOrigin[] = "Chrome settings"; 48 const char kSettingsOrigin[] = "Chrome settings";
48 49
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 194
194 // |GetRawMultiInfo()| always returns at least one, potentially empty, item. 195 // |GetRawMultiInfo()| always returns at least one, potentially empty, item.
195 if (values.size() == 1 && values.front().empty()) 196 if (values.size() == 1 && values.front().empty())
196 return; 197 return;
197 198
198 for (size_t i = 0; i < values.size(); ++i) { 199 for (size_t i = 0; i < values.size(); ++i) {
199 (*list)->Set(i, new base::StringValue(values[i])); 200 (*list)->Set(i, new base::StringValue(values[i]));
200 } 201 }
201 } 202 }
202 203
203 // Set the multi-valued element for |type| from input |list| values. 204 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.
204 void SetValueList(const base::ListValue* list, 205 std::vector<base::string16>* output) {
205 ServerFieldType type, 206 output->resize(list.GetSize());
206 AutofillProfile* profile) { 207 for (size_t i = 0; i < list.GetSize(); ++i) {
207 std::vector<base::string16> values(list->GetSize());
208 for (size_t i = 0; i < list->GetSize(); ++i) {
209 base::string16 value; 208 base::string16 value;
210 if (list->GetString(i, &value)) 209 if (list.GetString(i, &value))
211 values[i] = value; 210 (*output)[i].swap(value);
212 } 211 }
213 profile->SetRawMultiInfo(type, values);
214 } 212 }
215 213
216 // Pulls the phone number |index|, |phone_number_list|, and |country_code| from 214 // Pulls the phone number |index|, |phone_number_list|, and |country_code| from
217 // the |args| input. 215 // the |args| input.
218 void ExtractPhoneNumberInformation(const base::ListValue* args, 216 void ExtractPhoneNumberInformation(const base::ListValue* args,
219 size_t* index, 217 size_t* index,
220 const base::ListValue** phone_number_list, 218 const base::ListValue** phone_number_list,
221 std::string* country_code) { 219 std::string* country_code) {
222 // Retrieve index as a |double|, as that is how it comes across from 220 // Retrieve index as a |double|, as that is how it comes across from
223 // JavaScript. 221 // JavaScript.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 std::string guid; 592 std::string guid;
595 if (!args->GetString(arg_counter++, &guid)) { 593 if (!args->GetString(arg_counter++, &guid)) {
596 NOTREACHED(); 594 NOTREACHED();
597 return; 595 return;
598 } 596 }
599 597
600 AutofillProfile profile(guid, kSettingsOrigin); 598 AutofillProfile profile(guid, kSettingsOrigin);
601 599
602 base::string16 value; 600 base::string16 value;
603 const base::ListValue* list_value; 601 const base::ListValue* list_value;
604 if (args->GetList(arg_counter++, &list_value)) 602 if (args->GetList(arg_counter++, &list_value)) {
605 SetValueList(list_value, autofill::NAME_FULL, &profile); 603 std::vector<base::string16> values;
604 ListValueToStringVector(*list_value, &values);
605 profile.SetMultiInfo(AutofillType(autofill::NAME_FULL),
606 values,
607 g_browser_process->GetApplicationLocale());
608 }
606 609
607 if (args->GetString(arg_counter++, &value)) 610 if (args->GetString(arg_counter++, &value))
608 profile.SetRawInfo(autofill::COMPANY_NAME, value); 611 profile.SetRawInfo(autofill::COMPANY_NAME, value);
609 612
610 if (args->GetString(arg_counter++, &value)) 613 if (args->GetString(arg_counter++, &value))
611 profile.SetRawInfo(autofill::ADDRESS_HOME_STREET_ADDRESS, value); 614 profile.SetRawInfo(autofill::ADDRESS_HOME_STREET_ADDRESS, value);
612 615
613 if (args->GetString(arg_counter++, &value)) 616 if (args->GetString(arg_counter++, &value))
614 profile.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY, value); 617 profile.SetRawInfo(autofill::ADDRESS_HOME_DEPENDENT_LOCALITY, value);
615 618
616 if (args->GetString(arg_counter++, &value)) 619 if (args->GetString(arg_counter++, &value))
617 profile.SetRawInfo(autofill::ADDRESS_HOME_CITY, value); 620 profile.SetRawInfo(autofill::ADDRESS_HOME_CITY, value);
618 621
619 if (args->GetString(arg_counter++, &value)) 622 if (args->GetString(arg_counter++, &value))
620 profile.SetRawInfo(autofill::ADDRESS_HOME_STATE, value); 623 profile.SetRawInfo(autofill::ADDRESS_HOME_STATE, value);
621 624
622 if (args->GetString(arg_counter++, &value)) 625 if (args->GetString(arg_counter++, &value))
623 profile.SetRawInfo(autofill::ADDRESS_HOME_ZIP, value); 626 profile.SetRawInfo(autofill::ADDRESS_HOME_ZIP, value);
624 627
625 if (args->GetString(arg_counter++, &value)) 628 if (args->GetString(arg_counter++, &value))
626 profile.SetRawInfo(autofill::ADDRESS_HOME_SORTING_CODE, value); 629 profile.SetRawInfo(autofill::ADDRESS_HOME_SORTING_CODE, value);
627 630
628 if (args->GetString(arg_counter++, &value)) 631 if (args->GetString(arg_counter++, &value))
629 profile.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, value); 632 profile.SetRawInfo(autofill::ADDRESS_HOME_COUNTRY, value);
630 633
631 if (args->GetList(arg_counter++, &list_value)) 634 if (args->GetList(arg_counter++, &list_value)) {
632 SetValueList(list_value, autofill::PHONE_HOME_WHOLE_NUMBER, &profile); 635 std::vector<base::string16> values;
636 ListValueToStringVector(*list_value, &values);
637 profile.SetRawMultiInfo(autofill::PHONE_HOME_WHOLE_NUMBER, values);
638 }
633 639
634 if (args->GetList(arg_counter++, &list_value)) 640 if (args->GetList(arg_counter++, &list_value)) {
635 SetValueList(list_value, autofill::EMAIL_ADDRESS, &profile); 641 std::vector<base::string16> values;
642 ListValueToStringVector(*list_value, &values);
643 profile.SetRawMultiInfo(autofill::EMAIL_ADDRESS, values);
644 }
636 645
637 if (args->GetString(arg_counter++, &value)) 646 if (args->GetString(arg_counter++, &value))
638 profile.set_language_code(base::UTF16ToUTF8(value)); 647 profile.set_language_code(base::UTF16ToUTF8(value));
639 648
640 if (!base::IsValidGUID(profile.guid())) { 649 if (!base::IsValidGUID(profile.guid())) {
641 profile.set_guid(base::GenerateGUID()); 650 profile.set_guid(base::GenerateGUID());
642 personal_data_->AddProfile(profile); 651 personal_data_->AddProfile(profile);
643 } else { 652 } else {
644 personal_data_->UpdateProfile(profile); 653 personal_data_->UpdateProfile(profile);
645 } 654 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 695
687 web_ui()->CallJavascriptFunction( 696 web_ui()->CallJavascriptFunction(
688 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); 697 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
689 } 698 }
690 699
691 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { 700 bool AutofillOptionsHandler::IsPersonalDataLoaded() const {
692 return personal_data_ && personal_data_->IsDataLoaded(); 701 return personal_data_ && personal_data_->IsDataLoaded();
693 } 702 }
694 703
695 } // namespace options 704 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698