| OLD | NEW |
| 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/personal_data_manager.h" | 5 #include "components/autofill/core/browser/personal_data_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 311 } |
| 312 | 312 |
| 313 // If the sync service is configured to start and to sync autofill profiles, | 313 // If the sync service is configured to start and to sync autofill profiles, |
| 314 // then we can just let the notification that sync has started trigger the | 314 // then we can just let the notification that sync has started trigger the |
| 315 // de-duplication. | 315 // de-duplication. |
| 316 if (sync_service && sync_service->CanSyncStart() && | 316 if (sync_service && sync_service->CanSyncStart() && |
| 317 sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) { | 317 sync_service->GetPreferredDataTypes().Has(syncer::AUTOFILL_PROFILE)) { |
| 318 return; | 318 return; |
| 319 } | 319 } |
| 320 | 320 |
| 321 // Otherwise, run the de-duplication now. | 321 // This runs as a one-time fix, tracked in syncable prefs. If it has already |
| 322 // run, it is a NOP (other than checking the pref). |
| 323 ApplyProfileUseDatesFix(); |
| 324 |
| 325 // This runs at most once per major version, tracked in syncable prefs. If it |
| 326 // has already run for this version, it's a NOP, other than checking the pref. |
| 322 ApplyDedupingRoutine(); | 327 ApplyDedupingRoutine(); |
| 323 } | 328 } |
| 324 | 329 |
| 325 void PersonalDataManager::OnWebDataServiceRequestDone( | 330 void PersonalDataManager::OnWebDataServiceRequestDone( |
| 326 WebDataServiceBase::Handle h, | 331 WebDataServiceBase::Handle h, |
| 327 const WDTypedResult* result) { | 332 const WDTypedResult* result) { |
| 328 DCHECK(pending_profiles_query_ || pending_server_profiles_query_ || | 333 DCHECK(pending_profiles_query_ || pending_server_profiles_query_ || |
| 329 pending_creditcards_query_ || pending_server_creditcards_query_); | 334 pending_creditcards_query_ || pending_server_creditcards_query_); |
| 330 | 335 |
| 331 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is | 336 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/422460 is |
| (...skipping 10 matching lines...) Expand all Loading... |
| 342 pending_profiles_query_ = 0; | 347 pending_profiles_query_ = 0; |
| 343 return; | 348 return; |
| 344 } | 349 } |
| 345 | 350 |
| 346 switch (result->GetType()) { | 351 switch (result->GetType()) { |
| 347 case AUTOFILL_PROFILES_RESULT: | 352 case AUTOFILL_PROFILES_RESULT: |
| 348 if (h == pending_profiles_query_) { | 353 if (h == pending_profiles_query_) { |
| 349 ReceiveLoadedDbValues(h, result, &pending_profiles_query_, | 354 ReceiveLoadedDbValues(h, result, &pending_profiles_query_, |
| 350 &web_profiles_); | 355 &web_profiles_); |
| 351 LogProfileCount(); // This only logs local profiles. | 356 LogProfileCount(); // This only logs local profiles. |
| 352 ApplyProfileUseDatesFix(); | |
| 353 } else { | 357 } else { |
| 354 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_, | 358 ReceiveLoadedDbValues(h, result, &pending_server_profiles_query_, |
| 355 &server_profiles_); | 359 &server_profiles_); |
| 356 | 360 |
| 357 if (!server_profiles_.empty()) { | 361 if (!server_profiles_.empty()) { |
| 358 std::string account_id = signin_manager_->GetAuthenticatedAccountId(); | 362 std::string account_id = signin_manager_->GetAuthenticatedAccountId(); |
| 359 base::string16 email = | 363 base::string16 email = |
| 360 base::UTF8ToUTF16( | 364 base::UTF8ToUTF16( |
| 361 account_tracker_->GetAccountInfo(account_id).email); | 365 account_tracker_->GetAccountInfo(account_id).email); |
| 362 | 366 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 is_data_loaded_ = true; | 401 is_data_loaded_ = true; |
| 398 NotifyPersonalDataChanged(); | 402 NotifyPersonalDataChanged(); |
| 399 } | 403 } |
| 400 } | 404 } |
| 401 | 405 |
| 402 void PersonalDataManager::AutofillMultipleChanged() { | 406 void PersonalDataManager::AutofillMultipleChanged() { |
| 403 Refresh(); | 407 Refresh(); |
| 404 } | 408 } |
| 405 | 409 |
| 406 void PersonalDataManager::SyncStarted(syncer::ModelType model_type) { | 410 void PersonalDataManager::SyncStarted(syncer::ModelType model_type) { |
| 407 if (model_type == syncer::AUTOFILL_PROFILE && | 411 if (model_type == syncer::AUTOFILL_PROFILE) { |
| 408 is_autofill_profile_dedupe_pending_) { | 412 // This runs as a one-time fix, tracked in syncable prefs. If it has already |
| 413 // run, it is a NOP (other than checking the pref). |
| 414 ApplyProfileUseDatesFix(); |
| 415 |
| 416 // This runs at most once per major version, tracked in syncable prefs. If |
| 417 // it has already run for this version, it's a NOP, other than checking the |
| 418 // pref. |
| 409 ApplyDedupingRoutine(); | 419 ApplyDedupingRoutine(); |
| 410 } | 420 } |
| 411 } | 421 } |
| 412 | 422 |
| 413 void PersonalDataManager::AddObserver(PersonalDataManagerObserver* observer) { | 423 void PersonalDataManager::AddObserver(PersonalDataManagerObserver* observer) { |
| 414 observers_.AddObserver(observer); | 424 observers_.AddObserver(observer); |
| 415 } | 425 } |
| 416 | 426 |
| 417 void PersonalDataManager::RemoveObserver( | 427 void PersonalDataManager::RemoveObserver( |
| 418 PersonalDataManagerObserver* observer) { | 428 PersonalDataManagerObserver* observer) { |
| (...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 if (profile_to_merge->IsVerified()) | 1755 if (profile_to_merge->IsVerified()) |
| 1746 break; | 1756 break; |
| 1747 } | 1757 } |
| 1748 } | 1758 } |
| 1749 } | 1759 } |
| 1750 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( | 1760 AutofillMetrics::LogNumberOfProfilesRemovedDuringDedupe( |
| 1751 profiles_to_delete->size()); | 1761 profiles_to_delete->size()); |
| 1752 } | 1762 } |
| 1753 | 1763 |
| 1754 } // namespace autofill | 1764 } // namespace autofill |
| OLD | NEW |