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

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: Changes as per review comments. 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 name, email, and phone fields.
328 diff = UpdateMultivaluedField(NAME_FIRST, 328 diff = UpdateField(NAME_FIRST,
329 specifics.name_first(), profile) || diff; 329 specifics.name_first().size() ? specifics.name_first(0)
330 diff = UpdateMultivaluedField(NAME_MIDDLE, 330 : std::string(), profile) ||
Evan Stade 2015/07/09 19:06:55 regardless of whether this is git cl formatted, th
Deepak 2015/07/10 06:09:54 Done.
331 specifics.name_middle(), profile) || diff; 331 diff;
332 diff = UpdateMultivaluedField(NAME_LAST, 332 diff = UpdateField(NAME_MIDDLE,
333 specifics.name_last(), profile) || diff; 333 specifics.name_middle().size() ? specifics.name_middle(0)
334 : std::string(), profile) ||
335 diff;
336 diff = UpdateField(NAME_LAST,
337 specifics.name_last().size() ? specifics.name_last(0)
338 : std::string(), profile) ||
339 diff;
334 // Older versions don't have a separate full name; don't overwrite full name 340 // Older versions don't have a separate full name; don't overwrite full name
335 // in this case. 341 // in this case.
336 if (specifics.name_full().size() > 0) { 342 if (specifics.name_full().size() > 0) {
337 diff = UpdateMultivaluedField(NAME_FULL, 343 diff = UpdateField(NAME_FULL,
338 specifics.name_full(), profile) || diff; 344 specifics.name_full().size() ? specifics.name_full(0)
345 : std::string(), profile) ||
346 diff;
339 } 347 }
340 diff = UpdateMultivaluedField(EMAIL_ADDRESS, 348 diff = UpdateField(EMAIL_ADDRESS, specifics.email_address().size()
341 specifics.email_address(), profile) || diff; 349 ? specifics.email_address(0)
342 diff = UpdateMultivaluedField(PHONE_HOME_WHOLE_NUMBER, 350 : std::string(), profile) ||
343 specifics.phone_home_whole_number(), 351 diff;
344 profile) || diff; 352 diff = UpdateField(PHONE_HOME_WHOLE_NUMBER,
353 specifics.phone_home_whole_number().size()
354 ? specifics.phone_home_whole_number(0)
355 : std::string(), profile) ||
356 diff;
345 357
346 // Update all simple single-valued address fields. 358 // Update all simple single-valued address fields.
347 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff; 359 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff;
348 diff = UpdateField(ADDRESS_HOME_CITY, 360 diff = UpdateField(ADDRESS_HOME_CITY,
349 specifics.address_home_city(), profile) || diff; 361 specifics.address_home_city(), profile) || diff;
350 diff = UpdateField(ADDRESS_HOME_STATE, 362 diff = UpdateField(ADDRESS_HOME_STATE,
351 specifics.address_home_state(), profile) || diff; 363 specifics.address_home_state(), profile) || diff;
352 diff = UpdateField(ADDRESS_HOME_ZIP, 364 diff = UpdateField(ADDRESS_HOME_ZIP,
353 specifics.address_home_zip(), profile) || diff; 365 specifics.address_home_zip(), profile) || diff;
354 diff = UpdateField(ADDRESS_HOME_SORTING_CODE, 366 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( 461 specifics->set_address_home_sorting_code(
450 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE)))); 462 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))));
451 specifics->set_address_home_dependent_locality( 463 specifics->set_address_home_dependent_locality(
452 LimitData( 464 LimitData(
453 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY)))); 465 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY))));
454 specifics->set_address_home_language_code(LimitData(profile.language_code())); 466 specifics->set_address_home_language_code(LimitData(profile.language_code()));
455 467
456 // TODO(estade): this should be set_email_address. 468 // TODO(estade): this should be set_email_address.
457 specifics->add_email_address( 469 specifics->add_email_address(
458 LimitData(UTF16ToUTF8(profile.GetRawInfo(EMAIL_ADDRESS)))); 470 LimitData(UTF16ToUTF8(profile.GetRawInfo(EMAIL_ADDRESS))));
459 std::vector<base::string16> values;
460 471
461 specifics->set_company_name( 472 specifics->set_company_name(
462 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME)))); 473 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME))));
463 474
464 // TODO(estade): this should be set_phone_home_whole_number. 475 // TODO(estade): this should be set_phone_home_whole_number.
465 specifics->add_phone_home_whole_number( 476 specifics->add_phone_home_whole_number(
466 LimitData(UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)))); 477 LimitData(UTF16ToUTF8(profile.GetRawInfo(PHONE_HOME_WHOLE_NUMBER))));
467 } 478 }
468 479
469 void AutofillProfileSyncableService::CreateGUIDToProfileMap( 480 void AutofillProfileSyncableService::CreateGUIDToProfileMap(
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 bool AutofillProfileSyncableService::UpdateField( 628 bool AutofillProfileSyncableService::UpdateField(
618 ServerFieldType field_type, 629 ServerFieldType field_type,
619 const std::string& new_value, 630 const std::string& new_value,
620 AutofillProfile* autofill_profile) { 631 AutofillProfile* autofill_profile) {
621 if (UTF16ToUTF8(autofill_profile->GetRawInfo(field_type)) == new_value) 632 if (UTF16ToUTF8(autofill_profile->GetRawInfo(field_type)) == new_value)
622 return false; 633 return false;
623 autofill_profile->SetRawInfo(field_type, UTF8ToUTF16(new_value)); 634 autofill_profile->SetRawInfo(field_type, UTF8ToUTF16(new_value));
624 return true; 635 return true;
625 } 636 }
626 637
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( 638 bool AutofillProfileSyncableService::MergeProfile(
638 const AutofillProfile& merge_from, 639 const AutofillProfile& merge_from,
639 AutofillProfile* merge_into, 640 AutofillProfile* merge_into,
640 const std::string& app_locale) { 641 const std::string& app_locale) {
641 // Overwrites all values. Does not overwrite GUID. 642 // Overwrites all values. Does not overwrite GUID.
642 merge_into->OverwriteWith(merge_from, app_locale); 643 merge_into->OverwriteWith(merge_from, app_locale);
643 return !merge_into->EqualsForSyncPurposes(merge_from); 644 return !merge_into->EqualsForSyncPurposes(merge_from);
644 } 645 }
645 646
646 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const { 647 AutofillTable* AutofillProfileSyncableService::GetAutofillTable() const {
647 return AutofillTable::FromWebDatabase(webdata_backend_->GetDatabase()); 648 return AutofillTable::FromWebDatabase(webdata_backend_->GetDatabase());
648 } 649 }
649 650
650 void AutofillProfileSyncableService::InjectStartSyncFlare( 651 void AutofillProfileSyncableService::InjectStartSyncFlare(
651 const syncer::SyncableService::StartSyncFlare& flare) { 652 const syncer::SyncableService::StartSyncFlare& flare) {
652 flare_ = flare; 653 flare_ = flare;
653 } 654 }
654 655
655 AutofillProfileSyncableService::DataBundle::DataBundle() {} 656 AutofillProfileSyncableService::DataBundle::DataBundle() {}
656 657
657 AutofillProfileSyncableService::DataBundle::~DataBundle() {} 658 AutofillProfileSyncableService::DataBundle::~DataBundle() {}
658 659
659 } // namespace autofill 660 } // 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