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 #include "components/autofill/core/browser/autofill_profile.h" | 5 #include "components/autofill/core/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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 std::string country_code_; | 237 std::string country_code_; |
238 std::string app_locale_; | 238 std::string app_locale_; |
239 }; | 239 }; |
240 | 240 |
241 } // namespace | 241 } // namespace |
242 | 242 |
243 AutofillProfile::AutofillProfile(const std::string& guid, | 243 AutofillProfile::AutofillProfile(const std::string& guid, |
244 const std::string& origin) | 244 const std::string& origin) |
245 : AutofillDataModel(guid, origin), | 245 : AutofillDataModel(guid, origin), |
246 record_type_(LOCAL_PROFILE), | 246 record_type_(LOCAL_PROFILE), |
247 name_(1), | |
248 email_(1), | 247 email_(1), |
249 phone_number_(1, PhoneNumber(this)) { | 248 phone_number_(1, PhoneNumber(this)) { |
250 } | 249 } |
251 | 250 |
252 AutofillProfile::AutofillProfile(RecordType type, const std::string& server_id) | 251 AutofillProfile::AutofillProfile(RecordType type, const std::string& server_id) |
253 : AutofillDataModel(base::GenerateGUID(), std::string()), | 252 : AutofillDataModel(base::GenerateGUID(), std::string()), |
254 record_type_(type), | 253 record_type_(type), |
255 name_(1), | |
256 email_(1), | 254 email_(1), |
257 phone_number_(1, PhoneNumber(this)), | 255 phone_number_(1, PhoneNumber(this)), |
258 server_id_(server_id) { | 256 server_id_(server_id) { |
259 DCHECK(type == SERVER_PROFILE); | 257 DCHECK(type == SERVER_PROFILE); |
260 } | 258 } |
261 | 259 |
262 AutofillProfile::AutofillProfile() | 260 AutofillProfile::AutofillProfile() |
263 : AutofillDataModel(base::GenerateGUID(), std::string()), | 261 : AutofillDataModel(base::GenerateGUID(), std::string()), |
264 record_type_(LOCAL_PROFILE), | 262 record_type_(LOCAL_PROFILE), |
265 name_(1), | |
266 email_(1), | 263 email_(1), |
267 phone_number_(1, PhoneNumber(this)) { | 264 phone_number_(1, PhoneNumber(this)) { |
268 } | 265 } |
269 | 266 |
270 AutofillProfile::AutofillProfile(const AutofillProfile& profile) | 267 AutofillProfile::AutofillProfile(const AutofillProfile& profile) |
271 : AutofillDataModel(std::string(), std::string()) { | 268 : AutofillDataModel(std::string(), std::string()) { |
272 operator=(profile); | 269 operator=(profile); |
273 } | 270 } |
274 | 271 |
275 AutofillProfile::~AutofillProfile() { | 272 AutofillProfile::~AutofillProfile() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 const std::string& app_locale) { | 350 const std::string& app_locale) { |
354 FormGroup* form_group = MutableFormGroupForType(type); | 351 FormGroup* form_group = MutableFormGroupForType(type); |
355 if (!form_group) | 352 if (!form_group) |
356 return false; | 353 return false; |
357 | 354 |
358 base::string16 trimmed_value; | 355 base::string16 trimmed_value; |
359 base::TrimWhitespace(value, base::TRIM_ALL, &trimmed_value); | 356 base::TrimWhitespace(value, base::TRIM_ALL, &trimmed_value); |
360 return form_group->SetInfo(type, trimmed_value, app_locale); | 357 return form_group->SetInfo(type, trimmed_value, app_locale); |
361 } | 358 } |
362 | 359 |
| 360 // TODO(estade): remove this function. |
363 void AutofillProfile::SetRawMultiInfo( | 361 void AutofillProfile::SetRawMultiInfo( |
364 ServerFieldType type, | 362 ServerFieldType type, |
365 const std::vector<base::string16>& values) { | 363 const std::vector<base::string16>& values) { |
366 switch (AutofillType(type).group()) { | 364 switch (AutofillType(type).group()) { |
367 case NAME: | 365 case NAME: |
368 case NAME_BILLING: | 366 case NAME_BILLING: |
369 CopyRawValuesToItems(type, values, NameInfo(), &name_); | 367 SetRawInfo(type, values.empty() ? base::string16() : values[0]); |
370 break; | 368 break; |
371 | 369 |
372 case EMAIL: | 370 case EMAIL: |
373 CopyRawValuesToItems(type, values, EmailInfo(), &email_); | 371 CopyRawValuesToItems(type, values, EmailInfo(), &email_); |
374 break; | 372 break; |
375 | 373 |
376 case PHONE_HOME: | 374 case PHONE_HOME: |
377 case PHONE_BILLING: | 375 case PHONE_BILLING: |
378 CopyRawValuesToItems(type, values, PhoneNumber(this), &phone_number_); | 376 CopyRawValuesToItems(type, values, PhoneNumber(this), &phone_number_); |
379 break; | 377 break; |
380 | 378 |
381 default: | 379 default: |
382 if (values.size() == 1U) { | 380 if (values.size() == 1U) { |
383 SetRawInfo(type, values[0]); | 381 SetRawInfo(type, values[0]); |
384 } else if (values.empty()) { | 382 } else if (values.empty()) { |
385 SetRawInfo(type, base::string16()); | 383 SetRawInfo(type, base::string16()); |
386 } else { | 384 } else { |
387 // Shouldn't attempt to set multiple values on single-valued field. | |
388 NOTREACHED(); | 385 NOTREACHED(); |
389 } | 386 } |
390 break; | 387 break; |
391 } | 388 } |
392 } | 389 } |
393 | 390 |
394 void AutofillProfile::GetRawMultiInfo( | 391 void AutofillProfile::GetRawMultiInfo( |
395 ServerFieldType type, | 392 ServerFieldType type, |
396 std::vector<base::string16>* values) const { | 393 std::vector<base::string16>* values) const { |
397 GetMultiInfoImpl(AutofillType(type), std::string(), values); | 394 GetMultiInfoImpl(AutofillType(type), std::string(), values); |
398 } | 395 } |
399 | 396 |
400 void AutofillProfile::GetMultiInfo(const AutofillType& type, | |
401 const std::string& app_locale, | |
402 std::vector<base::string16>* values) const { | |
403 GetMultiInfoImpl(type, app_locale, values); | |
404 } | |
405 | |
406 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { | 397 bool AutofillProfile::IsEmpty(const std::string& app_locale) const { |
407 ServerFieldTypeSet types; | 398 ServerFieldTypeSet types; |
408 GetNonEmptyTypes(app_locale, &types); | 399 GetNonEmptyTypes(app_locale, &types); |
409 return types.empty(); | 400 return types.empty(); |
410 } | 401 } |
411 | 402 |
412 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { | 403 bool AutofillProfile::IsPresentButInvalid(ServerFieldType type) const { |
413 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY)); | 404 std::string country = UTF16ToUTF8(GetRawInfo(ADDRESS_HOME_COUNTRY)); |
414 base::string16 data = GetRawInfo(type); | 405 base::string16 data = GetRawInfo(type); |
415 if (data.empty()) | 406 if (data.empty()) |
(...skipping 12 matching lines...) Expand all Loading... |
428 case EMAIL_ADDRESS: | 419 case EMAIL_ADDRESS: |
429 return !autofill::IsValidEmailAddress(data); | 420 return !autofill::IsValidEmailAddress(data); |
430 | 421 |
431 default: | 422 default: |
432 NOTREACHED(); | 423 NOTREACHED(); |
433 return false; | 424 return false; |
434 } | 425 } |
435 } | 426 } |
436 | 427 |
437 int AutofillProfile::Compare(const AutofillProfile& profile) const { | 428 int AutofillProfile::Compare(const AutofillProfile& profile) const { |
438 const ServerFieldType single_value_types[] = { | 429 const ServerFieldType types[] = { |
439 COMPANY_NAME, | 430 NAME_FULL, |
440 ADDRESS_HOME_STREET_ADDRESS, | 431 NAME_FIRST, |
441 ADDRESS_HOME_DEPENDENT_LOCALITY, | 432 NAME_MIDDLE, |
442 ADDRESS_HOME_CITY, | 433 NAME_LAST, |
443 ADDRESS_HOME_STATE, | 434 COMPANY_NAME, |
444 ADDRESS_HOME_ZIP, | 435 ADDRESS_HOME_STREET_ADDRESS, |
445 ADDRESS_HOME_SORTING_CODE, | 436 ADDRESS_HOME_DEPENDENT_LOCALITY, |
446 ADDRESS_HOME_COUNTRY, | 437 ADDRESS_HOME_CITY, |
| 438 ADDRESS_HOME_STATE, |
| 439 ADDRESS_HOME_ZIP, |
| 440 ADDRESS_HOME_SORTING_CODE, |
| 441 ADDRESS_HOME_COUNTRY, |
| 442 EMAIL_ADDRESS, |
| 443 PHONE_HOME_WHOLE_NUMBER, |
447 }; | 444 }; |
448 | 445 |
449 for (size_t i = 0; i < arraysize(single_value_types); ++i) { | 446 for (size_t i = 0; i < arraysize(types); ++i) { |
450 int comparison = GetRawInfo(single_value_types[i]).compare( | 447 int comparison = GetRawInfo(types[i]).compare(profile.GetRawInfo(types[i])); |
451 profile.GetRawInfo(single_value_types[i])); | 448 if (comparison != 0) { |
452 if (comparison != 0) | |
453 return comparison; | 449 return comparison; |
454 } | |
455 | |
456 const ServerFieldType multi_value_types[] = { NAME_FULL, | |
457 NAME_FIRST, | |
458 NAME_MIDDLE, | |
459 NAME_LAST, | |
460 EMAIL_ADDRESS, | |
461 PHONE_HOME_WHOLE_NUMBER }; | |
462 | |
463 for (size_t i = 0; i < arraysize(multi_value_types); ++i) { | |
464 std::vector<base::string16> values_a; | |
465 std::vector<base::string16> values_b; | |
466 GetRawMultiInfo(multi_value_types[i], &values_a); | |
467 profile.GetRawMultiInfo(multi_value_types[i], &values_b); | |
468 if (values_a.size() < values_b.size()) | |
469 return -1; | |
470 if (values_a.size() > values_b.size()) | |
471 return 1; | |
472 for (size_t j = 0; j < values_a.size(); ++j) { | |
473 int comparison = values_a[j].compare(values_b[j]); | |
474 if (comparison != 0) | |
475 return comparison; | |
476 } | 450 } |
477 } | 451 } |
478 | 452 |
479 return 0; | 453 return 0; |
480 } | 454 } |
481 | 455 |
482 bool AutofillProfile::EqualsSansOrigin(const AutofillProfile& profile) const { | 456 bool AutofillProfile::EqualsSansOrigin(const AutofillProfile& profile) const { |
483 return guid() == profile.guid() && | 457 return guid() == profile.guid() && |
484 language_code() == profile.language_code() && | 458 language_code() == profile.language_code() && |
485 Compare(profile) == 0; | 459 Compare(profile) == 0; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 if (!compare) | 517 if (!compare) |
544 compare.reset(new l10n::CaseInsensitiveCompare()); | 518 compare.reset(new l10n::CaseInsensitiveCompare()); |
545 if (!compare->StringsEqual(value, profile.GetRawInfo(type))) | 519 if (!compare->StringsEqual(value, profile.GetRawInfo(type))) |
546 return false; | 520 return false; |
547 } | 521 } |
548 } | 522 } |
549 | 523 |
550 return true; | 524 return true; |
551 } | 525 } |
552 | 526 |
553 void AutofillProfile::OverwriteOrAppendNames( | 527 void AutofillProfile::OverwriteName(const NameInfo& imported_name, |
554 const std::vector<NameInfo>& names, | 528 const std::string& app_locale) { |
555 const std::string& app_locale) { | 529 if (name_.ParsedNamesAreEqual(imported_name)) { |
556 std::vector<NameInfo> results(name_); | 530 if (name_.GetRawInfo(NAME_FULL).empty()) |
557 l10n::CaseInsensitiveCompare compare; | 531 name_.SetRawInfo(NAME_FULL, imported_name.GetRawInfo(NAME_FULL)); |
558 for (std::vector<NameInfo>::const_iterator it = names.begin(); | 532 return; |
559 it != names.end(); | |
560 ++it) { | |
561 NameInfo imported_name = *it; | |
562 bool should_append_imported_name = true; | |
563 | |
564 for (size_t index = 0; index < name_.size(); ++index) { | |
565 NameInfo current_name = name_[index]; | |
566 if (current_name.ParsedNamesAreEqual(imported_name)) { | |
567 if (current_name.GetRawInfo(NAME_FULL).empty()) { | |
568 current_name.SetRawInfo(NAME_FULL, | |
569 imported_name.GetRawInfo(NAME_FULL)); | |
570 } | |
571 | |
572 should_append_imported_name = false; | |
573 break; | |
574 } | |
575 | |
576 AutofillType type = AutofillType(NAME_FULL); | |
577 base::string16 full_name = current_name.GetInfo(type, app_locale); | |
578 if (compare.StringsEqual(full_name, | |
579 imported_name.GetInfo(type, app_locale))) { | |
580 // The imported name has the same full name string as one of the | |
581 // existing names for this profile. Because full names are | |
582 // _heuristically_ parsed into {first, middle, last} name components, | |
583 // it's possible that either the existing name or the imported name | |
584 // was misparsed. Prefer to keep the name whose {first, middle, | |
585 // last} components do not match those computed by the heuristic | |
586 // parse, as this more likely represents the correct, user-input parse | |
587 // of the name. | |
588 NameInfo heuristically_parsed_name; | |
589 heuristically_parsed_name.SetInfo(type, full_name, app_locale); | |
590 if (imported_name.ParsedNamesAreEqual(heuristically_parsed_name)) { | |
591 should_append_imported_name = false; | |
592 break; | |
593 } | |
594 | |
595 if (current_name.ParsedNamesAreEqual(heuristically_parsed_name)) { | |
596 results[index] = imported_name; | |
597 should_append_imported_name = false; | |
598 break; | |
599 } | |
600 } | |
601 } | |
602 | |
603 // Append unique names to the list. | |
604 if (should_append_imported_name) | |
605 results.push_back(imported_name); | |
606 } | 533 } |
607 | 534 |
608 name_.swap(results); | 535 l10n::CaseInsensitiveCompare compare; |
| 536 AutofillType type = AutofillType(NAME_FULL); |
| 537 base::string16 full_name = name_.GetInfo(type, app_locale); |
| 538 if (compare.StringsEqual(full_name, |
| 539 imported_name.GetInfo(type, app_locale))) { |
| 540 // The imported name has the same full name string as the name for this |
| 541 // profile. Because full names are _heuristically_ parsed into |
| 542 // {first, middle, last} name components, it's possible that either the |
| 543 // existing name or the imported name was misparsed. Prefer to keep the |
| 544 // name whose {first, middle, last} components do not match those computed |
| 545 // by the heuristic parse, as this more likely represents the correct, |
| 546 // user-input parse of the name. |
| 547 NameInfo heuristically_parsed_name; |
| 548 heuristically_parsed_name.SetInfo(type, full_name, app_locale); |
| 549 if (imported_name.ParsedNamesAreEqual(heuristically_parsed_name)) |
| 550 return; |
| 551 } |
| 552 |
| 553 name_ = imported_name; |
609 } | 554 } |
610 | 555 |
611 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile, | 556 void AutofillProfile::OverwriteWith(const AutofillProfile& profile, |
612 const std::string& app_locale) { | 557 const std::string& app_locale) { |
613 // Verified profiles should never be overwritten with unverified data. | 558 // Verified profiles should never be overwritten with unverified data. |
614 DCHECK(!IsVerified() || profile.IsVerified()); | 559 DCHECK(!IsVerified() || profile.IsVerified()); |
615 set_origin(profile.origin()); | 560 set_origin(profile.origin()); |
616 set_language_code(profile.language_code()); | 561 set_language_code(profile.language_code()); |
617 set_use_count(profile.use_count() + use_count()); | 562 set_use_count(profile.use_count() + use_count()); |
618 if (profile.use_date() > use_date()) | 563 if (profile.use_date() > use_date()) |
619 set_use_date(profile.use_date()); | 564 set_use_date(profile.use_date()); |
620 | 565 |
621 ServerFieldTypeSet field_types; | 566 ServerFieldTypeSet field_types; |
622 profile.GetNonEmptyTypes(app_locale, &field_types); | 567 profile.GetNonEmptyTypes(app_locale, &field_types); |
623 | 568 |
624 // Only transfer "full" types (e.g. full name) and not fragments (e.g. | 569 // Only transfer "full" types (e.g. full name) and not fragments (e.g. |
625 // first name, last name). | 570 // first name, last name). |
626 CollapseCompoundFieldTypes(&field_types); | 571 CollapseCompoundFieldTypes(&field_types); |
627 | 572 |
628 // TODO(isherman): Revisit this decision in the context of i18n and storing | 573 // TODO(isherman): Revisit this decision in the context of i18n and storing |
629 // full addresses rather than storing 1-to-2 lines of an address. | 574 // full addresses rather than storing 1-to-2 lines of an address. |
630 // For addresses, do the opposite: transfer individual address lines, rather | 575 // For addresses, do the opposite: transfer individual address lines, rather |
631 // than full addresses. | 576 // than full addresses. |
632 field_types.erase(ADDRESS_HOME_STREET_ADDRESS); | 577 field_types.erase(ADDRESS_HOME_STREET_ADDRESS); |
633 | 578 |
634 l10n::CaseInsensitiveCompare compare; | 579 l10n::CaseInsensitiveCompare compare; |
635 | 580 |
636 for (ServerFieldTypeSet::const_iterator iter = field_types.begin(); | 581 for (ServerFieldTypeSet::const_iterator iter = field_types.begin(); |
637 iter != field_types.end(); ++iter) { | 582 iter != field_types.end(); ++iter) { |
638 FieldTypeGroup group = AutofillType(*iter).group(); | 583 FieldTypeGroup group = AutofillType(*iter).group(); |
639 // Special case names. | 584 // Special case names. |
640 if (group == NAME) { | 585 if (group == NAME) { |
641 OverwriteOrAppendNames(profile.name_, app_locale); | 586 OverwriteName(profile.name_, app_locale); |
642 continue; | 587 continue; |
643 } | 588 } |
644 | 589 |
645 // Single value field --- overwrite. | 590 base::string16 new_value = profile.GetRawInfo(*iter); |
646 if (!AutofillProfile::SupportsMultiValue(*iter)) { | 591 if (!compare.StringsEqual(GetRawInfo(*iter), new_value)) |
647 base::string16 new_value = profile.GetRawInfo(*iter); | 592 SetRawInfo(*iter, new_value); |
648 if (!compare.StringsEqual(GetRawInfo(*iter), new_value)) | |
649 SetRawInfo(*iter, new_value); | |
650 continue; | |
651 } | |
652 | |
653 // Multi value field --- overwrite/append. | |
654 std::vector<base::string16> new_values; | |
655 profile.GetRawMultiInfo(*iter, &new_values); | |
656 std::vector<base::string16> existing_values; | |
657 GetRawMultiInfo(*iter, &existing_values); | |
658 | |
659 // GetMultiInfo always returns at least one element, even if the profile | |
660 // has no data stored for this field type. | |
661 if (existing_values.size() == 1 && existing_values.front().empty()) | |
662 existing_values.clear(); | |
663 | |
664 for (std::vector<base::string16>::iterator value_iter = | |
665 new_values.begin(); | |
666 value_iter != new_values.end(); ++value_iter) { | |
667 // Don't add duplicates. Most types get case insensitive matching. | |
668 std::vector<base::string16>::const_iterator existing_iter; | |
669 | |
670 if (group == PHONE_HOME) { | |
671 // Phones allow "fuzzy" matching, so "1-800-FLOWERS", "18003569377", | |
672 // "(800)356-9377" and "356-9377" are considered the same. | |
673 std::string country_code = | |
674 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)); | |
675 existing_iter = | |
676 std::find_if(existing_values.begin(), existing_values.end(), | |
677 FindByPhone(*value_iter, country_code, app_locale)); | |
678 } else { | |
679 existing_iter = | |
680 std::find_if(existing_values.begin(), existing_values.end(), | |
681 [&compare, value_iter](base::string16& rhs) { | |
682 return compare.StringsEqual(*value_iter, rhs); | |
683 }); | |
684 } | |
685 | |
686 if (existing_iter == existing_values.end()) | |
687 existing_values.insert(existing_values.end(), *value_iter); | |
688 } | |
689 | |
690 SetRawMultiInfo(*iter, existing_values); | |
691 } | 593 } |
692 } | 594 } |
693 | 595 |
| 596 bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile, |
| 597 const std::string& app_locale) { |
| 598 ServerFieldTypeSet field_types, other_field_types; |
| 599 GetNonEmptyTypes(app_locale, &field_types); |
| 600 profile.GetNonEmptyTypes(app_locale, &other_field_types); |
| 601 // See note in OverwriteWith. |
| 602 field_types.erase(ADDRESS_HOME_STREET_ADDRESS); |
| 603 l10n::CaseInsensitiveCompare compare; |
| 604 for (ServerFieldType field_type : field_types) { |
| 605 if (other_field_types.count(field_type)) { |
| 606 AutofillType type = AutofillType(field_type); |
| 607 if (type.group() == NAME && |
| 608 compare.StringsEqual( |
| 609 profile.GetInfo(AutofillType(NAME_FULL), app_locale), |
| 610 GetInfo(AutofillType(NAME_FULL), app_locale))) { |
| 611 continue; |
| 612 } |
| 613 if (type.group() == PHONE_HOME && |
| 614 i18n::PhoneNumbersMatch( |
| 615 GetRawInfo(PHONE_HOME_WHOLE_NUMBER), |
| 616 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER), |
| 617 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)), |
| 618 app_locale)) { |
| 619 continue; |
| 620 } |
| 621 if (!compare.StringsEqual(profile.GetRawInfo(field_type), |
| 622 GetRawInfo(field_type))) { |
| 623 return false; |
| 624 } |
| 625 } |
| 626 } |
| 627 |
| 628 if (!IsVerified() || profile.IsVerified()) |
| 629 OverwriteWith(profile, app_locale); |
| 630 return true; |
| 631 } |
| 632 |
694 // static | 633 // static |
695 bool AutofillProfile::SupportsMultiValue(ServerFieldType type) { | 634 bool AutofillProfile::SupportsMultiValue(ServerFieldType type) { |
696 FieldTypeGroup group = AutofillType(type).group(); | 635 FieldTypeGroup group = AutofillType(type).group(); |
697 return group == NAME || | 636 return group == NAME || |
698 group == NAME_BILLING || | 637 group == NAME_BILLING || |
699 group == EMAIL || | 638 group == EMAIL || |
700 group == PHONE_HOME || | 639 group == PHONE_HOME || |
701 group == PHONE_BILLING; | 640 group == PHONE_BILLING; |
702 } | 641 } |
703 | 642 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 FormGroupList info = FormGroups(); | 784 FormGroupList info = FormGroups(); |
846 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) | 785 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) |
847 (*it)->GetSupportedTypes(supported_types); | 786 (*it)->GetSupportedTypes(supported_types); |
848 } | 787 } |
849 | 788 |
850 void AutofillProfile::GetMultiInfoImpl( | 789 void AutofillProfile::GetMultiInfoImpl( |
851 const AutofillType& type, | 790 const AutofillType& type, |
852 const std::string& app_locale, | 791 const std::string& app_locale, |
853 std::vector<base::string16>* values) const { | 792 std::vector<base::string16>* values) const { |
854 switch (type.group()) { | 793 switch (type.group()) { |
855 case NAME: | |
856 case NAME_BILLING: | |
857 CopyItemsToValues(type, name_, app_locale, values); | |
858 break; | |
859 case EMAIL: | 794 case EMAIL: |
860 CopyItemsToValues(type, email_, app_locale, values); | 795 CopyItemsToValues(type, email_, app_locale, values); |
861 break; | 796 break; |
862 case PHONE_HOME: | 797 case PHONE_HOME: |
863 case PHONE_BILLING: | 798 case PHONE_BILLING: |
864 CopyItemsToValues(type, phone_number_, app_locale, values); | 799 CopyItemsToValues(type, phone_number_, app_locale, values); |
865 break; | 800 break; |
866 default: | 801 default: |
867 values->resize(1); | 802 values->resize(1); |
868 (*values)[0] = GetFormGroupInfo(*this, type, app_locale); | 803 (*values)[0] = GetFormGroupInfo(*this, type, app_locale); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 break; | 950 break; |
1016 } | 951 } |
1017 | 952 |
1018 (*labels)[*it] = profile->ConstructInferredLabel( | 953 (*labels)[*it] = profile->ConstructInferredLabel( |
1019 label_fields, label_fields.size(), app_locale); | 954 label_fields, label_fields.size(), app_locale); |
1020 } | 955 } |
1021 } | 956 } |
1022 | 957 |
1023 AutofillProfile::FormGroupList AutofillProfile::FormGroups() const { | 958 AutofillProfile::FormGroupList AutofillProfile::FormGroups() const { |
1024 FormGroupList v(5); | 959 FormGroupList v(5); |
1025 v[0] = &name_[0]; | 960 v[0] = &name_; |
1026 v[1] = &email_[0]; | 961 v[1] = &email_[0]; |
1027 v[2] = &company_; | 962 v[2] = &company_; |
1028 v[3] = &phone_number_[0]; | 963 v[3] = &phone_number_[0]; |
1029 v[4] = &address_; | 964 v[4] = &address_; |
1030 return v; | 965 return v; |
1031 } | 966 } |
1032 | 967 |
1033 const FormGroup* AutofillProfile::FormGroupForType( | 968 const FormGroup* AutofillProfile::FormGroupForType( |
1034 const AutofillType& type) const { | 969 const AutofillType& type) const { |
1035 return const_cast<AutofillProfile*>(this)->MutableFormGroupForType(type); | 970 return const_cast<AutofillProfile*>(this)->MutableFormGroupForType(type); |
1036 } | 971 } |
1037 | 972 |
1038 FormGroup* AutofillProfile::MutableFormGroupForType(const AutofillType& type) { | 973 FormGroup* AutofillProfile::MutableFormGroupForType(const AutofillType& type) { |
1039 switch (type.group()) { | 974 switch (type.group()) { |
1040 case NAME: | 975 case NAME: |
1041 case NAME_BILLING: | 976 case NAME_BILLING: |
1042 return &name_[0]; | 977 return &name_; |
1043 | 978 |
1044 case EMAIL: | 979 case EMAIL: |
1045 return &email_[0]; | 980 return &email_[0]; |
1046 | 981 |
1047 case COMPANY: | 982 case COMPANY: |
1048 return &company_; | 983 return &company_; |
1049 | 984 |
1050 case PHONE_HOME: | 985 case PHONE_HOME: |
1051 case PHONE_BILLING: | 986 case PHONE_BILLING: |
1052 return &phone_number_[0]; | 987 return &phone_number_[0]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) | 1040 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) |
1106 << " " | 1041 << " " |
1107 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) | 1042 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) |
1108 << " " | 1043 << " " |
1109 << profile.language_code() | 1044 << profile.language_code() |
1110 << " " | 1045 << " " |
1111 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); | 1046 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); |
1112 } | 1047 } |
1113 | 1048 |
1114 } // namespace autofill | 1049 } // namespace autofill |
OLD | NEW |