Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: components/autofill/core/browser/autofill_profile.cc

Issue 1143253012: More work on removing variants from Autofill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self review Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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;
please use gerrit instead 2015/06/04 23:24:28 FYI, CaseInsensitiveCompare is surprisingly slow t
Evan Stade 2015/06/05 00:39:08 I don't think this is called that often
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 the
please use gerrit instead 2015/06/04 23:24:28 Did you forget "as" between "string" and "the"?
Evan Stade 2015/06/05 00:39:08 Done.
541 // name for this profile. Because full names are
542 // _heuristically_ parsed into {first, middle, last} name components,
543 // it's possible that either the existing name or the imported name
544 // was misparsed. Prefer to keep the name whose {first, middle,
545 // last} components do not match those computed by the heuristic
546 // parse, as this more likely represents the correct, user-input parse
547 // of the name.
548 NameInfo heuristically_parsed_name;
549 heuristically_parsed_name.SetInfo(type, full_name, app_locale);
550 if (imported_name.ParsedNamesAreEqual(heuristically_parsed_name))
551 return;
552 }
553
554 name_ = imported_name;
609 } 555 }
610 556
611 void AutofillProfile::OverwriteWithOrAddTo(const AutofillProfile& profile, 557 void AutofillProfile::OverwriteWith(const AutofillProfile& profile,
612 const std::string& app_locale) { 558 const std::string& app_locale) {
613 // Verified profiles should never be overwritten with unverified data. 559 // Verified profiles should never be overwritten with unverified data.
614 DCHECK(!IsVerified() || profile.IsVerified()); 560 DCHECK(!IsVerified() || profile.IsVerified());
615 set_origin(profile.origin()); 561 set_origin(profile.origin());
616 set_language_code(profile.language_code()); 562 set_language_code(profile.language_code());
617 set_use_count(profile.use_count() + use_count()); 563 set_use_count(profile.use_count() + use_count());
618 if (profile.use_date() > use_date()) 564 if (profile.use_date() > use_date())
619 set_use_date(profile.use_date()); 565 set_use_date(profile.use_date());
620 566
621 ServerFieldTypeSet field_types; 567 ServerFieldTypeSet field_types;
622 profile.GetNonEmptyTypes(app_locale, &field_types); 568 profile.GetNonEmptyTypes(app_locale, &field_types);
623 569
624 // Only transfer "full" types (e.g. full name) and not fragments (e.g. 570 // Only transfer "full" types (e.g. full name) and not fragments (e.g.
625 // first name, last name). 571 // first name, last name).
626 CollapseCompoundFieldTypes(&field_types); 572 CollapseCompoundFieldTypes(&field_types);
627 573
628 // TODO(isherman): Revisit this decision in the context of i18n and storing 574 // 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. 575 // full addresses rather than storing 1-to-2 lines of an address.
630 // For addresses, do the opposite: transfer individual address lines, rather 576 // For addresses, do the opposite: transfer individual address lines, rather
631 // than full addresses. 577 // than full addresses.
632 field_types.erase(ADDRESS_HOME_STREET_ADDRESS); 578 field_types.erase(ADDRESS_HOME_STREET_ADDRESS);
633 579
634 l10n::CaseInsensitiveCompare compare; 580 l10n::CaseInsensitiveCompare compare;
635 581
636 for (ServerFieldTypeSet::const_iterator iter = field_types.begin(); 582 for (ServerFieldTypeSet::const_iterator iter = field_types.begin();
637 iter != field_types.end(); ++iter) { 583 iter != field_types.end(); ++iter) {
638 FieldTypeGroup group = AutofillType(*iter).group(); 584 FieldTypeGroup group = AutofillType(*iter).group();
639 // Special case names. 585 // Special case names.
640 if (group == NAME) { 586 if (group == NAME) {
641 OverwriteOrAppendNames(profile.name_, app_locale); 587 OverwriteName(profile.name_, app_locale);
642 continue; 588 continue;
643 } 589 }
644 590
645 // Single value field --- overwrite. 591 base::string16 new_value = profile.GetRawInfo(*iter);
646 if (!AutofillProfile::SupportsMultiValue(*iter)) { 592 if (!compare.StringsEqual(GetRawInfo(*iter), new_value))
647 base::string16 new_value = profile.GetRawInfo(*iter); 593 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 } 594 }
692 } 595 }
693 596
597 bool AutofillProfile::SaveAdditionalInfo(const AutofillProfile& profile,
598 const std::string& app_locale) {
599 ServerFieldTypeSet field_types, other_field_types;
600 GetNonEmptyTypes(app_locale, &field_types);
601 profile.GetNonEmptyTypes(app_locale, &other_field_types);
602 // See note in OverwriteWith.
603 field_types.erase(ADDRESS_HOME_STREET_ADDRESS);
604 l10n::CaseInsensitiveCompare compare;
605 for (ServerFieldType field_type : field_types) {
606 if (other_field_types.count(field_type)) {
607 AutofillType type = AutofillType(field_type);
608 if (type.group() == NAME &&
609 compare.StringsEqual(
610 profile.GetInfo(AutofillType(NAME_FULL), app_locale),
611 GetInfo(AutofillType(NAME_FULL), app_locale))) {
612 continue;
613 }
614 if (type.group() == PHONE_HOME &&
615 i18n::PhoneNumbersMatch(
616 GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
617 profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER),
618 base::UTF16ToASCII(GetRawInfo(ADDRESS_HOME_COUNTRY)),
619 app_locale)) {
620 continue;
621 }
622 if (!compare.StringsEqual(profile.GetRawInfo(field_type),
623 GetRawInfo(field_type))) {
624 return false;
625 }
626 }
627 }
628
629 if (!IsVerified() || profile.IsVerified())
630 OverwriteWith(profile, app_locale);
631 return true;
632 }
633
694 // static 634 // static
695 bool AutofillProfile::SupportsMultiValue(ServerFieldType type) { 635 bool AutofillProfile::SupportsMultiValue(ServerFieldType type) {
696 FieldTypeGroup group = AutofillType(type).group(); 636 FieldTypeGroup group = AutofillType(type).group();
697 return group == NAME || 637 return group == NAME ||
698 group == NAME_BILLING || 638 group == NAME_BILLING ||
699 group == EMAIL || 639 group == EMAIL ||
700 group == PHONE_HOME || 640 group == PHONE_HOME ||
701 group == PHONE_BILLING; 641 group == PHONE_BILLING;
702 } 642 }
703 643
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 FormGroupList info = FormGroups(); 785 FormGroupList info = FormGroups();
846 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it) 786 for (FormGroupList::const_iterator it = info.begin(); it != info.end(); ++it)
847 (*it)->GetSupportedTypes(supported_types); 787 (*it)->GetSupportedTypes(supported_types);
848 } 788 }
849 789
850 void AutofillProfile::GetMultiInfoImpl( 790 void AutofillProfile::GetMultiInfoImpl(
851 const AutofillType& type, 791 const AutofillType& type,
852 const std::string& app_locale, 792 const std::string& app_locale,
853 std::vector<base::string16>* values) const { 793 std::vector<base::string16>* values) const {
854 switch (type.group()) { 794 switch (type.group()) {
855 case NAME:
856 case NAME_BILLING:
857 CopyItemsToValues(type, name_, app_locale, values);
858 break;
859 case EMAIL: 795 case EMAIL:
860 CopyItemsToValues(type, email_, app_locale, values); 796 CopyItemsToValues(type, email_, app_locale, values);
861 break; 797 break;
862 case PHONE_HOME: 798 case PHONE_HOME:
863 case PHONE_BILLING: 799 case PHONE_BILLING:
864 CopyItemsToValues(type, phone_number_, app_locale, values); 800 CopyItemsToValues(type, phone_number_, app_locale, values);
865 break; 801 break;
866 default: 802 default:
867 values->resize(1); 803 values->resize(1);
868 (*values)[0] = GetFormGroupInfo(*this, type, app_locale); 804 (*values)[0] = GetFormGroupInfo(*this, type, app_locale);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 break; 951 break;
1016 } 952 }
1017 953
1018 (*labels)[*it] = profile->ConstructInferredLabel( 954 (*labels)[*it] = profile->ConstructInferredLabel(
1019 label_fields, label_fields.size(), app_locale); 955 label_fields, label_fields.size(), app_locale);
1020 } 956 }
1021 } 957 }
1022 958
1023 AutofillProfile::FormGroupList AutofillProfile::FormGroups() const { 959 AutofillProfile::FormGroupList AutofillProfile::FormGroups() const {
1024 FormGroupList v(5); 960 FormGroupList v(5);
1025 v[0] = &name_[0]; 961 v[0] = &name_;
1026 v[1] = &email_[0]; 962 v[1] = &email_[0];
1027 v[2] = &company_; 963 v[2] = &company_;
1028 v[3] = &phone_number_[0]; 964 v[3] = &phone_number_[0];
1029 v[4] = &address_; 965 v[4] = &address_;
1030 return v; 966 return v;
1031 } 967 }
1032 968
1033 const FormGroup* AutofillProfile::FormGroupForType( 969 const FormGroup* AutofillProfile::FormGroupForType(
1034 const AutofillType& type) const { 970 const AutofillType& type) const {
1035 return const_cast<AutofillProfile*>(this)->MutableFormGroupForType(type); 971 return const_cast<AutofillProfile*>(this)->MutableFormGroupForType(type);
1036 } 972 }
1037 973
1038 FormGroup* AutofillProfile::MutableFormGroupForType(const AutofillType& type) { 974 FormGroup* AutofillProfile::MutableFormGroupForType(const AutofillType& type) {
1039 switch (type.group()) { 975 switch (type.group()) {
1040 case NAME: 976 case NAME:
1041 case NAME_BILLING: 977 case NAME_BILLING:
1042 return &name_[0]; 978 return &name_;
1043 979
1044 case EMAIL: 980 case EMAIL:
1045 return &email_[0]; 981 return &email_[0];
1046 982
1047 case COMPANY: 983 case COMPANY:
1048 return &company_; 984 return &company_;
1049 985
1050 case PHONE_HOME: 986 case PHONE_HOME:
1051 case PHONE_BILLING: 987 case PHONE_BILLING:
1052 return &phone_number_[0]; 988 return &phone_number_[0];
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)) 1041 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))
1106 << " " 1042 << " "
1107 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)) 1043 << UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))
1108 << " " 1044 << " "
1109 << profile.language_code() 1045 << profile.language_code()
1110 << " " 1046 << " "
1111 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER)); 1047 << UTF16ToUTF8(MultiString(profile, PHONE_HOME_WHOLE_NUMBER));
1112 } 1048 }
1113 1049
1114 } // namespace autofill 1050 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698