OLD | NEW |
---|---|
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> |
Mathieu
2016/04/04 13:36:17
#include <memory>
vabr (Chromium)
2016/04/04 14:29:04
Done.
| |
10 #include <ostream> | 10 #include <ostream> |
11 #include <set> | 11 #include <set> |
12 | 12 |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/i18n/char_iterator.h" | 15 #include "base/i18n/char_iterator.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
19 #include "base/sha1.h" | 19 #include "base/sha1.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
314 void AutofillProfile::SetRawInfo(ServerFieldType type, | 314 void AutofillProfile::SetRawInfo(ServerFieldType type, |
315 const base::string16& value) { | 315 const base::string16& value) { |
316 FormGroup* form_group = MutableFormGroupForType(AutofillType(type)); | 316 FormGroup* form_group = MutableFormGroupForType(AutofillType(type)); |
317 if (form_group) | 317 if (form_group) |
318 form_group->SetRawInfo(type, value); | 318 form_group->SetRawInfo(type, value); |
319 } | 319 } |
320 | 320 |
321 base::string16 AutofillProfile::GetInfo(const AutofillType& type, | 321 base::string16 AutofillProfile::GetInfo(const AutofillType& type, |
322 const std::string& app_locale) const { | 322 const std::string& app_locale) const { |
323 if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { | 323 if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { |
324 scoped_ptr<AddressData> address_data = | 324 std::unique_ptr<AddressData> address_data = |
325 i18n::CreateAddressDataFromAutofillProfile(*this, app_locale); | 325 i18n::CreateAddressDataFromAutofillProfile(*this, app_locale); |
326 if (!addressinput::HasAllRequiredFields(*address_data)) | 326 if (!addressinput::HasAllRequiredFields(*address_data)) |
327 return base::string16(); | 327 return base::string16(); |
328 | 328 |
329 std::vector<std::string> lines; | 329 std::vector<std::string> lines; |
330 ::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines); | 330 ::i18n::addressinput::GetFormattedNationalAddress(*address_data, &lines); |
331 return base::UTF8ToUTF16(base::JoinString(lines, "\n")); | 331 return base::UTF8ToUTF16(base::JoinString(lines, "\n")); |
332 } | 332 } |
333 | 333 |
334 const FormGroup* form_group = FormGroupForType(type); | 334 const FormGroup* form_group = FormGroupForType(type); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 const std::string& app_locale) const { | 438 const std::string& app_locale) const { |
439 ServerFieldTypeSet types; | 439 ServerFieldTypeSet types; |
440 GetSupportedTypes(&types); | 440 GetSupportedTypes(&types); |
441 return IsSubsetOfForFieldSet(profile, app_locale, types); | 441 return IsSubsetOfForFieldSet(profile, app_locale, types); |
442 } | 442 } |
443 | 443 |
444 bool AutofillProfile::IsSubsetOfForFieldSet( | 444 bool AutofillProfile::IsSubsetOfForFieldSet( |
445 const AutofillProfile& profile, | 445 const AutofillProfile& profile, |
446 const std::string& app_locale, | 446 const std::string& app_locale, |
447 const ServerFieldTypeSet& types) const { | 447 const ServerFieldTypeSet& types) const { |
448 scoped_ptr<l10n::CaseInsensitiveCompare> compare; | 448 std::unique_ptr<l10n::CaseInsensitiveCompare> compare; |
449 | 449 |
450 for (ServerFieldType type : types) { | 450 for (ServerFieldType type : types) { |
451 base::string16 value = GetRawInfo(type); | 451 base::string16 value = GetRawInfo(type); |
452 if (value.empty()) | 452 if (value.empty()) |
453 continue; | 453 continue; |
454 | 454 |
455 if (type == NAME_FULL || type == ADDRESS_HOME_STREET_ADDRESS) { | 455 if (type == NAME_FULL || type == ADDRESS_HOME_STREET_ADDRESS) { |
456 // Ignore the compound "full name" field type. We are only interested in | 456 // Ignore the compound "full name" field type. We are only interested in |
457 // comparing the constituent parts. For example, if |this| has a middle | 457 // comparing the constituent parts. For example, if |this| has a middle |
458 // name saved, but |profile| lacks one, |profile| could still be a subset | 458 // name saved, but |profile| lacks one, |profile| could still be a subset |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 | 862 |
863 AutofillType autofill_type(*it); | 863 AutofillType autofill_type(*it); |
864 base::string16 field_value = GetInfo(autofill_type, app_locale); | 864 base::string16 field_value = GetInfo(autofill_type, app_locale); |
865 if (field_value.empty()) | 865 if (field_value.empty()) |
866 continue; | 866 continue; |
867 | 867 |
868 trimmed_profile.SetInfo(autofill_type, field_value, app_locale); | 868 trimmed_profile.SetInfo(autofill_type, field_value, app_locale); |
869 --num_fields_to_use; | 869 --num_fields_to_use; |
870 } | 870 } |
871 | 871 |
872 scoped_ptr<AddressData> address_data = | 872 std::unique_ptr<AddressData> address_data = |
873 i18n::CreateAddressDataFromAutofillProfile(trimmed_profile, app_locale); | 873 i18n::CreateAddressDataFromAutofillProfile(trimmed_profile, app_locale); |
874 std::string address_line; | 874 std::string address_line; |
875 ::i18n::addressinput::GetFormattedNationalAddressLine( | 875 ::i18n::addressinput::GetFormattedNationalAddressLine( |
876 *address_data, &address_line); | 876 *address_data, &address_line); |
877 base::string16 label = base::UTF8ToUTF16(address_line); | 877 base::string16 label = base::UTF8ToUTF16(address_line); |
878 | 878 |
879 for (std::vector<ServerFieldType>::const_iterator it = | 879 for (std::vector<ServerFieldType>::const_iterator it = |
880 remaining_fields.begin(); | 880 remaining_fields.begin(); |
881 it != remaining_fields.end() && num_fields_to_use > 0; | 881 it != remaining_fields.end() && num_fields_to_use > 0; |
882 ++it) { | 882 ++it) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1048 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " | 1048 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " |
1049 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " | 1049 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " |
1050 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " | 1050 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " |
1051 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " | 1051 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " |
1052 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " | 1052 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " |
1053 << profile.language_code() << " " | 1053 << profile.language_code() << " " |
1054 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); | 1054 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); |
1055 } | 1055 } |
1056 | 1056 |
1057 } // namespace autofill | 1057 } // namespace autofill |
OLD | NEW |