| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // Creates a differentiating label for each of the |profiles|. | 117 // Creates a differentiating label for each of the |profiles|. |
| 118 // Labels consist of the minimal differentiating combination of: | 118 // Labels consist of the minimal differentiating combination of: |
| 119 // 1. Full name. | 119 // 1. Full name. |
| 120 // 2. Address. | 120 // 2. Address. |
| 121 // 3. E-mail. | 121 // 3. E-mail. |
| 122 // 4. Phone. | 122 // 4. Phone. |
| 123 // 5. Company name. | 123 // 5. Company name. |
| 124 static void CreateDifferentiatingLabels( | 124 static void CreateDifferentiatingLabels( |
| 125 const std::vector<AutofillProfile*>& profiles, | 125 const std::vector<AutofillProfile*>& profiles, |
| 126 const std::string& app_locale, |
| 126 std::vector<base::string16>* labels); | 127 std::vector<base::string16>* labels); |
| 127 | 128 |
| 128 // Creates inferred labels for |profiles|, according to the rules above and | 129 // Creates inferred labels for |profiles|, according to the rules above and |
| 129 // stores them in |created_labels|. If |suggested_fields| is not NULL, the | 130 // stores them in |created_labels|. If |suggested_fields| is not NULL, the |
| 130 // resulting label fields are drawn from |suggested_fields|, except excluding | 131 // resulting label fields are drawn from |suggested_fields|, except excluding |
| 131 // |excluded_field|. Otherwise, the label fields are drawn from a default set, | 132 // |excluded_field|. Otherwise, the label fields are drawn from a default set, |
| 132 // and |excluded_field| is ignored; by convention, it should be of | 133 // and |excluded_field| is ignored; by convention, it should be of |
| 133 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at | 134 // |UNKNOWN_TYPE| when |suggested_fields| is NULL. Each label includes at |
| 134 // least |minimal_fields_shown| fields, if possible. | 135 // least |minimal_fields_shown| fields, if possible. |
| 135 static void CreateInferredLabels( | 136 static void CreateInferredLabels( |
| 136 const std::vector<AutofillProfile*>& profiles, | 137 const std::vector<AutofillProfile*>& profiles, |
| 137 const std::vector<ServerFieldType>* suggested_fields, | 138 const std::vector<ServerFieldType>* suggested_fields, |
| 138 ServerFieldType excluded_field, | 139 ServerFieldType excluded_field, |
| 139 size_t minimal_fields_shown, | 140 size_t minimal_fields_shown, |
| 141 const std::string& app_locale, |
| 140 std::vector<base::string16>* labels); | 142 std::vector<base::string16>* labels); |
| 141 | 143 |
| 142 const std::string& language_code() const { return language_code_; } | 144 const std::string& language_code() const { return language_code_; } |
| 143 void set_language_code(const std::string& language_code) { | 145 void set_language_code(const std::string& language_code) { |
| 144 language_code_ = language_code; | 146 language_code_ = language_code; |
| 145 } | 147 } |
| 146 | 148 |
| 147 private: | 149 private: |
| 148 typedef std::vector<const FormGroup*> FormGroupList; | 150 typedef std::vector<const FormGroup*> FormGroupList; |
| 149 | 151 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 164 // Adds the |phone| to the |existing_phones| if not already there. | 166 // Adds the |phone| to the |existing_phones| if not already there. |
| 165 void AddPhoneIfUnique(const base::string16& phone, | 167 void AddPhoneIfUnique(const base::string16& phone, |
| 166 const std::string& app_locale, | 168 const std::string& app_locale, |
| 167 std::vector<base::string16>* existing_phones); | 169 std::vector<base::string16>* existing_phones); |
| 168 | 170 |
| 169 // Builds inferred label from the first |num_fields_to_include| non-empty | 171 // Builds inferred label from the first |num_fields_to_include| non-empty |
| 170 // fields in |label_fields|. Uses as many fields as possible if there are not | 172 // fields in |label_fields|. Uses as many fields as possible if there are not |
| 171 // enough non-empty fields. | 173 // enough non-empty fields. |
| 172 base::string16 ConstructInferredLabel( | 174 base::string16 ConstructInferredLabel( |
| 173 const std::vector<ServerFieldType>& label_fields, | 175 const std::vector<ServerFieldType>& label_fields, |
| 174 size_t num_fields_to_include) const; | 176 size_t num_fields_to_include, |
| 177 const std::string& app_locale) const; |
| 175 | 178 |
| 176 // Creates inferred labels for |profiles| at indices corresponding to | 179 // Creates inferred labels for |profiles| at indices corresponding to |
| 177 // |indices|, and stores the results to the corresponding elements of | 180 // |indices|, and stores the results to the corresponding elements of |
| 178 // |labels|. These labels include enough fields to differentiate among the | 181 // |labels|. These labels include enough fields to differentiate among the |
| 179 // profiles, if possible; and also at least |num_fields_to_include| fields, if | 182 // profiles, if possible; and also at least |num_fields_to_include| fields, if |
| 180 // possible. The label fields are drawn from |fields|. | 183 // possible. The label fields are drawn from |fields|. |
| 181 static void CreateInferredLabelsHelper( | 184 static void CreateInferredLabelsHelper( |
| 182 const std::vector<AutofillProfile*>& profiles, | 185 const std::vector<AutofillProfile*>& profiles, |
| 183 const std::list<size_t>& indices, | 186 const std::list<size_t>& indices, |
| 184 const std::vector<ServerFieldType>& fields, | 187 const std::vector<ServerFieldType>& fields, |
| 185 size_t num_fields_to_include, | 188 size_t num_fields_to_include, |
| 189 const std::string& app_locale, |
| 186 std::vector<base::string16>* labels); | 190 std::vector<base::string16>* labels); |
| 187 | 191 |
| 188 // Utilities for listing and lookup of the data members that constitute | 192 // Utilities for listing and lookup of the data members that constitute |
| 189 // user-visible profile information. | 193 // user-visible profile information. |
| 190 FormGroupList FormGroups() const; | 194 FormGroupList FormGroups() const; |
| 191 const FormGroup* FormGroupForType(const AutofillType& type) const; | 195 const FormGroup* FormGroupForType(const AutofillType& type) const; |
| 192 FormGroup* MutableFormGroupForType(const AutofillType& type); | 196 FormGroup* MutableFormGroupForType(const AutofillType& type); |
| 193 | 197 |
| 194 // Appends unique names from |names| onto the |name_| list, dropping | 198 // Appends unique names from |names| onto the |name_| list, dropping |
| 195 // duplicates. If a name in |names| has the same full name representation | 199 // duplicates. If a name in |names| has the same full name representation |
| (...skipping 11 matching lines...) Expand all Loading... |
| 207 // The BCP 47 language code that can be used to format |address_| for display. | 211 // The BCP 47 language code that can be used to format |address_| for display. |
| 208 std::string language_code_; | 212 std::string language_code_; |
| 209 }; | 213 }; |
| 210 | 214 |
| 211 // So we can compare AutofillProfiles with EXPECT_EQ(). | 215 // So we can compare AutofillProfiles with EXPECT_EQ(). |
| 212 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); | 216 std::ostream& operator<<(std::ostream& os, const AutofillProfile& profile); |
| 213 | 217 |
| 214 } // namespace autofill | 218 } // namespace autofill |
| 215 | 219 |
| 216 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ | 220 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_PROFILE_H_ |
| OLD | NEW |