OLD | NEW |
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" |
11 #include "components/autofill/core/browser/autofill_country.h" | 11 #include "components/autofill/core/browser/autofill_country.h" |
12 #include "components/autofill/core/browser/autofill_profile.h" | 12 #include "components/autofill/core/browser/autofill_profile.h" |
13 #include "components/autofill/core/browser/form_group.h" | 13 #include "components/autofill/core/browser/form_group.h" |
14 #include "components/autofill/core/browser/webdata/autofill_table.h" | 14 #include "components/autofill/core/browser/webdata/autofill_table.h" |
15 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 15 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
16 #include "components/webdata/common/web_database.h" | 16 #include "components/webdata/common/web_database.h" |
17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
18 #include "sync/api/sync_error.h" | 18 #include "sync/api/sync_error.h" |
19 #include "sync/api/sync_error_factory.h" | 19 #include "sync/api/sync_error_factory.h" |
20 #include "sync/protocol/sync.pb.h" | 20 #include "sync/protocol/sync.pb.h" |
21 | 21 |
22 using base::ASCIIToUTF16; | 22 using base::ASCIIToUTF16; |
23 using base::UTF8ToUTF16; | 23 using base::UTF8ToUTF16; |
24 using base::UTF16ToUTF8; | 24 using base::UTF16ToUTF8; |
25 using autofill::AutofillCountry; | |
26 using autofill::ServerFieldType; | |
27 using autofill::AutofillProfile; | |
28 using autofill::AutofillProfileChange; | |
29 using autofill::AutofillTable; | |
30 using autofill::AutofillWebDataService; | |
31 using content::BrowserThread; | 25 using content::BrowserThread; |
32 | 26 |
| 27 namespace autofill { |
| 28 |
33 namespace { | 29 namespace { |
34 | 30 |
35 std::string LimitData(const std::string& data) { | 31 std::string LimitData(const std::string& data) { |
36 std::string sanitized_value(data); | 32 std::string sanitized_value(data); |
37 if (sanitized_value.length() > AutofillTable::kMaxDataLength) | 33 if (sanitized_value.length() > AutofillTable::kMaxDataLength) |
38 sanitized_value.resize(AutofillTable::kMaxDataLength); | 34 sanitized_value.resize(AutofillTable::kMaxDataLength); |
39 return sanitized_value; | 35 return sanitized_value; |
40 } | 36 } |
41 | 37 |
42 void* UserDataKey() { | 38 void* UserDataKey() { |
43 // Use the address of a static that COMDAT folding won't ever fold | 39 // Use the address of a static that COMDAT folding won't ever fold |
44 // with something else. | 40 // with something else. |
45 static int user_data_key = 0; | 41 static int user_data_key = 0; |
46 return reinterpret_cast<void*>(&user_data_key); | 42 return reinterpret_cast<void*>(&user_data_key); |
47 } | 43 } |
48 | 44 |
49 } // namespace | 45 } // namespace |
50 | 46 |
51 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles"; | 47 const char kAutofillProfileTag[] = "google_chrome_autofill_profiles"; |
52 | 48 |
53 AutofillProfileSyncableService::AutofillProfileSyncableService( | 49 AutofillProfileSyncableService::AutofillProfileSyncableService( |
54 autofill::AutofillWebDataBackend* webdata_backend, | 50 AutofillWebDataBackend* webdata_backend, |
55 const std::string& app_locale) | 51 const std::string& app_locale) |
56 : webdata_backend_(webdata_backend), | 52 : webdata_backend_(webdata_backend), |
57 app_locale_(app_locale), | 53 app_locale_(app_locale), |
58 scoped_observer_(this) { | 54 scoped_observer_(this) { |
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
60 DCHECK(webdata_backend_); | 56 DCHECK(webdata_backend_); |
61 | 57 |
62 scoped_observer_.Add(webdata_backend_); | 58 scoped_observer_.Add(webdata_backend_); |
63 } | 59 } |
64 | 60 |
65 AutofillProfileSyncableService::~AutofillProfileSyncableService() { | 61 AutofillProfileSyncableService::~AutofillProfileSyncableService() { |
66 DCHECK(CalledOnValidThread()); | 62 DCHECK(CalledOnValidThread()); |
67 } | 63 } |
68 | 64 |
69 // static | 65 // static |
70 void AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( | 66 void AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( |
71 AutofillWebDataService* web_data_service, | 67 AutofillWebDataService* web_data_service, |
72 autofill::AutofillWebDataBackend* webdata_backend, | 68 AutofillWebDataBackend* webdata_backend, |
73 const std::string& app_locale) { | 69 const std::string& app_locale) { |
74 web_data_service->GetDBUserData()->SetUserData( | 70 web_data_service->GetDBUserData()->SetUserData( |
75 UserDataKey(), | 71 UserDataKey(), |
76 new AutofillProfileSyncableService(webdata_backend, app_locale)); | 72 new AutofillProfileSyncableService(webdata_backend, app_locale)); |
77 } | 73 } |
78 | 74 |
79 // static | 75 // static |
80 AutofillProfileSyncableService* | 76 AutofillProfileSyncableService* |
81 AutofillProfileSyncableService::FromWebDataService( | 77 AutofillProfileSyncableService::FromWebDataService( |
82 AutofillWebDataService* web_data_service) { | 78 AutofillWebDataService* web_data_service) { |
(...skipping 28 matching lines...) Expand all Loading... |
111 } | 107 } |
112 | 108 |
113 if (DLOG_IS_ON(INFO)) { | 109 if (DLOG_IS_ON(INFO)) { |
114 DVLOG(2) << "[AUTOFILL MIGRATION]" | 110 DVLOG(2) << "[AUTOFILL MIGRATION]" |
115 << "Printing profiles from web db"; | 111 << "Printing profiles from web db"; |
116 | 112 |
117 for (ScopedVector<AutofillProfile>::const_iterator ix = | 113 for (ScopedVector<AutofillProfile>::const_iterator ix = |
118 profiles_.begin(); ix != profiles_.end(); ++ix) { | 114 profiles_.begin(); ix != profiles_.end(); ++ix) { |
119 AutofillProfile* p = *ix; | 115 AutofillProfile* p = *ix; |
120 DVLOG(2) << "[AUTOFILL MIGRATION] " | 116 DVLOG(2) << "[AUTOFILL MIGRATION] " |
121 << p->GetRawInfo(autofill::NAME_FIRST) | 117 << UTF16ToUTF8(p->GetRawInfo(NAME_FIRST)) |
122 << p->GetRawInfo(autofill::NAME_LAST) | 118 << UTF16ToUTF8(p->GetRawInfo(NAME_LAST)) |
123 << p->guid(); | 119 << p->guid(); |
124 } | 120 } |
125 } | 121 } |
126 | 122 |
127 sync_processor_ = sync_processor.Pass(); | 123 sync_processor_ = sync_processor.Pass(); |
128 | 124 |
129 GUIDToProfileMap remaining_profiles; | 125 GUIDToProfileMap remaining_profiles; |
130 CreateGUIDToProfileMap(profiles_.get(), &remaining_profiles); | 126 CreateGUIDToProfileMap(profiles_.get(), &remaining_profiles); |
131 | 127 |
132 DataBundle bundle; | 128 DataBundle bundle; |
(...skipping 17 matching lines...) Expand all Loading... |
150 for (GUIDToProfileMap::iterator it = bundle.candidates_to_merge.begin(); | 146 for (GUIDToProfileMap::iterator it = bundle.candidates_to_merge.begin(); |
151 it != bundle.candidates_to_merge.end(); ++it) { | 147 it != bundle.candidates_to_merge.end(); ++it) { |
152 GUIDToProfileMap::iterator profile_to_merge = | 148 GUIDToProfileMap::iterator profile_to_merge = |
153 remaining_profiles.find(it->first); | 149 remaining_profiles.find(it->first); |
154 if (profile_to_merge != remaining_profiles.end()) { | 150 if (profile_to_merge != remaining_profiles.end()) { |
155 bundle.profiles_to_delete.push_back(profile_to_merge->second->guid()); | 151 bundle.profiles_to_delete.push_back(profile_to_merge->second->guid()); |
156 if (MergeProfile(*(profile_to_merge->second), it->second, app_locale_)) | 152 if (MergeProfile(*(profile_to_merge->second), it->second, app_locale_)) |
157 bundle.profiles_to_sync_back.push_back(it->second); | 153 bundle.profiles_to_sync_back.push_back(it->second); |
158 DVLOG(2) << "[AUTOFILL SYNC]" | 154 DVLOG(2) << "[AUTOFILL SYNC]" |
159 << "Found similar profile in sync db but with a different guid: " | 155 << "Found similar profile in sync db but with a different guid: " |
160 << UTF16ToUTF8(it->second->GetRawInfo(autofill::NAME_FIRST)) | 156 << UTF16ToUTF8(it->second->GetRawInfo(NAME_FIRST)) |
161 << UTF16ToUTF8(it->second->GetRawInfo(autofill::NAME_LAST)) | 157 << UTF16ToUTF8(it->second->GetRawInfo(NAME_LAST)) |
162 << "New guid " << it->second->guid() | 158 << "New guid " << it->second->guid() |
163 << ". Profile to be deleted " | 159 << ". Profile to be deleted " |
164 << profile_to_merge->second->guid(); | 160 << profile_to_merge->second->guid(); |
165 remaining_profiles.erase(profile_to_merge); | 161 remaining_profiles.erase(profile_to_merge); |
166 } | 162 } |
167 } | 163 } |
168 | 164 |
169 if (!SaveChangesToWebData(bundle)) { | 165 if (!SaveChangesToWebData(bundle)) { |
170 merge_result.set_error(sync_error_factory_->CreateAndUploadError( | 166 merge_result.set_error(sync_error_factory_->CreateAndUploadError( |
171 FROM_HERE, | 167 FROM_HERE, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 287 |
292 bool AutofillProfileSyncableService::LoadAutofillData( | 288 bool AutofillProfileSyncableService::LoadAutofillData( |
293 std::vector<AutofillProfile*>* profiles) { | 289 std::vector<AutofillProfile*>* profiles) { |
294 return GetAutofillTable()->GetAutofillProfiles(profiles); | 290 return GetAutofillTable()->GetAutofillProfiles(profiles); |
295 } | 291 } |
296 | 292 |
297 bool AutofillProfileSyncableService::SaveChangesToWebData( | 293 bool AutofillProfileSyncableService::SaveChangesToWebData( |
298 const DataBundle& bundle) { | 294 const DataBundle& bundle) { |
299 DCHECK(CalledOnValidThread()); | 295 DCHECK(CalledOnValidThread()); |
300 | 296 |
301 autofill::AutofillTable* autofill_table = GetAutofillTable(); | 297 AutofillTable* autofill_table = GetAutofillTable(); |
302 | 298 |
303 bool success = true; | 299 bool success = true; |
304 for (size_t i = 0; i< bundle.profiles_to_delete.size(); ++i) { | 300 for (size_t i = 0; i< bundle.profiles_to_delete.size(); ++i) { |
305 if (!autofill_table->RemoveAutofillProfile(bundle.profiles_to_delete[i])) | 301 if (!autofill_table->RemoveAutofillProfile(bundle.profiles_to_delete[i])) |
306 success = false; | 302 success = false; |
307 } | 303 } |
308 | 304 |
309 for (size_t i = 0; i < bundle.profiles_to_add.size(); i++) { | 305 for (size_t i = 0; i < bundle.profiles_to_add.size(); i++) { |
310 if (!autofill_table->AddAutofillProfile(*bundle.profiles_to_add[i])) | 306 if (!autofill_table->AddAutofillProfile(*bundle.profiles_to_add[i])) |
311 success = false; | 307 success = false; |
(...skipping 14 matching lines...) Expand all Loading... |
326 bool diff = false; | 322 bool diff = false; |
327 if (profile->origin() != specifics.origin()) { | 323 if (profile->origin() != specifics.origin()) { |
328 bool was_verified = profile->IsVerified(); | 324 bool was_verified = profile->IsVerified(); |
329 profile->set_origin(specifics.origin()); | 325 profile->set_origin(specifics.origin()); |
330 diff = true; | 326 diff = true; |
331 | 327 |
332 // Verified profiles should never be overwritten by unverified ones. | 328 // Verified profiles should never be overwritten by unverified ones. |
333 DCHECK(!was_verified || profile->IsVerified()); | 329 DCHECK(!was_verified || profile->IsVerified()); |
334 } | 330 } |
335 | 331 |
336 diff = UpdateMultivaluedField(autofill::NAME_FIRST, | 332 // Update all multivalued fields: names, emails, and phones. |
| 333 diff = UpdateMultivaluedField(NAME_FIRST, |
337 specifics.name_first(), profile) || diff; | 334 specifics.name_first(), profile) || diff; |
338 diff = UpdateMultivaluedField(autofill::NAME_MIDDLE, | 335 diff = UpdateMultivaluedField(NAME_MIDDLE, |
339 specifics.name_middle(), profile) || diff; | 336 specifics.name_middle(), profile) || diff; |
340 diff = UpdateMultivaluedField(autofill::NAME_LAST, | 337 diff = UpdateMultivaluedField(NAME_LAST, |
341 specifics.name_last(), profile) || diff; | 338 specifics.name_last(), profile) || diff; |
342 diff = UpdateField(autofill::ADDRESS_HOME_LINE1, | 339 diff = UpdateMultivaluedField(EMAIL_ADDRESS, |
| 340 specifics.email_address(), profile) || diff; |
| 341 diff = UpdateMultivaluedField(PHONE_HOME_WHOLE_NUMBER, |
| 342 specifics.phone_home_whole_number(), |
| 343 profile) || diff; |
| 344 |
| 345 // Update all simple single-valued address fields. |
| 346 diff = UpdateField(COMPANY_NAME, specifics.company_name(), profile) || diff; |
| 347 diff = UpdateField(ADDRESS_HOME_LINE1, |
343 specifics.address_home_line1(), profile) || diff; | 348 specifics.address_home_line1(), profile) || diff; |
344 diff = UpdateField(autofill::ADDRESS_HOME_LINE2, | 349 diff = UpdateField(ADDRESS_HOME_LINE2, |
345 specifics.address_home_line2(), profile) || diff; | 350 specifics.address_home_line2(), profile) || diff; |
346 diff = UpdateField(autofill::ADDRESS_HOME_CITY, | 351 diff = UpdateField(ADDRESS_HOME_CITY, |
347 specifics.address_home_city(), profile) || diff; | 352 specifics.address_home_city(), profile) || diff; |
348 diff = UpdateField(autofill::ADDRESS_HOME_STATE, | 353 diff = UpdateField(ADDRESS_HOME_STATE, |
349 specifics.address_home_state(), profile) || diff; | 354 specifics.address_home_state(), profile) || diff; |
| 355 diff = UpdateField(ADDRESS_HOME_ZIP, |
| 356 specifics.address_home_zip(), profile) || diff; |
| 357 |
| 358 // 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 // version of Chrome). |
350 base::string16 country_name_or_code = | 361 base::string16 country_name_or_code = |
351 ASCIIToUTF16(specifics.address_home_country()); | 362 ASCIIToUTF16(specifics.address_home_country()); |
352 std::string country_code = AutofillCountry::GetCountryCode( | 363 std::string country_code = |
353 country_name_or_code, app_locale); | 364 AutofillCountry::GetCountryCode(country_name_or_code, app_locale); |
354 diff = UpdateField( | 365 diff = UpdateField(ADDRESS_HOME_COUNTRY, country_code, profile) || diff; |
355 autofill::ADDRESS_HOME_COUNTRY, country_code, profile) || diff; | 366 |
356 diff = UpdateField(autofill::ADDRESS_HOME_ZIP, | |
357 specifics.address_home_zip(), profile) || diff; | |
358 diff = UpdateMultivaluedField(autofill::EMAIL_ADDRESS, | |
359 specifics.email_address(), profile) || diff; | |
360 diff = UpdateField( | |
361 autofill::COMPANY_NAME, specifics.company_name(), profile) || diff; | |
362 diff = UpdateMultivaluedField(autofill::PHONE_HOME_WHOLE_NUMBER, | |
363 specifics.phone_home_whole_number(), | |
364 profile) || diff; | |
365 return diff; | 367 return diff; |
366 } | 368 } |
367 | 369 |
368 // static | 370 // static |
369 void AutofillProfileSyncableService::WriteAutofillProfile( | 371 void AutofillProfileSyncableService::WriteAutofillProfile( |
370 const AutofillProfile& profile, | 372 const AutofillProfile& profile, |
371 sync_pb::EntitySpecifics* profile_specifics) { | 373 sync_pb::EntitySpecifics* profile_specifics) { |
372 sync_pb::AutofillProfileSpecifics* specifics = | 374 sync_pb::AutofillProfileSpecifics* specifics = |
373 profile_specifics->mutable_autofill_profile(); | 375 profile_specifics->mutable_autofill_profile(); |
374 | 376 |
375 DCHECK(base::IsValidGUID(profile.guid())); | 377 DCHECK(base::IsValidGUID(profile.guid())); |
376 | 378 |
377 // Reset all multi-valued fields in the protobuf. | 379 // Reset all multi-valued fields in the protobuf. |
378 specifics->clear_name_first(); | 380 specifics->clear_name_first(); |
379 specifics->clear_name_middle(); | 381 specifics->clear_name_middle(); |
380 specifics->clear_name_last(); | 382 specifics->clear_name_last(); |
381 specifics->clear_email_address(); | 383 specifics->clear_email_address(); |
382 specifics->clear_phone_home_whole_number(); | 384 specifics->clear_phone_home_whole_number(); |
383 | 385 |
384 specifics->set_guid(profile.guid()); | 386 specifics->set_guid(profile.guid()); |
385 specifics->set_origin(profile.origin()); | 387 specifics->set_origin(profile.origin()); |
386 | 388 |
387 std::vector<base::string16> values; | 389 std::vector<base::string16> values; |
388 profile.GetRawMultiInfo(autofill::NAME_FIRST, &values); | 390 profile.GetRawMultiInfo(NAME_FIRST, &values); |
389 for (size_t i = 0; i < values.size(); ++i) { | 391 for (size_t i = 0; i < values.size(); ++i) { |
390 specifics->add_name_first(LimitData(UTF16ToUTF8(values[i]))); | 392 specifics->add_name_first(LimitData(UTF16ToUTF8(values[i]))); |
391 } | 393 } |
392 | 394 |
393 profile.GetRawMultiInfo(autofill::NAME_MIDDLE, &values); | 395 profile.GetRawMultiInfo(NAME_MIDDLE, &values); |
394 for (size_t i = 0; i < values.size(); ++i) { | 396 for (size_t i = 0; i < values.size(); ++i) { |
395 specifics->add_name_middle(LimitData(UTF16ToUTF8(values[i]))); | 397 specifics->add_name_middle(LimitData(UTF16ToUTF8(values[i]))); |
396 } | 398 } |
397 | 399 |
398 profile.GetRawMultiInfo(autofill::NAME_LAST, &values); | 400 profile.GetRawMultiInfo(NAME_LAST, &values); |
399 for (size_t i = 0; i < values.size(); ++i) { | 401 for (size_t i = 0; i < values.size(); ++i) { |
400 specifics->add_name_last(LimitData(UTF16ToUTF8(values[i]))); | 402 specifics->add_name_last(LimitData(UTF16ToUTF8(values[i]))); |
401 } | 403 } |
402 | 404 |
403 specifics->set_address_home_line1( | 405 specifics->set_address_home_line1( |
404 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_LINE1)))); | 406 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_LINE1)))); |
405 specifics->set_address_home_line2( | 407 specifics->set_address_home_line2( |
406 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_LINE2)))); | 408 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_LINE2)))); |
407 specifics->set_address_home_city( | 409 specifics->set_address_home_city( |
408 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_CITY)))); | 410 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_CITY)))); |
409 specifics->set_address_home_state( | 411 specifics->set_address_home_state( |
410 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_STATE)))); | 412 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_STATE)))); |
| 413 specifics->set_address_home_zip( |
| 414 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_ZIP)))); |
411 specifics->set_address_home_country( | 415 specifics->set_address_home_country( |
412 LimitData( | 416 LimitData(UTF16ToUTF8(profile.GetRawInfo(ADDRESS_HOME_COUNTRY)))); |
413 UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)))); | |
414 specifics->set_address_home_zip( | |
415 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_ZIP)))); | |
416 | 417 |
417 profile.GetRawMultiInfo(autofill::EMAIL_ADDRESS, &values); | 418 profile.GetRawMultiInfo(EMAIL_ADDRESS, &values); |
418 for (size_t i = 0; i < values.size(); ++i) { | 419 for (size_t i = 0; i < values.size(); ++i) { |
419 specifics->add_email_address(LimitData(UTF16ToUTF8(values[i]))); | 420 specifics->add_email_address(LimitData(UTF16ToUTF8(values[i]))); |
420 } | 421 } |
421 | 422 |
422 specifics->set_company_name( | 423 specifics->set_company_name( |
423 LimitData(UTF16ToUTF8(profile.GetRawInfo(autofill::COMPANY_NAME)))); | 424 LimitData(UTF16ToUTF8(profile.GetRawInfo(COMPANY_NAME)))); |
424 | 425 |
425 profile.GetRawMultiInfo(autofill::PHONE_HOME_WHOLE_NUMBER, &values); | 426 profile.GetRawMultiInfo(PHONE_HOME_WHOLE_NUMBER, &values); |
426 for (size_t i = 0; i < values.size(); ++i) { | 427 for (size_t i = 0; i < values.size(); ++i) { |
427 specifics->add_phone_home_whole_number(LimitData(UTF16ToUTF8(values[i]))); | 428 specifics->add_phone_home_whole_number(LimitData(UTF16ToUTF8(values[i]))); |
428 } | 429 } |
429 } | 430 } |
430 | 431 |
431 void AutofillProfileSyncableService::CreateGUIDToProfileMap( | 432 void AutofillProfileSyncableService::CreateGUIDToProfileMap( |
432 const std::vector<AutofillProfile*>& profiles, | 433 const std::vector<AutofillProfile*>& profiles, |
433 GUIDToProfileMap* profile_map) { | 434 GUIDToProfileMap* profile_map) { |
434 DCHECK(profile_map); | 435 DCHECK(profile_map); |
435 profile_map->clear(); | 436 profile_map->clear(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 // Ensure that a verified profile can never revert back to an unverified | 478 // Ensure that a verified profile can never revert back to an unverified |
478 // one. | 479 // one. |
479 if (local_profile->IsVerified() && !new_profile->IsVerified()) { | 480 if (local_profile->IsVerified() && !new_profile->IsVerified()) { |
480 new_profile->set_origin(local_profile->origin()); | 481 new_profile->set_origin(local_profile->origin()); |
481 bundle->profiles_to_sync_back.push_back(new_profile); | 482 bundle->profiles_to_sync_back.push_back(new_profile); |
482 } | 483 } |
483 | 484 |
484 bundle->profiles_to_delete.push_back(local_profile->guid()); | 485 bundle->profiles_to_delete.push_back(local_profile->guid()); |
485 DVLOG(2) << "[AUTOFILL SYNC]" | 486 DVLOG(2) << "[AUTOFILL SYNC]" |
486 << "Found in sync db but with a different guid: " | 487 << "Found in sync db but with a different guid: " |
487 << UTF16ToUTF8(local_profile->GetRawInfo(autofill::NAME_FIRST)) | 488 << UTF16ToUTF8(local_profile->GetRawInfo(NAME_FIRST)) |
488 << UTF16ToUTF8(local_profile->GetRawInfo(autofill::NAME_LAST)) | 489 << UTF16ToUTF8(local_profile->GetRawInfo(NAME_LAST)) |
489 << "New guid " << new_profile->guid() | 490 << "New guid " << new_profile->guid() |
490 << ". Profile to be deleted " << local_profile->guid(); | 491 << ". Profile to be deleted " << local_profile->guid(); |
491 profile_map->erase(it); | 492 profile_map->erase(it); |
492 break; | 493 break; |
493 } else if (!local_profile->IsVerified() && | 494 } else if (!local_profile->IsVerified() && |
494 !new_profile->IsVerified() && | 495 !new_profile->IsVerified() && |
495 !local_profile->PrimaryValue().empty() && | 496 !local_profile->PrimaryValue().empty() && |
496 local_profile->PrimaryValue() == new_profile->PrimaryValue()) { | 497 local_profile->PrimaryValue() == new_profile->PrimaryValue()) { |
497 // Add it to candidates for merge - if there is no profile with this | 498 // Add it to candidates for merge - if there is no profile with this |
498 // guid we will merge them. | 499 // guid we will merge them. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 } | 618 } |
618 | 619 |
619 void AutofillProfileSyncableService::InjectStartSyncFlare( | 620 void AutofillProfileSyncableService::InjectStartSyncFlare( |
620 const syncer::SyncableService::StartSyncFlare& flare) { | 621 const syncer::SyncableService::StartSyncFlare& flare) { |
621 flare_ = flare; | 622 flare_ = flare; |
622 } | 623 } |
623 | 624 |
624 AutofillProfileSyncableService::DataBundle::DataBundle() {} | 625 AutofillProfileSyncableService::DataBundle::DataBundle() {} |
625 | 626 |
626 AutofillProfileSyncableService::DataBundle::~DataBundle() {} | 627 AutofillProfileSyncableService::DataBundle::~DataBundle() {} |
| 628 |
| 629 } // namespace autofill |
OLD | NEW |