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

Side by Side Diff: chrome/browser/webdata/autofill_profile_syncable_service.cc

Issue 127403002: [Autofill, Sync] Sync additional Autofill address fields for i18n. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/webdata/autofill_profile_syncable_service.h" 5 #include "chrome/browser/webdata/autofill_profile_syncable_service.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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 diff = UpdateMultivaluedField(NAME_LAST, 337 diff = UpdateMultivaluedField(NAME_LAST,
338 specifics.name_last(), profile) || diff; 338 specifics.name_last(), profile) || diff;
339 diff = UpdateMultivaluedField(EMAIL_ADDRESS, 339 diff = UpdateMultivaluedField(EMAIL_ADDRESS,
340 specifics.email_address(), profile) || diff; 340 specifics.email_address(), profile) || diff;
341 diff = UpdateMultivaluedField(PHONE_HOME_WHOLE_NUMBER, 341 diff = UpdateMultivaluedField(PHONE_HOME_WHOLE_NUMBER,
342 specifics.phone_home_whole_number(), 342 specifics.phone_home_whole_number(),
343 profile) || diff; 343 profile) || diff;
344 344
345 // Update all simple single-valued address fields. 345 // Update all simple single-valued address fields.
346 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff; 346 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff;
347 diff = UpdateField(ADDRESS_HOME_LINE1,
348 specifics.address_home_line1(), profile) || diff;
349 diff = UpdateField(ADDRESS_HOME_LINE2,
350 specifics.address_home_line2(), profile) || diff;
351 diff = UpdateField(ADDRESS_HOME_CITY, 347 diff = UpdateField(ADDRESS_HOME_CITY,
352 specifics.address_home_city(), profile) || diff; 348 specifics.address_home_city(), profile) || diff;
353 diff = UpdateField(ADDRESS_HOME_STATE, 349 diff = UpdateField(ADDRESS_HOME_STATE,
354 specifics.address_home_state(), profile) || diff; 350 specifics.address_home_state(), profile) || diff;
355 diff = UpdateField(ADDRESS_HOME_ZIP, 351 diff = UpdateField(ADDRESS_HOME_ZIP,
356 specifics.address_home_zip(), profile) || diff; 352 specifics.address_home_zip(), profile) || diff;
353 diff = UpdateField(ADDRESS_HOME_SORTING_CODE,
354 specifics.address_home_sorting_code(), profile) || diff;
355 diff = UpdateField(ADDRESS_HOME_DEPENDENT_LOCALITY,
356 specifics.address_home_dependent_locality(),
357 profile) || diff;
357 358
358 // Update the country field, which can contain either a country code (if set 359 // Update the country field, which can contain either a country code (if set
359 // by a newer version of Chrome), or a country name (if set by an older 360 // by a newer version of Chrome), or a country name (if set by an older
360 // version of Chrome). 361 // version of Chrome).
361 base::string16 country_name_or_code = 362 base::string16 country_name_or_code =
362 ASCIIToUTF16(specifics.address_home_country()); 363 ASCIIToUTF16(specifics.address_home_country());
363 std::string country_code = 364 std::string country_code =
364 AutofillCountry::GetCountryCode(country_name_or_code, app_locale); 365 AutofillCountry::GetCountryCode(country_name_or_code, app_locale);
365 diff = UpdateField(ADDRESS_HOME_COUNTRY, country_code, profile) || diff; 366 diff = UpdateField(ADDRESS_HOME_COUNTRY, country_code, profile) || diff;
366 367
368 // Update the street address. In newer versions of Chrome (M34+), this data
369 // is stored in the |address_home_street_address| field. In older versions,
370 // this data is stored separated out by address line.
371 if (specifics.has_address_home_street_address()) {
372 diff = UpdateField(ADDRESS_HOME_STREET_ADDRESS,
373 specifics.address_home_street_address(),
374 profile) || diff;
375 } else {
376 diff = UpdateField(ADDRESS_HOME_LINE1,
377 specifics.address_home_line1(), profile) || diff;
378 diff = UpdateField(ADDRESS_HOME_LINE2,
379 specifics.address_home_line2(), profile) || diff;
380 }
367 return diff; 381 return diff;
368 } 382 }
369 383
370 // static 384 // static
371 void AutofillProfileSyncableService::WriteAutofillProfile( 385 void AutofillProfileSyncableService::WriteAutofillProfile(
372 const AutofillProfile& profile, 386 const AutofillProfile& profile,
373 sync_pb::EntitySpecifics* profile_specifics) { 387 sync_pb::EntitySpecifics* profile_specifics) {
374 sync_pb::AutofillProfileSpecifics* specifics = 388 sync_pb::AutofillProfileSpecifics* specifics =
375 profile_specifics->mutable_autofill_profile(); 389 profile_specifics->mutable_autofill_profile();
376 390
(...skipping 30 matching lines...) Expand all
407 specifics->set_address_home_line2( 421 specifics->set_address_home_line2(
408 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_LINE2)))); 422 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_LINE2))));
409 specifics->set_address_home_city( 423 specifics->set_address_home_city(
410 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)))); 424 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY))));
411 specifics->set_address_home_state( 425 specifics->set_address_home_state(
412 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)))); 426 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE))));
413 specifics->set_address_home_zip( 427 specifics->set_address_home_zip(
414 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)))); 428 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP))));
415 specifics->set_address_home_country( 429 specifics->set_address_home_country(
416 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)))); 430 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY))));
431 specifics->set_address_home_street_address(
432 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS))));
433 specifics->set_address_home_sorting_code(
434 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_SORTING_CODE))));
435 specifics->set_address_home_dependent_locality(
436 LimitData(
437 UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_DEPENDENT_LOCALITY))));
417 438
418 profile.GetRawMultiInfo(EMAIL_ADDRESS, &values); 439 profile.GetRawMultiInfo(EMAIL_ADDRESS, &values);
419 for (size_t i = 0; i < values.size(); ++i) { 440 for (size_t i = 0; i < values.size(); ++i) {
420 specifics->add_email_address(LimitData(UTF16ToUTF8(values[i]))); 441 specifics->add_email_address(LimitData(UTF16ToUTF8(values[i])));
421 } 442 }
422 443
423 specifics->set_company_name( 444 specifics->set_company_name(
424 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME)))); 445 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME))));
425 446
426 profile.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); 447 profile.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 void AutofillProfileSyncableService::InjectStartSyncFlare( 641 void AutofillProfileSyncableService::InjectStartSyncFlare(
621 const syncer::SyncableService::StartSyncFlare& flare) { 642 const syncer::SyncableService::StartSyncFlare& flare) {
622 flare_ = flare; 643 flare_ = flare;
623 } 644 }
624 645
625 AutofillProfileSyncableService::DataBundle::DataBundle() {} 646 AutofillProfileSyncableService::DataBundle::DataBundle() {}
626 647
627 AutofillProfileSyncableService::DataBundle::~DataBundle() {} 648 AutofillProfileSyncableService::DataBundle::~DataBundle() {}
628 649
629 } // namespace autofill 650 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/webdata/autofill_profile_syncable_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698