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

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

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

Powered by Google App Engine
This is Rietveld 408576698