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

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1553833002: Display phone number with formatting in Autofill profile summary label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update tests Created 4 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/core/browser/autofill_profile.h" 5 #include "components/autofill/core/browser/autofill_profile.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <map> 9 #include <map>
10 #include <ostream> 10 #include <ostream>
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 AddressField address_field; 852 AddressField address_field;
853 if (!i18n::FieldForType(*it, &address_field) || 853 if (!i18n::FieldForType(*it, &address_field) ||
854 !::i18n::addressinput::IsFieldUsed( 854 !::i18n::addressinput::IsFieldUsed(
855 address_field, address_region_code) || 855 address_field, address_region_code) ||
856 address_field == ::i18n::addressinput::COUNTRY) { 856 address_field == ::i18n::addressinput::COUNTRY) {
857 remaining_fields.push_back(*it); 857 remaining_fields.push_back(*it);
858 continue; 858 continue;
859 } 859 }
860 860
861 AutofillType autofill_type(*it); 861 AutofillType autofill_type(*it);
862 const base::string16& field_value = GetInfo(autofill_type, app_locale); 862 base::string16 field_value = GetInfo(autofill_type, app_locale);
863 if (field_value.empty()) 863 if (field_value.empty())
864 continue; 864 continue;
865 865
866 trimmed_profile.SetInfo(autofill_type, field_value, app_locale); 866 trimmed_profile.SetInfo(autofill_type, field_value, app_locale);
867 --num_fields_to_use; 867 --num_fields_to_use;
868 } 868 }
869 869
870 scoped_ptr<AddressData> address_data = 870 scoped_ptr<AddressData> address_data =
871 i18n::CreateAddressDataFromAutofillProfile(trimmed_profile, app_locale); 871 i18n::CreateAddressDataFromAutofillProfile(trimmed_profile, app_locale);
872 std::string address_line; 872 std::string address_line;
873 ::i18n::addressinput::GetFormattedNationalAddressLine( 873 ::i18n::addressinput::GetFormattedNationalAddressLine(
874 *address_data, &address_line); 874 *address_data, &address_line);
875 base::string16 label = base::UTF8ToUTF16(address_line); 875 base::string16 label = base::UTF8ToUTF16(address_line);
876 876
877 for (std::vector<ServerFieldType>::const_iterator it = 877 for (std::vector<ServerFieldType>::const_iterator it =
878 remaining_fields.begin(); 878 remaining_fields.begin();
879 it != remaining_fields.end() && num_fields_to_use > 0; 879 it != remaining_fields.end() && num_fields_to_use > 0;
880 ++it) { 880 ++it) {
881 const base::string16& field_value = GetInfo(AutofillType(*it), app_locale); 881 base::string16 field_value;
882 // Special case whole numbers: we want the user-formatted (raw) version, not
883 // the canonicalized version we'll fill into the page.
884 if (*it == PHONE_HOME_WHOLE_NUMBER)
885 field_value = GetRawInfo(*it);
886 else
887 field_value = GetInfo(AutofillType(*it), app_locale);
882 if (field_value.empty()) 888 if (field_value.empty())
883 continue; 889 continue;
884 890
885 if (!label.empty()) 891 if (!label.empty())
886 label.append(separator); 892 label.append(separator);
887 893
888 label.append(field_value); 894 label.append(field_value);
889 --num_fields_to_use; 895 --num_fields_to_use;
890 } 896 }
891 897
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 1046 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
1041 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 1047 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
1042 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 1048 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
1043 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 1049 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
1044 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 1050 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
1045 << profile.language_code() << " " 1051 << profile.language_code() << " "
1046 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 1052 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
1047 } 1053 }
1048 1054
1049 } // namespace autofill 1055 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698