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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_profile_syncable_service.cc

Issue 1212733005: Removal of UpdateMultivaluedField() as we now don't have multiple values for name,email and phone n… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_profile_syncable_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/webdata/autofill_profile_syncable_ser vice.h" 5 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 bool diff = false; 317 bool diff = false;
318 if (specifics.has_origin() && profile->origin() != specifics.origin()) { 318 if (specifics.has_origin() && profile->origin() != specifics.origin()) {
319 bool was_verified = profile->IsVerified(); 319 bool was_verified = profile->IsVerified();
320 profile->set_origin(specifics.origin()); 320 profile->set_origin(specifics.origin());
321 diff = true; 321 diff = true;
322 322
323 // Verified profiles should never be overwritten by unverified ones. 323 // Verified profiles should never be overwritten by unverified ones.
324 DCHECK(!was_verified || profile->IsVerified()); 324 DCHECK(!was_verified || profile->IsVerified());
325 } 325 }
326 326
327 // Update all multivalued fields: names, emails, and phones. 327 // Update all multivalued fields: names, emails, and phones.
vabr (Chromium) 2015/07/08 13:20:04 The comment looks obsolete, please update.
Deepak 2015/07/08 14:53:36 Done.
328 diff = UpdateMultivaluedField(NAME_FIRST, 328 ::google::protobuf::RepeatedPtrField<std::string> values =
329 specifics.name_first(), profile) || diff; 329 specifics.name_first();
330 diff = UpdateMultivaluedField(NAME_MIDDLE, 330 diff =
331 specifics.name_middle(), profile) || diff; 331 UpdateField(NAME_FIRST, values.size() < 1 ? std::string() : values.Get(0),
332 diff = UpdateMultivaluedField(NAME_LAST, 332 profile) || diff;
333 specifics.name_last(), profile) || diff; 333 values = specifics.name_middle();
334 diff =
335 UpdateField(NAME_MIDDLE,
336 values.size() < 1 ? std::string() : values.Get(0),
337 profile) || diff;
338 values = specifics.name_last();
339 diff =
340 UpdateField(NAME_LAST, values.size() < 1 ? std::string() : values.Get(0),
341 profile) || diff;
334 // Older versions don't have a separate full name; don't overwrite full name 342 // Older versions don't have a separate full name; don't overwrite full name
335 // in this case. 343 // in this case.
336 if (specifics.name_full().size() > 0) { 344 if (specifics.name_full().size() > 0) {
337 diff = UpdateMultivaluedField(NAME_FULL, 345 values = specifics.name_full();
338 specifics.name_full(), profile) || diff; 346 diff = UpdateField(NAME_FULL,
347 values.size() < 1 ? std::string() : values.Get(0),
348 profile) || diff;
339 } 349 }
340 diff = UpdateMultivaluedField(EMAIL_ADDRESS, 350 values = specifics.email_address();
341 specifics.email_address(), profile) || diff; 351 diff =
342 diff = UpdateMultivaluedField(PHONE_HOME_WHOLE_NUMBER, 352 UpdateField(EMAIL_ADDRESS,
343 specifics.phone_home_whole_number(), 353 values.size() < 1 ? std::string() : values.Get(0),
344 profile) || diff; 354 profile) || diff;
355 values = specifics.phone_home_whole_number();
356 diff =
357 UpdateField(PHONE_HOME_WHOLE_NUMBER,
358 values.size() < 1 ? std::string() : values.Get(0),
359 profile) || diff;
345 360
346 // Update all simple single-valued address fields. 361 // Update all simple single-valued address fields.
347 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff; 362 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff;
348 diff = UpdateField(ADDRESS_HOME_CITY, 363 diff = UpdateField(ADDRESS_HOME_CITY,
349 specifics.address_home_city(), profile) || diff; 364 specifics.address_home_city(), profile) || diff;
350 diff = UpdateField(ADDRESS_HOME_STATE, 365 diff = UpdateField(ADDRESS_HOME_STATE,
351 specifics.address_home_state(), profile) || diff; 366 specifics.address_home_state(), profile) || diff;
352 diff = UpdateField(ADDRESS_HOME_ZIP, 367 diff = UpdateField(ADDRESS_HOME_ZIP,
353 specifics.address_home_zip(), profile) || diff; 368 specifics.address_home_zip(), profile) || diff;
354 diff = UpdateField(ADDRESS_HOME_SORTING_CODE, 369 diff = UpdateField(ADDRESS_HOME_SORTING_CODE,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 specifics->set_address_home_sorting_code( 464 specifics->set_address_home_sorting_code(
450 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)))); 465 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))));
451 specifics->set_address_home_dependent_locality( 466 specifics->set_address_home_dependent_locality(
452 LimitData( 467 LimitData(
453 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)))); 468 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY))));
454 specifics->set_address_home_language_code(LimitData(profile.language_code())); 469 specifics->set_address_home_language_code(LimitData(profile.language_code()));
455 470
456 // TODO(estade): this should be set_email_address. 471 // TODO(estade): this should be set_email_address.
457 specifics->add_email_address( 472 specifics->add_email_address(
458 LimitData(UTF16ToUTF8(profile.GetRawInfo(EMAIL_ADDRESS)))); 473 LimitData(UTF16ToUTF8(profile.GetRawInfo(EMAIL_ADDRESS))));
459 std::vector<base::string16> values;
460 474
461 specifics->set_company_name( 475 specifics->set_company_name(
462 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME)))); 476 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME))));
463 477
464 // TODO(estade): this should be set_phone_home_whole_number. 478 // TODO(estade): this should be set_phone_home_whole_number.
465 specifics->add_phone_home_whole_number( 479 specifics->add_phone_home_whole_number(
466 LimitData(UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)))); 480 LimitData(UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER))));
467 } 481 }
468 482
469 void AutofillProfileSyncableService::CreateGUIDToProfileMap( 483 void AutofillProfileSyncableService::CreateGUIDToProfileMap(
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 bool AutofillProfileSyncableService::UpdateField( 631 bool AutofillProfileSyncableService::UpdateField(
618 ServerFieldType field_type, 632 ServerFieldType field_type,
619 const std::string& new_value, 633 const std::string& new_value,
620 AutofillProfile* autofill_profile) { 634 AutofillProfile* autofill_profile) {
621 if (UTF16ToUTF8(autofill_profile->GetRawInfo(field_type)) == new_value) 635 if (UTF16ToUTF8(autofill_profile->GetRawInfo(field_type)) == new_value)
622 return false; 636 return false;
623 autofill_profile->SetRawInfo(field_type, UTF8ToUTF16(new_value)); 637 autofill_profile->SetRawInfo(field_type, UTF8ToUTF16(new_value));
624 return true; 638 return true;
625 } 639 }
626 640
627 // TODO(estade): remove this function.
628 bool AutofillProfileSyncableService::UpdateMultivaluedField(
629 ServerFieldType field_type,
630 const ::google::protobuf::RepeatedPtrField<std::string>& new_values,
631 AutofillProfile* autofill_profile) {
632 return UpdateField(field_type,
633 new_values.size() < 1 ? std::string() : new_values.Get(0),
634 autofill_profile);
635 }
636
637 bool AutofillProfileSyncableService::MergeProfile( 641 bool AutofillProfileSyncableService::MergeProfile(
638 const AutofillProfile& merge_from, 642 const AutofillProfile& merge_from,
639 AutofillProfile* merge_into, 643 AutofillProfile* merge_into,
640 const std::string& app_locale) { 644 const std::string& app_locale) {
641 // Overwrites all values. Does not overwrite GUID. 645 // Overwrites all values. Does not overwrite GUID.
642 merge_into->OverwriteWith(merge_from, app_locale); 646 merge_into->OverwriteWith(merge_from, app_locale);
643 return !merge_into->EqualsForSyncPurposes(merge_from); 647 return !merge_into->EqualsForSyncPurposes(merge_from);
644 } 648 }
645 649
646 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { 650 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {
647 return AutofillTable::FromWebDatabase(webdata_backend_->GetDatabase()); 651 return AutofillTable::FromWebDatabase(webdata_backend_->GetDatabase());
648 } 652 }
649 653
650 void AutofillProfileSyncableService::InjectStartSyncFlare( 654 void AutofillProfileSyncableService::InjectStartSyncFlare(
651 const syncer::SyncableService::StartSyncFlare& flare) { 655 const syncer::SyncableService::StartSyncFlare& flare) {
652 flare_ = flare; 656 flare_ = flare;
653 } 657 }
654 658
655 AutofillProfileSyncableService::DataBundle::DataBundle() {} 659 AutofillProfileSyncableService::DataBundle::DataBundle() {}
656 660
657 AutofillProfileSyncableService::DataBundle::~DataBundle() {} 661 AutofillProfileSyncableService::DataBundle::~DataBundle() {}
658 662
659 } // namespace autofill 663 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/webdata/autofill_profile_syncable_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698