| OLD | NEW |
| 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 "components/autofill/browser/autofill_profile.h" | 5 #include "components/autofill/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 <ostream> | 10 #include <ostream> |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 GetEquivalentFieldTypeCollapsingNames(*it) == NAME_FULL) { | 100 GetEquivalentFieldTypeCollapsingNames(*it) == NAME_FULL) { |
| 101 distinguishing_fields->push_back(NAME_FULL); | 101 distinguishing_fields->push_back(NAME_FULL); |
| 102 break; | 102 break; |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 // A helper function for string streaming. Concatenates multi-valued entries | 108 // A helper function for string streaming. Concatenates multi-valued entries |
| 109 // stored for a given |type| into a single string. This string is returned. | 109 // stored for a given |type| into a single string. This string is returned. |
| 110 const string16 MultiString(const AutofillProfile& p, AutofillFieldType type) { | 110 const base::string16 MultiString(const AutofillProfile& p, |
| 111 std::vector<string16> values; | 111 AutofillFieldType type) { |
| 112 std::vector<base::string16> values; |
| 112 p.GetRawMultiInfo(type, &values); | 113 p.GetRawMultiInfo(type, &values); |
| 113 string16 accumulate; | 114 base::string16 accumulate; |
| 114 for (size_t i = 0; i < values.size(); ++i) { | 115 for (size_t i = 0; i < values.size(); ++i) { |
| 115 if (i > 0) | 116 if (i > 0) |
| 116 accumulate += ASCIIToUTF16(" "); | 117 accumulate += ASCIIToUTF16(" "); |
| 117 accumulate += values[i]; | 118 accumulate += values[i]; |
| 118 } | 119 } |
| 119 return accumulate; | 120 return accumulate; |
| 120 } | 121 } |
| 121 | 122 |
| 122 string16 GetFormGroupInfo(const FormGroup& form_group, | 123 base::string16 GetFormGroupInfo(const FormGroup& form_group, |
| 123 AutofillFieldType type, | 124 AutofillFieldType type, |
| 124 const std::string& app_locale) { | 125 const std::string& app_locale) { |
| 125 return app_locale.empty() ? | 126 return app_locale.empty() ? |
| 126 form_group.GetRawInfo(type) : | 127 form_group.GetRawInfo(type) : |
| 127 form_group.GetInfo(type, app_locale); | 128 form_group.GetInfo(type, app_locale); |
| 128 } | 129 } |
| 129 | 130 |
| 130 template <class T> | 131 template <class T> |
| 131 void CopyValuesToItems(AutofillFieldType type, | 132 void CopyValuesToItems(AutofillFieldType type, |
| 132 const std::vector<string16>& values, | 133 const std::vector<base::string16>& values, |
| 133 std::vector<T>* form_group_items, | 134 std::vector<T>* form_group_items, |
| 134 const T& prototype) { | 135 const T& prototype) { |
| 135 form_group_items->resize(values.size(), prototype); | 136 form_group_items->resize(values.size(), prototype); |
| 136 for (size_t i = 0; i < form_group_items->size(); ++i) { | 137 for (size_t i = 0; i < form_group_items->size(); ++i) { |
| 137 (*form_group_items)[i].SetRawInfo(type, | 138 (*form_group_items)[i].SetRawInfo(type, |
| 138 CollapseWhitespace(values[i], false)); | 139 CollapseWhitespace(values[i], false)); |
| 139 } | 140 } |
| 140 // Must have at least one (possibly empty) element. | 141 // Must have at least one (possibly empty) element. |
| 141 if (form_group_items->empty()) | 142 if (form_group_items->empty()) |
| 142 form_group_items->resize(1, prototype); | 143 form_group_items->resize(1, prototype); |
| 143 } | 144 } |
| 144 | 145 |
| 145 template <class T> | 146 template <class T> |
| 146 void CopyItemsToValues(AutofillFieldType type, | 147 void CopyItemsToValues(AutofillFieldType type, |
| 147 const std::vector<T>& form_group_items, | 148 const std::vector<T>& form_group_items, |
| 148 const std::string& app_locale, | 149 const std::string& app_locale, |
| 149 std::vector<string16>* values) { | 150 std::vector<base::string16>* values) { |
| 150 values->resize(form_group_items.size()); | 151 values->resize(form_group_items.size()); |
| 151 for (size_t i = 0; i < values->size(); ++i) { | 152 for (size_t i = 0; i < values->size(); ++i) { |
| 152 (*values)[i] = GetFormGroupInfo(form_group_items[i], type, app_locale); | 153 (*values)[i] = GetFormGroupInfo(form_group_items[i], type, app_locale); |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 // Collapse compound field types to their "full" type. I.e. First name | 157 // Collapse compound field types to their "full" type. I.e. First name |
| 157 // collapses to full name, area code collapses to full phone, etc. | 158 // collapses to full name, area code collapses to full phone, etc. |
| 158 void CollapseCompoundFieldTypes(FieldTypeSet* type_set) { | 159 void CollapseCompoundFieldTypes(FieldTypeSet* type_set) { |
| 159 FieldTypeSet collapsed_set; | 160 FieldTypeSet collapsed_set; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 179 | 180 |
| 180 default: | 181 default: |
| 181 collapsed_set.insert(*iter); | 182 collapsed_set.insert(*iter); |
| 182 } | 183 } |
| 183 } | 184 } |
| 184 std::swap(*type_set, collapsed_set); | 185 std::swap(*type_set, collapsed_set); |
| 185 } | 186 } |
| 186 | 187 |
| 187 class FindByPhone { | 188 class FindByPhone { |
| 188 public: | 189 public: |
| 189 FindByPhone(const string16& phone, | 190 FindByPhone(const base::string16& phone, |
| 190 const std::string& country_code, | 191 const std::string& country_code, |
| 191 const std::string& app_locale) | 192 const std::string& app_locale) |
| 192 : phone_(phone), | 193 : phone_(phone), |
| 193 country_code_(country_code), | 194 country_code_(country_code), |
| 194 app_locale_(app_locale) { | 195 app_locale_(app_locale) { |
| 195 } | 196 } |
| 196 | 197 |
| 197 bool operator()(const string16& phone) { | 198 bool operator()(const base::string16& phone) { |
| 198 return autofill_i18n::PhoneNumbersMatch( | 199 return autofill_i18n::PhoneNumbersMatch( |
| 199 phone, phone_, country_code_, app_locale_); | 200 phone, phone_, country_code_, app_locale_); |
| 200 } | 201 } |
| 201 | 202 |
| 202 bool operator()(const string16* phone) { | 203 bool operator()(const base::string16* phone) { |
| 203 return autofill_i18n::PhoneNumbersMatch( | 204 return autofill_i18n::PhoneNumbersMatch( |
| 204 *phone, phone_, country_code_, app_locale_); | 205 *phone, phone_, country_code_, app_locale_); |
| 205 } | 206 } |
| 206 | 207 |
| 207 private: | 208 private: |
| 208 string16 phone_; | 209 base::string16 phone_; |
| 209 std::string country_code_; | 210 std::string country_code_; |
| 210 std::string app_locale_; | 211 std::string app_locale_; |
| 211 }; | 212 }; |
| 212 | 213 |
| 213 // Functor used to check for case-insensitive equality of two strings. | 214 // Functor used to check for case-insensitive equality of two strings. |
| 214 struct CaseInsensitiveStringEquals | 215 struct CaseInsensitiveStringEquals |
| 215 : public std::binary_function<string16, string16, bool> | 216 : public std::binary_function<base::string16, base::string16, bool> |
| 216 { | 217 { |
| 217 bool operator()(const string16& x, const string16& y) const { | 218 bool operator()(const base::string16& x, const base::string16& y) const { |
| 218 return | 219 return |
| 219 x.size() == y.size() && StringToLowerASCII(x) == StringToLowerASCII(y); | 220 x.size() == y.size() && StringToLowerASCII(x) == StringToLowerASCII(y); |
| 220 } | 221 } |
| 221 }; | 222 }; |
| 222 | 223 |
| 223 } // namespace | 224 } // namespace |
| 224 | 225 |
| 225 AutofillProfile::AutofillProfile(const std::string& guid) | 226 AutofillProfile::AutofillProfile(const std::string& guid) |
| 226 : guid_(guid), | 227 : guid_(guid), |
| 227 name_(1), | 228 name_(1), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 | 262 |
| 262 address_ = profile.address_; | 263 address_ = profile.address_; |
| 263 | 264 |
| 264 return *this; | 265 return *this; |
| 265 } | 266 } |
| 266 | 267 |
| 267 std::string AutofillProfile::GetGUID() const { | 268 std::string AutofillProfile::GetGUID() const { |
| 268 return guid(); | 269 return guid(); |
| 269 } | 270 } |
| 270 | 271 |
| 271 void AutofillProfile::GetMatchingTypes(const string16& text, | 272 void AutofillProfile::GetMatchingTypes(const base::string16& text, |
| 272 const std::string& app_locale, | 273 const std::string& app_locale, |
| 273 FieldTypeSet* matching_types) const { | 274 FieldTypeSet* matching_types) const { |
| 274 FormGroupList info = FormGroups(); | 275 FormGroupList info = FormGroups(); |
| 275 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) | 276 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) |
| 276 (*it)->GetMatchingTypes(text, app_locale, matching_types); | 277 (*it)->GetMatchingTypes(text, app_locale, matching_types); |
| 277 } | 278 } |
| 278 | 279 |
| 279 string16 AutofillProfile::GetRawInfo(AutofillFieldType type) const { | 280 base::string16 AutofillProfile::GetRawInfo(AutofillFieldType type) const { |
| 280 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); | 281 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); |
| 281 const FormGroup* form_group = FormGroupForType(return_type); | 282 const FormGroup* form_group = FormGroupForType(return_type); |
| 282 if (!form_group) | 283 if (!form_group) |
| 283 return string16(); | 284 return base::string16(); |
| 284 | 285 |
| 285 return form_group->GetRawInfo(return_type); | 286 return form_group->GetRawInfo(return_type); |
| 286 } | 287 } |
| 287 | 288 |
| 288 void AutofillProfile::SetRawInfo(AutofillFieldType type, | 289 void AutofillProfile::SetRawInfo(AutofillFieldType type, |
| 289 const string16& value) { | 290 const base::string16& value) { |
| 290 FormGroup* form_group = MutableFormGroupForType(type); | 291 FormGroup* form_group = MutableFormGroupForType(type); |
| 291 if (form_group) | 292 if (form_group) |
| 292 form_group->SetRawInfo(type, CollapseWhitespace(value, false)); | 293 form_group->SetRawInfo(type, CollapseWhitespace(value, false)); |
| 293 } | 294 } |
| 294 | 295 |
| 295 string16 AutofillProfile::GetInfo(AutofillFieldType type, | 296 base::string16 AutofillProfile::GetInfo(AutofillFieldType type, |
| 296 const std::string& app_locale) const { | 297 const std::string& app_locale) const { |
| 297 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); | 298 AutofillFieldType return_type = AutofillType::GetEquivalentFieldType(type); |
| 298 const FormGroup* form_group = FormGroupForType(return_type); | 299 const FormGroup* form_group = FormGroupForType(return_type); |
| 299 if (!form_group) | 300 if (!form_group) |
| 300 return string16(); | 301 return base::string16(); |
| 301 | 302 |
| 302 return form_group->GetInfo(return_type, app_locale); | 303 return form_group->GetInfo(return_type, app_locale); |
| 303 } | 304 } |
| 304 | 305 |
| 305 bool AutofillProfile::SetInfo(AutofillFieldType type, | 306 bool AutofillProfile::SetInfo(AutofillFieldType type, |
| 306 const string16& value, | 307 const base::string16& value, |
| 307 const std::string& app_locale) { | 308 const std::string& app_locale) { |
| 308 FormGroup* form_group = MutableFormGroupForType(type); | 309 FormGroup* form_group = MutableFormGroupForType(type); |
| 309 if (!form_group) | 310 if (!form_group) |
| 310 return false; | 311 return false; |
| 311 | 312 |
| 312 return | 313 return |
| 313 form_group->SetInfo(type, CollapseWhitespace(value, false), app_locale); | 314 form_group->SetInfo(type, CollapseWhitespace(value, false), app_locale); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void AutofillProfile::SetRawMultiInfo(AutofillFieldType type, | 317 void AutofillProfile::SetRawMultiInfo( |
| 317 const std::vector<string16>& values) { | 318 AutofillFieldType type, |
| 319 const std::vector<base::string16>& values) { |
| 318 switch (AutofillType(type).group()) { | 320 switch (AutofillType(type).group()) { |
| 319 case AutofillType::NAME: | 321 case AutofillType::NAME: |
| 320 CopyValuesToItems(type, values, &name_, NameInfo()); | 322 CopyValuesToItems(type, values, &name_, NameInfo()); |
| 321 break; | 323 break; |
| 322 case AutofillType::EMAIL: | 324 case AutofillType::EMAIL: |
| 323 CopyValuesToItems(type, values, &email_, EmailInfo()); | 325 CopyValuesToItems(type, values, &email_, EmailInfo()); |
| 324 break; | 326 break; |
| 325 case AutofillType::PHONE: | 327 case AutofillType::PHONE: |
| 326 CopyValuesToItems(type, | 328 CopyValuesToItems(type, |
| 327 values, | 329 values, |
| 328 &home_number_, | 330 &home_number_, |
| 329 PhoneNumber(this)); | 331 PhoneNumber(this)); |
| 330 break; | 332 break; |
| 331 default: | 333 default: |
| 332 if (values.size() == 1) { | 334 if (values.size() == 1) { |
| 333 SetRawInfo(type, values[0]); | 335 SetRawInfo(type, values[0]); |
| 334 } else if (values.size() == 0) { | 336 } else if (values.size() == 0) { |
| 335 SetRawInfo(type, string16()); | 337 SetRawInfo(type, base::string16()); |
| 336 } else { | 338 } else { |
| 337 // Shouldn't attempt to set multiple values on single-valued field. | 339 // Shouldn't attempt to set multiple values on single-valued field. |
| 338 NOTREACHED(); | 340 NOTREACHED(); |
| 339 } | 341 } |
| 340 break; | 342 break; |
| 341 } | 343 } |
| 342 } | 344 } |
| 343 | 345 |
| 344 void AutofillProfile::GetRawMultiInfo(AutofillFieldType type, | 346 void AutofillProfile::GetRawMultiInfo( |
| 345 std::vector<string16>* values) const { | 347 AutofillFieldType type, |
| 348 std::vector<base::string16>* values) const { |
| 346 GetMultiInfoImpl(type, std::string(), values); | 349 GetMultiInfoImpl(type, std::string(), values); |
| 347 } | 350 } |
| 348 | 351 |
| 349 void AutofillProfile::GetMultiInfo(AutofillFieldType type, | 352 void AutofillProfile::GetMultiInfo(AutofillFieldType type, |
| 350 const std::string& app_locale, | 353 const std::string& app_locale, |
| 351 std::vector<string16>* values) const { | 354 std::vector<base::string16>* values) const { |
| 352 GetMultiInfoImpl(type, app_locale, values); | 355 GetMultiInfoImpl(type, app_locale, values); |
| 353 } | 356 } |
| 354 | 357 |
| 355 void AutofillProfile::FillFormField(const AutofillField& field, | 358 void AutofillProfile::FillFormField(const AutofillField& field, |
| 356 size_t variant, | 359 size_t variant, |
| 357 const std::string& app_locale, | 360 const std::string& app_locale, |
| 358 FormFieldData* field_data) const { | 361 FormFieldData* field_data) const { |
| 359 AutofillFieldType type = field.type(); | 362 AutofillFieldType type = field.type(); |
| 360 DCHECK_NE(AutofillType::CREDIT_CARD, AutofillType(type).group()); | 363 DCHECK_NE(AutofillType::CREDIT_CARD, AutofillType(type).group()); |
| 361 DCHECK(field_data); | 364 DCHECK(field_data); |
| 362 | 365 |
| 363 if (type == PHONE_HOME_NUMBER) { | 366 if (type == PHONE_HOME_NUMBER) { |
| 364 FillPhoneNumberField(field, variant, app_locale, field_data); | 367 FillPhoneNumberField(field, variant, app_locale, field_data); |
| 365 } else if (field_data->form_control_type == "select-one") { | 368 } else if (field_data->form_control_type == "select-one") { |
| 366 FillSelectControl(type, app_locale, field_data); | 369 FillSelectControl(type, app_locale, field_data); |
| 367 } else { | 370 } else { |
| 368 std::vector<string16> values; | 371 std::vector<base::string16> values; |
| 369 GetMultiInfo(type, app_locale, &values); | 372 GetMultiInfo(type, app_locale, &values); |
| 370 if (variant >= values.size()) { | 373 if (variant >= values.size()) { |
| 371 // If the variant is unavailable, bail. This case is reachable, for | 374 // If the variant is unavailable, bail. This case is reachable, for |
| 372 // example if Sync updates a profile during the filling process. | 375 // example if Sync updates a profile during the filling process. |
| 373 return; | 376 return; |
| 374 } | 377 } |
| 375 | 378 |
| 376 field_data->value = values[variant]; | 379 field_data->value = values[variant]; |
| 377 } | 380 } |
| 378 } | 381 } |
| 379 | 382 |
| 380 void AutofillProfile::FillPhoneNumberField(const AutofillField& field, | 383 void AutofillProfile::FillPhoneNumberField(const AutofillField& field, |
| 381 size_t variant, | 384 size_t variant, |
| 382 const std::string& app_locale, | 385 const std::string& app_locale, |
| 383 FormFieldData* field_data) const { | 386 FormFieldData* field_data) const { |
| 384 std::vector<string16> values; | 387 std::vector<base::string16> values; |
| 385 GetMultiInfo(field.type(), app_locale, &values); | 388 GetMultiInfo(field.type(), app_locale, &values); |
| 386 DCHECK(variant < values.size()); | 389 DCHECK(variant < values.size()); |
| 387 | 390 |
| 388 // If we are filling a phone number, check to see if the size field | 391 // If we are filling a phone number, check to see if the size field |
| 389 // matches the "prefix" or "suffix" sizes and fill accordingly. | 392 // matches the "prefix" or "suffix" sizes and fill accordingly. |
| 390 string16 number = values[variant]; | 393 base::string16 number = values[variant]; |
| 391 if (number.length() == | 394 if (number.length() == |
| 392 PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { | 395 PhoneNumber::kPrefixLength + PhoneNumber::kSuffixLength) { |
| 393 if (field.phone_part() == AutofillField::PHONE_PREFIX || | 396 if (field.phone_part() == AutofillField::PHONE_PREFIX || |
| 394 field_data->max_length == PhoneNumber::kPrefixLength) { | 397 field_data->max_length == PhoneNumber::kPrefixLength) { |
| 395 number = number.substr(PhoneNumber::kPrefixOffset, | 398 number = number.substr(PhoneNumber::kPrefixOffset, |
| 396 PhoneNumber::kPrefixLength); | 399 PhoneNumber::kPrefixLength); |
| 397 } else if (field.phone_part() == AutofillField::PHONE_SUFFIX || | 400 } else if (field.phone_part() == AutofillField::PHONE_SUFFIX || |
| 398 field_data->max_length == PhoneNumber::kSuffixLength) { | 401 field_data->max_length == PhoneNumber::kSuffixLength) { |
| 399 number = number.substr(PhoneNumber::kSuffixOffset, | 402 number = number.substr(PhoneNumber::kSuffixOffset, |
| 400 PhoneNumber::kSuffixLength); | 403 PhoneNumber::kSuffixLength); |
| 401 } | 404 } |
| 402 } | 405 } |
| 403 | 406 |
| 404 field_data->value = number; | 407 field_data->value = number; |
| 405 } | 408 } |
| 406 | 409 |
| 407 const string16 AutofillProfile::Label() const { | 410 const base::string16 AutofillProfile::Label() const { |
| 408 return label_; | 411 return label_; |
| 409 } | 412 } |
| 410 | 413 |
| 411 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { | 414 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { |
| 412 FieldTypeSet types; | 415 FieldTypeSet types; |
| 413 GetNonEmptyTypes(app_locale, &types); | 416 GetNonEmptyTypes(app_locale, &types); |
| 414 return types.empty(); | 417 return types.empty(); |
| 415 } | 418 } |
| 416 | 419 |
| 417 int AutofillProfile::Compare(const AutofillProfile& profile) const { | 420 int AutofillProfile::Compare(const AutofillProfile& profile) const { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 430 return comparison; | 433 return comparison; |
| 431 } | 434 } |
| 432 | 435 |
| 433 const AutofillFieldType multi_value_types[] = { NAME_FIRST, | 436 const AutofillFieldType multi_value_types[] = { NAME_FIRST, |
| 434 NAME_MIDDLE, | 437 NAME_MIDDLE, |
| 435 NAME_LAST, | 438 NAME_LAST, |
| 436 EMAIL_ADDRESS, | 439 EMAIL_ADDRESS, |
| 437 PHONE_HOME_WHOLE_NUMBER }; | 440 PHONE_HOME_WHOLE_NUMBER }; |
| 438 | 441 |
| 439 for (size_t i = 0; i < arraysize(multi_value_types); ++i) { | 442 for (size_t i = 0; i < arraysize(multi_value_types); ++i) { |
| 440 std::vector<string16> values_a; | 443 std::vector<base::string16> values_a; |
| 441 std::vector<string16> values_b; | 444 std::vector<base::string16> values_b; |
| 442 GetRawMultiInfo(multi_value_types[i], &values_a); | 445 GetRawMultiInfo(multi_value_types[i], &values_a); |
| 443 profile.GetRawMultiInfo(multi_value_types[i], &values_b); | 446 profile.GetRawMultiInfo(multi_value_types[i], &values_b); |
| 444 if (values_a.size() < values_b.size()) | 447 if (values_a.size() < values_b.size()) |
| 445 return -1; | 448 return -1; |
| 446 if (values_a.size() > values_b.size()) | 449 if (values_a.size() > values_b.size()) |
| 447 return 1; | 450 return 1; |
| 448 for (size_t j = 0; j < values_a.size(); ++j) { | 451 for (size_t j = 0; j < values_a.size(); ++j) { |
| 449 int comparison = values_a[j].compare(values_b[j]); | 452 int comparison = values_a[j].compare(values_b[j]); |
| 450 if (comparison != 0) | 453 if (comparison != 0) |
| 451 return comparison; | 454 return comparison; |
| 452 } | 455 } |
| 453 } | 456 } |
| 454 | 457 |
| 455 return 0; | 458 return 0; |
| 456 } | 459 } |
| 457 | 460 |
| 458 bool AutofillProfile::operator==(const AutofillProfile& profile) const { | 461 bool AutofillProfile::operator==(const AutofillProfile& profile) const { |
| 459 return guid_ == profile.guid_ && Compare(profile) == 0; | 462 return guid_ == profile.guid_ && Compare(profile) == 0; |
| 460 } | 463 } |
| 461 | 464 |
| 462 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { | 465 bool AutofillProfile::operator!=(const AutofillProfile& profile) const { |
| 463 return !operator==(profile); | 466 return !operator==(profile); |
| 464 } | 467 } |
| 465 | 468 |
| 466 const string16 AutofillProfile::PrimaryValue() const { | 469 const base::string16 AutofillProfile::PrimaryValue() const { |
| 467 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); | 470 return GetRawInfo(ADDRESS_HOME_LINE1) + GetRawInfo(ADDRESS_HOME_CITY); |
| 468 } | 471 } |
| 469 | 472 |
| 470 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, | 473 bool AutofillProfile::IsSubsetOf(const AutofillProfile& profile, |
| 471 const std::string& app_locale) const { | 474 const std::string& app_locale) const { |
| 472 FieldTypeSet types; | 475 FieldTypeSet types; |
| 473 GetNonEmptyTypes(app_locale, &types); | 476 GetNonEmptyTypes(app_locale, &types); |
| 474 | 477 |
| 475 for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end(); | 478 for (FieldTypeSet::const_iterator iter = types.begin(); iter != types.end(); |
| 476 ++iter) { | 479 ++iter) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 505 FieldTypeSet field_types; | 508 FieldTypeSet field_types; |
| 506 profile.GetNonEmptyTypes(app_locale, &field_types); | 509 profile.GetNonEmptyTypes(app_locale, &field_types); |
| 507 | 510 |
| 508 // Only transfer "full" types (e.g. full name) and not fragments (e.g. | 511 // Only transfer "full" types (e.g. full name) and not fragments (e.g. |
| 509 // first name, last name). | 512 // first name, last name). |
| 510 CollapseCompoundFieldTypes(&field_types); | 513 CollapseCompoundFieldTypes(&field_types); |
| 511 | 514 |
| 512 for (FieldTypeSet::const_iterator iter = field_types.begin(); | 515 for (FieldTypeSet::const_iterator iter = field_types.begin(); |
| 513 iter != field_types.end(); ++iter) { | 516 iter != field_types.end(); ++iter) { |
| 514 if (AutofillProfile::SupportsMultiValue(*iter)) { | 517 if (AutofillProfile::SupportsMultiValue(*iter)) { |
| 515 std::vector<string16> new_values; | 518 std::vector<base::string16> new_values; |
| 516 profile.GetRawMultiInfo(*iter, &new_values); | 519 profile.GetRawMultiInfo(*iter, &new_values); |
| 517 std::vector<string16> existing_values; | 520 std::vector<base::string16> existing_values; |
| 518 GetRawMultiInfo(*iter, &existing_values); | 521 GetRawMultiInfo(*iter, &existing_values); |
| 519 | 522 |
| 520 // GetMultiInfo always returns at least one element, even if the profile | 523 // GetMultiInfo always returns at least one element, even if the profile |
| 521 // has no data stored for this field type. | 524 // has no data stored for this field type. |
| 522 if (existing_values.size() == 1 && existing_values.front().empty()) | 525 if (existing_values.size() == 1 && existing_values.front().empty()) |
| 523 existing_values.clear(); | 526 existing_values.clear(); |
| 524 | 527 |
| 525 FieldTypeGroup group = AutofillType(*iter).group(); | 528 FieldTypeGroup group = AutofillType(*iter).group(); |
| 526 for (std::vector<string16>::iterator value_iter = new_values.begin(); | 529 for (std::vector<base::string16>::iterator value_iter = |
| 530 new_values.begin(); |
| 527 value_iter != new_values.end(); ++value_iter) { | 531 value_iter != new_values.end(); ++value_iter) { |
| 528 // Don't add duplicates. | 532 // Don't add duplicates. |
| 529 if (group == AutofillType::PHONE) { | 533 if (group == AutofillType::PHONE) { |
| 530 AddPhoneIfUnique(*value_iter, app_locale, &existing_values); | 534 AddPhoneIfUnique(*value_iter, app_locale, &existing_values); |
| 531 } else { | 535 } else { |
| 532 std::vector<string16>::const_iterator existing_iter = std::find_if( | 536 std::vector<base::string16>::const_iterator existing_iter = |
| 533 existing_values.begin(), existing_values.end(), | 537 std::find_if( |
| 534 std::bind1st(CaseInsensitiveStringEquals(), *value_iter)); | 538 existing_values.begin(), existing_values.end(), |
| 539 std::bind1st(CaseInsensitiveStringEquals(), *value_iter)); |
| 535 if (existing_iter == existing_values.end()) | 540 if (existing_iter == existing_values.end()) |
| 536 existing_values.insert(existing_values.end(), *value_iter); | 541 existing_values.insert(existing_values.end(), *value_iter); |
| 537 } | 542 } |
| 538 } | 543 } |
| 539 SetRawMultiInfo(*iter, existing_values); | 544 SetRawMultiInfo(*iter, existing_values); |
| 540 } else { | 545 } else { |
| 541 string16 new_value = profile.GetRawInfo(*iter); | 546 base::string16 new_value = profile.GetRawInfo(*iter); |
| 542 if (StringToLowerASCII(GetRawInfo(*iter)) != | 547 if (StringToLowerASCII(GetRawInfo(*iter)) != |
| 543 StringToLowerASCII(new_value)) { | 548 StringToLowerASCII(new_value)) { |
| 544 SetRawInfo(*iter, new_value); | 549 SetRawInfo(*iter, new_value); |
| 545 } | 550 } |
| 546 } | 551 } |
| 547 } | 552 } |
| 548 } | 553 } |
| 549 | 554 |
| 550 // static | 555 // static |
| 551 bool AutofillProfile::SupportsMultiValue(AutofillFieldType type) { | 556 bool AutofillProfile::SupportsMultiValue(AutofillFieldType type) { |
| 552 AutofillType::FieldTypeGroup group = AutofillType(type).group(); | 557 AutofillType::FieldTypeGroup group = AutofillType(type).group(); |
| 553 return group == AutofillType::NAME || | 558 return group == AutofillType::NAME || |
| 554 group == AutofillType::EMAIL || | 559 group == AutofillType::EMAIL || |
| 555 group == AutofillType::PHONE; | 560 group == AutofillType::PHONE; |
| 556 } | 561 } |
| 557 | 562 |
| 558 // static | 563 // static |
| 559 bool AutofillProfile::AdjustInferredLabels( | 564 bool AutofillProfile::AdjustInferredLabels( |
| 560 std::vector<AutofillProfile*>* profiles) { | 565 std::vector<AutofillProfile*>* profiles) { |
| 561 const size_t kMinimalFieldsShown = 2; | 566 const size_t kMinimalFieldsShown = 2; |
| 562 | 567 |
| 563 std::vector<string16> created_labels; | 568 std::vector<base::string16> created_labels; |
| 564 CreateInferredLabels(profiles, NULL, UNKNOWN_TYPE, kMinimalFieldsShown, | 569 CreateInferredLabels(profiles, NULL, UNKNOWN_TYPE, kMinimalFieldsShown, |
| 565 &created_labels); | 570 &created_labels); |
| 566 DCHECK_EQ(profiles->size(), created_labels.size()); | 571 DCHECK_EQ(profiles->size(), created_labels.size()); |
| 567 | 572 |
| 568 bool updated_labels = false; | 573 bool updated_labels = false; |
| 569 for (size_t i = 0; i < profiles->size(); ++i) { | 574 for (size_t i = 0; i < profiles->size(); ++i) { |
| 570 if ((*profiles)[i]->Label() != created_labels[i]) { | 575 if ((*profiles)[i]->Label() != created_labels[i]) { |
| 571 updated_labels = true; | 576 updated_labels = true; |
| 572 (*profiles)[i]->label_ = created_labels[i]; | 577 (*profiles)[i]->label_ = created_labels[i]; |
| 573 } | 578 } |
| 574 } | 579 } |
| 575 return updated_labels; | 580 return updated_labels; |
| 576 } | 581 } |
| 577 | 582 |
| 578 // static | 583 // static |
| 579 void AutofillProfile::CreateInferredLabels( | 584 void AutofillProfile::CreateInferredLabels( |
| 580 const std::vector<AutofillProfile*>* profiles, | 585 const std::vector<AutofillProfile*>* profiles, |
| 581 const std::vector<AutofillFieldType>* suggested_fields, | 586 const std::vector<AutofillFieldType>* suggested_fields, |
| 582 AutofillFieldType excluded_field, | 587 AutofillFieldType excluded_field, |
| 583 size_t minimal_fields_shown, | 588 size_t minimal_fields_shown, |
| 584 std::vector<string16>* created_labels) { | 589 std::vector<base::string16>* created_labels) { |
| 585 DCHECK(profiles); | 590 DCHECK(profiles); |
| 586 DCHECK(created_labels); | 591 DCHECK(created_labels); |
| 587 | 592 |
| 588 std::vector<AutofillFieldType> fields_to_use; | 593 std::vector<AutofillFieldType> fields_to_use; |
| 589 GetFieldsForDistinguishingProfiles(suggested_fields, excluded_field, | 594 GetFieldsForDistinguishingProfiles(suggested_fields, excluded_field, |
| 590 &fields_to_use); | 595 &fields_to_use); |
| 591 | 596 |
| 592 // Construct the default label for each profile. Also construct a map that | 597 // Construct the default label for each profile. Also construct a map that |
| 593 // associates each label with the profiles that have this label. This map is | 598 // associates each label with the profiles that have this label. This map is |
| 594 // then used to detect which labels need further differentiating fields. | 599 // then used to detect which labels need further differentiating fields. |
| 595 std::map<string16, std::list<size_t> > labels; | 600 std::map<base::string16, std::list<size_t> > labels; |
| 596 for (size_t i = 0; i < profiles->size(); ++i) { | 601 for (size_t i = 0; i < profiles->size(); ++i) { |
| 597 string16 label = | 602 base::string16 label = |
| 598 (*profiles)[i]->ConstructInferredLabel(fields_to_use, | 603 (*profiles)[i]->ConstructInferredLabel(fields_to_use, |
| 599 minimal_fields_shown); | 604 minimal_fields_shown); |
| 600 labels[label].push_back(i); | 605 labels[label].push_back(i); |
| 601 } | 606 } |
| 602 | 607 |
| 603 created_labels->resize(profiles->size()); | 608 created_labels->resize(profiles->size()); |
| 604 for (std::map<string16, std::list<size_t> >::const_iterator it = | 609 for (std::map<base::string16, std::list<size_t> >::const_iterator it = |
| 605 labels.begin(); | 610 labels.begin(); |
| 606 it != labels.end(); ++it) { | 611 it != labels.end(); ++it) { |
| 607 if (it->second.size() == 1) { | 612 if (it->second.size() == 1) { |
| 608 // This label is unique, so use it without any further ado. | 613 // This label is unique, so use it without any further ado. |
| 609 string16 label = it->first; | 614 base::string16 label = it->first; |
| 610 size_t profile_index = it->second.front(); | 615 size_t profile_index = it->second.front(); |
| 611 (*created_labels)[profile_index] = label; | 616 (*created_labels)[profile_index] = label; |
| 612 } else { | 617 } else { |
| 613 // We have more than one profile with the same label, so add | 618 // We have more than one profile with the same label, so add |
| 614 // differentiating fields. | 619 // differentiating fields. |
| 615 CreateDifferentiatingLabels(*profiles, it->second, fields_to_use, | 620 CreateDifferentiatingLabels(*profiles, it->second, fields_to_use, |
| 616 minimal_fields_shown, created_labels); | 621 minimal_fields_shown, created_labels); |
| 617 } | 622 } |
| 618 } | 623 } |
| 619 } | 624 } |
| 620 | 625 |
| 621 void AutofillProfile::GetSupportedTypes(FieldTypeSet* supported_types) const { | 626 void AutofillProfile::GetSupportedTypes(FieldTypeSet* supported_types) const { |
| 622 FormGroupList info = FormGroups(); | 627 FormGroupList info = FormGroups(); |
| 623 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) | 628 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) |
| 624 (*it)->GetSupportedTypes(supported_types); | 629 (*it)->GetSupportedTypes(supported_types); |
| 625 } | 630 } |
| 626 | 631 |
| 627 bool AutofillProfile::FillCountrySelectControl( | 632 bool AutofillProfile::FillCountrySelectControl( |
| 628 const std::string& app_locale, | 633 const std::string& app_locale, |
| 629 FormFieldData* field_data) const { | 634 FormFieldData* field_data) const { |
| 630 std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)); | 635 std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)); |
| 631 | 636 |
| 632 DCHECK_EQ(field_data->option_values.size(), | 637 DCHECK_EQ(field_data->option_values.size(), |
| 633 field_data->option_contents.size()); | 638 field_data->option_contents.size()); |
| 634 for (size_t i = 0; i < field_data->option_values.size(); ++i) { | 639 for (size_t i = 0; i < field_data->option_values.size(); ++i) { |
| 635 // Canonicalize each <option> value to a country code, and compare to the | 640 // Canonicalize each <option> value to a country code, and compare to the |
| 636 // target country code. | 641 // target country code. |
| 637 string16 value = field_data->option_values[i]; | 642 base::string16 value = field_data->option_values[i]; |
| 638 string16 contents = field_data->option_contents[i]; | 643 base::string16 contents = field_data->option_contents[i]; |
| 639 if (country_code == AutofillCountry::GetCountryCode(value, app_locale) || | 644 if (country_code == AutofillCountry::GetCountryCode(value, app_locale) || |
| 640 country_code == AutofillCountry::GetCountryCode(contents, app_locale)) { | 645 country_code == AutofillCountry::GetCountryCode(contents, app_locale)) { |
| 641 field_data->value = value; | 646 field_data->value = value; |
| 642 return true; | 647 return true; |
| 643 } | 648 } |
| 644 } | 649 } |
| 645 | 650 |
| 646 return false; | 651 return false; |
| 647 } | 652 } |
| 648 | 653 |
| 649 void AutofillProfile::GetMultiInfoImpl(AutofillFieldType type, | 654 void AutofillProfile::GetMultiInfoImpl( |
| 650 const std::string& app_locale, | 655 AutofillFieldType type, |
| 651 std::vector<string16>* values) const { | 656 const std::string& app_locale, |
| 657 std::vector<base::string16>* values) const { |
| 652 switch (AutofillType(type).group()) { | 658 switch (AutofillType(type).group()) { |
| 653 case AutofillType::NAME: | 659 case AutofillType::NAME: |
| 654 CopyItemsToValues(type, name_, app_locale, values); | 660 CopyItemsToValues(type, name_, app_locale, values); |
| 655 break; | 661 break; |
| 656 case AutofillType::EMAIL: | 662 case AutofillType::EMAIL: |
| 657 CopyItemsToValues(type, email_, app_locale, values); | 663 CopyItemsToValues(type, email_, app_locale, values); |
| 658 break; | 664 break; |
| 659 case AutofillType::PHONE: | 665 case AutofillType::PHONE: |
| 660 CopyItemsToValues(type, home_number_, app_locale, values); | 666 CopyItemsToValues(type, home_number_, app_locale, values); |
| 661 break; | 667 break; |
| 662 default: | 668 default: |
| 663 values->resize(1); | 669 values->resize(1); |
| 664 (*values)[0] = GetFormGroupInfo(*this, type, app_locale); | 670 (*values)[0] = GetFormGroupInfo(*this, type, app_locale); |
| 665 } | 671 } |
| 666 } | 672 } |
| 667 | 673 |
| 668 void AutofillProfile::AddPhoneIfUnique(const string16& phone, | 674 void AutofillProfile::AddPhoneIfUnique( |
| 669 const std::string& app_locale, | 675 const base::string16& phone, |
| 670 std::vector<string16>* existing_phones) { | 676 const std::string& app_locale, |
| 677 std::vector<base::string16>* existing_phones) { |
| 671 DCHECK(existing_phones); | 678 DCHECK(existing_phones); |
| 672 // Phones allow "fuzzy" matching, so "1-800-FLOWERS", "18003569377", | 679 // Phones allow "fuzzy" matching, so "1-800-FLOWERS", "18003569377", |
| 673 // "(800)356-9377" and "356-9377" are considered the same. | 680 // "(800)356-9377" and "356-9377" are considered the same. |
| 674 std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)); | 681 std::string country_code = UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)); |
| 675 if (std::find_if(existing_phones->begin(), existing_phones->end(), | 682 if (std::find_if(existing_phones->begin(), existing_phones->end(), |
| 676 FindByPhone(phone, country_code, app_locale)) == | 683 FindByPhone(phone, country_code, app_locale)) == |
| 677 existing_phones->end()) { | 684 existing_phones->end()) { |
| 678 existing_phones->push_back(phone); | 685 existing_phones->push_back(phone); |
| 679 } | 686 } |
| 680 } | 687 } |
| 681 | 688 |
| 682 string16 AutofillProfile::ConstructInferredLabel( | 689 base::string16 AutofillProfile::ConstructInferredLabel( |
| 683 const std::vector<AutofillFieldType>& included_fields, | 690 const std::vector<AutofillFieldType>& included_fields, |
| 684 size_t num_fields_to_use) const { | 691 size_t num_fields_to_use) const { |
| 685 const string16 separator = | 692 const base::string16 separator = |
| 686 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR); | 693 l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESS_SUMMARY_SEPARATOR); |
| 687 | 694 |
| 688 string16 label; | 695 base::string16 label; |
| 689 size_t num_fields_used = 0; | 696 size_t num_fields_used = 0; |
| 690 for (std::vector<AutofillFieldType>::const_iterator it = | 697 for (std::vector<AutofillFieldType>::const_iterator it = |
| 691 included_fields.begin(); | 698 included_fields.begin(); |
| 692 it != included_fields.end() && num_fields_used < num_fields_to_use; | 699 it != included_fields.end() && num_fields_used < num_fields_to_use; |
| 693 ++it) { | 700 ++it) { |
| 694 string16 field = GetRawInfo(*it); | 701 base::string16 field = GetRawInfo(*it); |
| 695 if (field.empty()) | 702 if (field.empty()) |
| 696 continue; | 703 continue; |
| 697 | 704 |
| 698 if (!label.empty()) | 705 if (!label.empty()) |
| 699 label.append(separator); | 706 label.append(separator); |
| 700 | 707 |
| 701 label.append(field); | 708 label.append(field); |
| 702 ++num_fields_used; | 709 ++num_fields_used; |
| 703 } | 710 } |
| 704 return label; | 711 return label; |
| 705 } | 712 } |
| 706 | 713 |
| 707 // static | 714 // static |
| 708 void AutofillProfile::CreateDifferentiatingLabels( | 715 void AutofillProfile::CreateDifferentiatingLabels( |
| 709 const std::vector<AutofillProfile*>& profiles, | 716 const std::vector<AutofillProfile*>& profiles, |
| 710 const std::list<size_t>& indices, | 717 const std::list<size_t>& indices, |
| 711 const std::vector<AutofillFieldType>& fields, | 718 const std::vector<AutofillFieldType>& fields, |
| 712 size_t num_fields_to_include, | 719 size_t num_fields_to_include, |
| 713 std::vector<string16>* created_labels) { | 720 std::vector<base::string16>* created_labels) { |
| 714 // For efficiency, we first construct a map of fields to their text values and | 721 // For efficiency, we first construct a map of fields to their text values and |
| 715 // each value's frequency. | 722 // each value's frequency. |
| 716 std::map<AutofillFieldType, | 723 std::map<AutofillFieldType, |
| 717 std::map<string16, size_t> > field_text_frequencies_by_field; | 724 std::map<base::string16, size_t> > field_text_frequencies_by_field; |
| 718 for (std::vector<AutofillFieldType>::const_iterator field = fields.begin(); | 725 for (std::vector<AutofillFieldType>::const_iterator field = fields.begin(); |
| 719 field != fields.end(); ++field) { | 726 field != fields.end(); ++field) { |
| 720 std::map<string16, size_t>& field_text_frequencies = | 727 std::map<base::string16, size_t>& field_text_frequencies = |
| 721 field_text_frequencies_by_field[*field]; | 728 field_text_frequencies_by_field[*field]; |
| 722 | 729 |
| 723 for (std::list<size_t>::const_iterator it = indices.begin(); | 730 for (std::list<size_t>::const_iterator it = indices.begin(); |
| 724 it != indices.end(); ++it) { | 731 it != indices.end(); ++it) { |
| 725 const AutofillProfile* profile = profiles[*it]; | 732 const AutofillProfile* profile = profiles[*it]; |
| 726 string16 field_text = profile->GetRawInfo(*field); | 733 base::string16 field_text = profile->GetRawInfo(*field); |
| 727 | 734 |
| 728 // If this label is not already in the map, add it with frequency 0. | 735 // If this label is not already in the map, add it with frequency 0. |
| 729 if (!field_text_frequencies.count(field_text)) | 736 if (!field_text_frequencies.count(field_text)) |
| 730 field_text_frequencies[field_text] = 0; | 737 field_text_frequencies[field_text] = 0; |
| 731 | 738 |
| 732 // Now, increment the frequency for this label. | 739 // Now, increment the frequency for this label. |
| 733 ++field_text_frequencies[field_text]; | 740 ++field_text_frequencies[field_text]; |
| 734 } | 741 } |
| 735 } | 742 } |
| 736 | 743 |
| 737 // Now comes the meat of the algorithm. For each profile, we scan the list of | 744 // Now comes the meat of the algorithm. For each profile, we scan the list of |
| 738 // fields to use, looking for two things: | 745 // fields to use, looking for two things: |
| 739 // 1. A (non-empty) field that differentiates the profile from all others | 746 // 1. A (non-empty) field that differentiates the profile from all others |
| 740 // 2. At least |num_fields_to_include| non-empty fields | 747 // 2. At least |num_fields_to_include| non-empty fields |
| 741 // Before we've satisfied condition (2), we include all fields, even ones that | 748 // Before we've satisfied condition (2), we include all fields, even ones that |
| 742 // are identical across all the profiles. Once we've satisfied condition (2), | 749 // are identical across all the profiles. Once we've satisfied condition (2), |
| 743 // we only include fields that that have at last two distinct values. | 750 // we only include fields that that have at last two distinct values. |
| 744 for (std::list<size_t>::const_iterator it = indices.begin(); | 751 for (std::list<size_t>::const_iterator it = indices.begin(); |
| 745 it != indices.end(); ++it) { | 752 it != indices.end(); ++it) { |
| 746 const AutofillProfile* profile = profiles[*it]; | 753 const AutofillProfile* profile = profiles[*it]; |
| 747 | 754 |
| 748 std::vector<AutofillFieldType> label_fields; | 755 std::vector<AutofillFieldType> label_fields; |
| 749 bool found_differentiating_field = false; | 756 bool found_differentiating_field = false; |
| 750 for (std::vector<AutofillFieldType>::const_iterator field = fields.begin(); | 757 for (std::vector<AutofillFieldType>::const_iterator field = fields.begin(); |
| 751 field != fields.end(); ++field) { | 758 field != fields.end(); ++field) { |
| 752 // Skip over empty fields. | 759 // Skip over empty fields. |
| 753 string16 field_text = profile->GetRawInfo(*field); | 760 base::string16 field_text = profile->GetRawInfo(*field); |
| 754 if (field_text.empty()) | 761 if (field_text.empty()) |
| 755 continue; | 762 continue; |
| 756 | 763 |
| 757 std::map<string16, size_t>& field_text_frequencies = | 764 std::map<base::string16, size_t>& field_text_frequencies = |
| 758 field_text_frequencies_by_field[*field]; | 765 field_text_frequencies_by_field[*field]; |
| 759 found_differentiating_field |= | 766 found_differentiating_field |= |
| 760 !field_text_frequencies.count(string16()) && | 767 !field_text_frequencies.count(base::string16()) && |
| 761 (field_text_frequencies[field_text] == 1); | 768 (field_text_frequencies[field_text] == 1); |
| 762 | 769 |
| 763 // Once we've found enough non-empty fields, skip over any remaining | 770 // Once we've found enough non-empty fields, skip over any remaining |
| 764 // fields that are identical across all the profiles. | 771 // fields that are identical across all the profiles. |
| 765 if (label_fields.size() >= num_fields_to_include && | 772 if (label_fields.size() >= num_fields_to_include && |
| 766 (field_text_frequencies.size() == 1)) | 773 (field_text_frequencies.size() == 1)) |
| 767 continue; | 774 continue; |
| 768 | 775 |
| 769 label_fields.push_back(*field); | 776 label_fields.push_back(*field); |
| 770 | 777 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) | 853 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)) |
| 847 << " " | 854 << " " |
| 848 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) | 855 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)) |
| 849 << " " | 856 << " " |
| 850 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) | 857 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)) |
| 851 << " " | 858 << " " |
| 852 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 859 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
| 853 << " " | 860 << " " |
| 854 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 861 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
| 855 } | 862 } |
| OLD | NEW |