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

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

Issue 2972973002: [Payments] When saving an edited address in editor, clear data first. (Closed)
Patch Set: addressed comments Created 3 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
« no previous file with comments | « components/autofill/core/browser/autofill_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory>
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 const std::string& app_locale) { 302 const std::string& app_locale) {
303 FormGroup* form_group = MutableFormGroupForType(type); 303 FormGroup* form_group = MutableFormGroupForType(type);
304 if (!form_group) 304 if (!form_group)
305 return false; 305 return false;
306 306
307 base::string16 trimmed_value; 307 base::string16 trimmed_value;
308 base::TrimWhitespace(value, base::TRIM_ALL, &trimmed_value); 308 base::TrimWhitespace(value, base::TRIM_ALL, &trimmed_value);
309 return form_group->SetInfo(type, trimmed_value, app_locale); 309 return form_group->SetInfo(type, trimmed_value, app_locale);
310 } 310 }
311 311
312 void AutofillProfile::GetSupportedTypes(
313 ServerFieldTypeSet* supported_types) const {
314 FormGroupList info = FormGroups();
315 for (const auto* form_group : info) {
316 form_group->GetSupportedTypes(supported_types);
317 }
318 }
319
312 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { 320 bool AutofillProfile::IsEmpty(const std::string& app_locale) const {
313 ServerFieldTypeSet types; 321 ServerFieldTypeSet types;
314 GetNonEmptyTypes(app_locale, &types); 322 GetNonEmptyTypes(app_locale, &types);
315 return types.empty(); 323 return types.empty();
316 } 324 }
317 325
318 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { 326 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const {
319 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY)); 327 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY));
320 base::string16 data = GetRawInfo(type); 328 base::string16 data = GetRawInfo(type);
321 if (data.empty()) 329 if (data.empty())
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 server_id_ = base::SHA1HashString(contents_utf8); 710 server_id_ = base::SHA1HashString(contents_utf8);
703 } 711 }
704 712
705 void AutofillProfile::RecordAndLogUse() { 713 void AutofillProfile::RecordAndLogUse() {
706 previous_use_date_ = use_date(); 714 previous_use_date_ = use_date();
707 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.Profile", 715 UMA_HISTOGRAM_COUNTS_1000("Autofill.DaysSinceLastUse.Profile",
708 (AutofillClock::Now() - use_date()).InDays()); 716 (AutofillClock::Now() - use_date()).InDays());
709 RecordUse(); 717 RecordUse();
710 } 718 }
711 719
712 void AutofillProfile::GetSupportedTypes(
713 ServerFieldTypeSet* supported_types) const {
714 FormGroupList info = FormGroups();
715 for (const auto* form_group : info) {
716 form_group->GetSupportedTypes(supported_types);
717 }
718 }
719
720 // static 720 // static
721 void AutofillProfile::CreateInferredLabelsHelper( 721 void AutofillProfile::CreateInferredLabelsHelper(
722 const std::vector<AutofillProfile*>& profiles, 722 const std::vector<AutofillProfile*>& profiles,
723 const std::list<size_t>& indices, 723 const std::list<size_t>& indices,
724 const std::vector<ServerFieldType>& fields, 724 const std::vector<ServerFieldType>& fields,
725 size_t num_fields_to_include, 725 size_t num_fields_to_include,
726 const std::string& app_locale, 726 const std::string& app_locale,
727 std::vector<base::string16>* labels) { 727 std::vector<base::string16>* labels) {
728 // For efficiency, we first construct a map of fields to their text values and 728 // For efficiency, we first construct a map of fields to their text values and
729 // each value's frequency. 729 // each value's frequency.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " " 860 << " " << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) << " "
861 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " " 861 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) << " "
862 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " " 862 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) << " "
863 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " " 863 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) << " "
864 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " " 864 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) << " "
865 << profile.language_code() << " " 865 << profile.language_code() << " "
866 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 866 << UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
867 } 867 }
868 868
869 } // namespace autofill 869 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698