OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 6 #define CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <list> | 10 #include <list> |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Equality operators compare GUIDs and the contents in the comparison. | 112 // Equality operators compare GUIDs and the contents in the comparison. |
113 // TODO(dhollowa): This needs to be made multi-profile once Sync updates. | 113 // TODO(dhollowa): This needs to be made multi-profile once Sync updates. |
114 bool operator==(const AutofillProfile& profile) const; | 114 bool operator==(const AutofillProfile& profile) const; |
115 virtual bool operator!=(const AutofillProfile& profile) const; | 115 virtual bool operator!=(const AutofillProfile& profile) const; |
116 | 116 |
117 // Returns concatenation of full name and address line 1. This acts as the | 117 // Returns concatenation of full name and address line 1. This acts as the |
118 // basis of comparison for new values that are submitted through forms to | 118 // basis of comparison for new values that are submitted through forms to |
119 // aid with correct aggregation of new data. | 119 // aid with correct aggregation of new data. |
120 const string16 PrimaryValue() const; | 120 const string16 PrimaryValue() const; |
121 | 121 |
| 122 // Normalizes the home phone and fax numbers. |
| 123 // Should be called after all of the form data is imported into profile. |
| 124 // Drops unparsable numbers, so the numbers that are incomplete or wrong |
| 125 // are not saved. Returns true if all numbers were successfully parsed, |
| 126 // false otherwise. |
| 127 bool NormalizePhones(); |
| 128 |
122 // Overwrites the single-valued field data in |profile| with this | 129 // Overwrites the single-valued field data in |profile| with this |
123 // Profile. Or, for multi-valued fields append the new values. | 130 // Profile. Or, for multi-valued fields append the new values. |
124 void OverwriteWithOrAddTo(const AutofillProfile& profile); | 131 void OverwriteWithOrAddTo(const AutofillProfile& profile); |
125 | 132 |
126 private: | 133 private: |
127 typedef std::vector<const FormGroup*> FormGroupList; | 134 typedef std::vector<const FormGroup*> FormGroupList; |
128 | 135 |
| 136 // Checks if the |phone| is in the |existing_phones| using fuzzy matching: |
| 137 // for example, "1-800-FLOWERS", "18003569377", "(800)356-9377" and "356-9377" |
| 138 // are considered the same. |
| 139 // Adds the |phone| to the |existing_phones| if not already there. |
| 140 void AddPhoneIfUnique(const string16& phone, |
| 141 std::vector<string16>* existing_phones); |
| 142 |
129 // Builds inferred label from the first |num_fields_to_include| non-empty | 143 // Builds inferred label from the first |num_fields_to_include| non-empty |
130 // fields in |label_fields|. Uses as many fields as possible if there are not | 144 // fields in |label_fields|. Uses as many fields as possible if there are not |
131 // enough non-empty fields. | 145 // enough non-empty fields. |
132 string16 ConstructInferredLabel( | 146 string16 ConstructInferredLabel( |
133 const std::vector<AutofillFieldType>& label_fields, | 147 const std::vector<AutofillFieldType>& label_fields, |
134 size_t num_fields_to_include) const; | 148 size_t num_fields_to_include) const; |
135 | 149 |
136 // Creates inferred labels for |profiles| at indices corresponding to | 150 // Creates inferred labels for |profiles| at indices corresponding to |
137 // |indices|, and stores the results to the corresponding elements of | 151 // |indices|, and stores the results to the corresponding elements of |
138 // |created_labels|. These labels include enough fields to differentiate among | 152 // |created_labels|. These labels include enough fields to differentiate among |
(...skipping 15 matching lines...) Expand all Loading... |
154 // The label presented to the user when selecting a profile. | 168 // The label presented to the user when selecting a profile. |
155 string16 label_; | 169 string16 label_; |
156 | 170 |
157 // The guid of this profile. | 171 // The guid of this profile. |
158 std::string guid_; | 172 std::string guid_; |
159 | 173 |
160 // Personal information for this profile. | 174 // Personal information for this profile. |
161 std::vector<NameInfo> name_; | 175 std::vector<NameInfo> name_; |
162 std::vector<EmailInfo> email_; | 176 std::vector<EmailInfo> email_; |
163 CompanyInfo company_; | 177 CompanyInfo company_; |
164 std::vector<HomePhoneNumber> home_number_; | 178 std::vector<PhoneNumber> home_number_; |
165 std::vector<FaxNumber> fax_number_; | 179 std::vector<PhoneNumber> fax_number_; |
166 Address address_; | 180 Address address_; |
167 }; | 181 }; |
168 | 182 |
169 // So we can compare AutofillProfiles with EXPECT_EQ(). | 183 // So we can compare AutofillProfiles with EXPECT_EQ(). |
170 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 184 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
171 | 185 |
172 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ | 186 #endif // CHROME_BROWSER_AUTOFILL_AUTOFILL_PROFILE_H_ |
OLD | NEW |