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

Side by Side Diff: chrome/browser/autofill/personal_data_manager.cc

Issue 11360055: [Autofill] Rename GetInfo and SetInfo to GetRawInfo and SetRawInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase harder Created 8 years, 1 month 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/autofill/personal_data_manager.h" 5 #include "chrome/browser/autofill/personal_data_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Basic US zip code matching. 86 // Basic US zip code matching.
87 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$"); 87 const string16 kZipPattern = ASCIIToUTF16("^\\d{5}(-\\d{4})?$");
88 return autofill::MatchesPattern(value, kZipPattern); 88 return autofill::MatchesPattern(value, kZipPattern);
89 } 89 }
90 90
91 // Returns true if minimum requirements for import of a given |profile| have 91 // Returns true if minimum requirements for import of a given |profile| have
92 // been met. An address submitted via a form must have at least these fields 92 // been met. An address submitted via a form must have at least these fields
93 // filled. No verification of validity of the contents is preformed. This is 93 // filled. No verification of validity of the contents is preformed. This is
94 // and existence check only. 94 // and existence check only.
95 bool IsMinimumAddress(const AutofillProfile& profile) { 95 bool IsMinimumAddress(const AutofillProfile& profile) {
96 return !profile.GetInfo(ADDRESS_HOME_LINE1).empty() && 96 return !profile.GetRawInfo(ADDRESS_HOME_LINE1).empty() &&
97 !profile.GetInfo(ADDRESS_HOME_CITY).empty() && 97 !profile.GetRawInfo(ADDRESS_HOME_CITY).empty() &&
98 !profile.GetInfo(ADDRESS_HOME_STATE).empty() && 98 !profile.GetRawInfo(ADDRESS_HOME_STATE).empty() &&
99 !profile.GetInfo(ADDRESS_HOME_ZIP).empty(); 99 !profile.GetRawInfo(ADDRESS_HOME_ZIP).empty();
100 } 100 }
101 101
102 // Return true if the |field_type| and |value| are valid within the context 102 // Return true if the |field_type| and |value| are valid within the context
103 // of importing a form. 103 // of importing a form.
104 bool IsValidFieldTypeAndValue(const std::set<AutofillFieldType>& types_seen, 104 bool IsValidFieldTypeAndValue(const std::set<AutofillFieldType>& types_seen,
105 AutofillFieldType field_type, 105 AutofillFieldType field_type,
106 const string16& value) { 106 const string16& value) {
107 // Abandon the import if two fields of the same type are encountered. 107 // Abandon the import if two fields of the same type are encountered.
108 // This indicates ambiguous data or miscategorization of types. 108 // This indicates ambiguous data or miscategorization of types.
109 // Make an exception for PHONE_HOME_NUMBER however as both prefix and 109 // Make an exception for PHONE_HOME_NUMBER however as both prefix and
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return PrefServiceBase::FromBrowserContext(browser_context_)->GetBoolean( 589 return PrefServiceBase::FromBrowserContext(browser_context_)->GetBoolean(
590 prefs::kAutofillEnabled); 590 prefs::kAutofillEnabled);
591 } 591 }
592 592
593 // static 593 // static
594 bool PersonalDataManager::IsValidLearnableProfile( 594 bool PersonalDataManager::IsValidLearnableProfile(
595 const AutofillProfile& profile) { 595 const AutofillProfile& profile) {
596 if (!IsMinimumAddress(profile)) 596 if (!IsMinimumAddress(profile))
597 return false; 597 return false;
598 598
599 string16 email = profile.GetInfo(EMAIL_ADDRESS); 599 string16 email = profile.GetRawInfo(EMAIL_ADDRESS);
600 if (!email.empty() && !IsValidEmail(email)) 600 if (!email.empty() && !IsValidEmail(email))
601 return false; 601 return false;
602 602
603 // Reject profiles with invalid US state information. 603 // Reject profiles with invalid US state information.
604 string16 state = profile.GetInfo(ADDRESS_HOME_STATE); 604 string16 state = profile.GetRawInfo(ADDRESS_HOME_STATE);
605 if (profile.CountryCode() == "US" && 605 if (profile.CountryCode() == "US" &&
606 !state.empty() && !autofill::IsValidState(state)) { 606 !state.empty() && !autofill::IsValidState(state)) {
607 return false; 607 return false;
608 } 608 }
609 609
610 // Reject profiles with invalid US zip information. 610 // Reject profiles with invalid US zip information.
611 string16 zip = profile.GetInfo(ADDRESS_HOME_ZIP); 611 string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP);
612 if (profile.CountryCode() == "US" && !zip.empty() && !IsValidZip(zip)) 612 if (profile.CountryCode() == "US" && !zip.empty() && !IsValidZip(zip))
613 return false; 613 return false;
614 614
615 return true; 615 return true;
616 } 616 }
617 617
618 // static 618 // static
619 bool PersonalDataManager::MergeProfile( 619 bool PersonalDataManager::MergeProfile(
620 const AutofillProfile& profile, 620 const AutofillProfile& profile,
621 const std::vector<AutofillProfile*>& existing_profiles, 621 const std::vector<AutofillProfile*>& existing_profiles,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 933 }
934 934
935 const AutofillMetrics* PersonalDataManager::metric_logger() const { 935 const AutofillMetrics* PersonalDataManager::metric_logger() const {
936 return metric_logger_.get(); 936 return metric_logger_.get();
937 } 937 }
938 938
939 void PersonalDataManager::set_metric_logger( 939 void PersonalDataManager::set_metric_logger(
940 const AutofillMetrics* metric_logger) { 940 const AutofillMetrics* metric_logger) {
941 metric_logger_.reset(metric_logger); 941 metric_logger_.reset(metric_logger);
942 } 942 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/form_group.cc ('k') | chrome/browser/autofill/personal_data_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698