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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <iosfwd> | 10 #include <iosfwd> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at | 152 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at |
153 // least |minimal_fields_shown| fields, if possible. | 153 // least |minimal_fields_shown| fields, if possible. |
154 static void CreateInferredLabels( | 154 static void CreateInferredLabels( |
155 const std::vector<AutofillProfile*>& profiles, | 155 const std::vector<AutofillProfile*>& profiles, |
156 const std::vector<ServerFieldType>* suggested_fields, | 156 const std::vector<ServerFieldType>* suggested_fields, |
157 ServerFieldType excluded_field, | 157 ServerFieldType excluded_field, |
158 size_t minimal_fields_shown, | 158 size_t minimal_fields_shown, |
159 const std::string& app_locale, | 159 const std::string& app_locale, |
160 std::vector<base::string16>* labels); | 160 std::vector<base::string16>* labels); |
161 | 161 |
| 162 // Builds inferred label from the first |num_fields_to_include| non-empty |
| 163 // fields in |label_fields|. Uses as many fields as possible if there are not |
| 164 // enough non-empty fields. |
| 165 base::string16 ConstructInferredLabel( |
| 166 const std::vector<ServerFieldType>& label_fields, |
| 167 size_t num_fields_to_include, |
| 168 const std::string& app_locale) const; |
| 169 |
162 const std::string& language_code() const { return language_code_; } | 170 const std::string& language_code() const { return language_code_; } |
163 void set_language_code(const std::string& language_code) { | 171 void set_language_code(const std::string& language_code) { |
164 language_code_ = language_code; | 172 language_code_ = language_code; |
165 } | 173 } |
166 | 174 |
167 // Nonempty only when type() == SERVER_PROFILE. base::kSHA1Length bytes long. | 175 // Nonempty only when type() == SERVER_PROFILE. base::kSHA1Length bytes long. |
168 // Not necessarily valid UTF-8. | 176 // Not necessarily valid UTF-8. |
169 const std::string& server_id() const { return server_id_; } | 177 const std::string& server_id() const { return server_id_; } |
170 | 178 |
171 // Creates an identifier and saves it as |server_id_|. Only used for | 179 // Creates an identifier and saves it as |server_id_|. Only used for |
(...skipping 14 matching lines...) Expand all Loading... |
186 // This string is designed for comparison purposes only and isn't suitable | 194 // This string is designed for comparison purposes only and isn't suitable |
187 // for storing or displaying to the user. | 195 // for storing or displaying to the user. |
188 static base::string16 CanonicalizeProfileString(const base::string16& str); | 196 static base::string16 CanonicalizeProfileString(const base::string16& str); |
189 | 197 |
190 private: | 198 private: |
191 typedef std::vector<const FormGroup*> FormGroupList; | 199 typedef std::vector<const FormGroup*> FormGroupList; |
192 | 200 |
193 // FormGroup: | 201 // FormGroup: |
194 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; | 202 void GetSupportedTypes(ServerFieldTypeSet* supported_types) const override; |
195 | 203 |
196 // Builds inferred label from the first |num_fields_to_include| non-empty | |
197 // fields in |label_fields|. Uses as many fields as possible if there are not | |
198 // enough non-empty fields. | |
199 base::string16 ConstructInferredLabel( | |
200 const std::vector<ServerFieldType>& label_fields, | |
201 size_t num_fields_to_include, | |
202 const std::string& app_locale) const; | |
203 | |
204 // Creates inferred labels for |profiles| at indices corresponding to | 204 // Creates inferred labels for |profiles| at indices corresponding to |
205 // |indices|, and stores the results to the corresponding elements of | 205 // |indices|, and stores the results to the corresponding elements of |
206 // |labels|. These labels include enough fields to differentiate among the | 206 // |labels|. These labels include enough fields to differentiate among the |
207 // profiles, if possible; and also at least |num_fields_to_include| fields, if | 207 // profiles, if possible; and also at least |num_fields_to_include| fields, if |
208 // possible. The label fields are drawn from |fields|. | 208 // possible. The label fields are drawn from |fields|. |
209 static void CreateInferredLabelsHelper( | 209 static void CreateInferredLabelsHelper( |
210 const std::vector<AutofillProfile*>& profiles, | 210 const std::vector<AutofillProfile*>& profiles, |
211 const std::list<size_t>& indices, | 211 const std::list<size_t>& indices, |
212 const std::vector<ServerFieldType>& fields, | 212 const std::vector<ServerFieldType>& fields, |
213 size_t num_fields_to_include, | 213 size_t num_fields_to_include, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // a hash of the contents. | 245 // a hash of the contents. |
246 std::string server_id_; | 246 std::string server_id_; |
247 }; | 247 }; |
248 | 248 |
249 // So we can compare AutofillProfiles with EXPECT_EQ(). | 249 // So we can compare AutofillProfiles with EXPECT_EQ(). |
250 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 250 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
251 | 251 |
252 } // namespace autofill | 252 } // namespace autofill |
253 | 253 |
254 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 254 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
OLD | NEW |