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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 } | 510 } |
511 | 511 |
512 void PersonalDataManager::RecordUseOf(const AutofillDataModel& data_model) { | 512 void PersonalDataManager::RecordUseOf(const AutofillDataModel& data_model) { |
513 if (is_off_the_record_ || !database_.get()) | 513 if (is_off_the_record_ || !database_.get()) |
514 return; | 514 return; |
515 | 515 |
516 CreditCard* credit_card = GetCreditCardByGUID(data_model.guid()); | 516 CreditCard* credit_card = GetCreditCardByGUID(data_model.guid()); |
517 if (credit_card) { | 517 if (credit_card) { |
518 credit_card->RecordUse(); | 518 credit_card->RecordUse(); |
519 | 519 |
520 if (credit_card->record_type() == CreditCard::LOCAL_CARD) { | 520 if (credit_card->record_type() == CreditCard::LOCAL_CARD) |
521 database_->UpdateCreditCard(*credit_card); | 521 database_->UpdateCreditCard(*credit_card); |
522 } else if (credit_card->record_type() == CreditCard::FULL_SERVER_CARD) { | 522 else |
523 database_->UpdateUnmaskedCardUsageStats(*credit_card); | 523 database_->UpdateServerCardUsageStats(*credit_card); |
524 } else { | |
525 // It's possible to get a masked server card here if the user decides not | |
526 // to store a card while verifying it. We don't currently track usage | |
527 // of masked cards, so no-op. | |
528 return; | |
529 } | |
530 | 524 |
531 Refresh(); | 525 Refresh(); |
532 return; | 526 return; |
533 } | 527 } |
534 | 528 |
535 AutofillProfile* profile = GetProfileByGUID(data_model.guid()); | 529 AutofillProfile* profile = GetProfileByGUID(data_model.guid()); |
536 if (profile) { | 530 if (profile) { |
537 profile->RecordUse(); | 531 profile->RecordUse(); |
538 database_->UpdateAutofillProfile(*profile); | 532 |
| 533 if (profile->record_type() == AutofillProfile::LOCAL_PROFILE) |
| 534 database_->UpdateAutofillProfile(*profile); |
| 535 else if (profile->record_type() == AutofillProfile::SERVER_PROFILE) |
| 536 database_->UpdateServerAddressUsageStats(*profile); |
| 537 |
539 Refresh(); | 538 Refresh(); |
540 } | 539 } |
541 } | 540 } |
542 | 541 |
543 void PersonalDataManager::AddProfile(const AutofillProfile& profile) { | 542 void PersonalDataManager::AddProfile(const AutofillProfile& profile) { |
544 if (is_off_the_record_) | 543 if (is_off_the_record_) |
545 return; | 544 return; |
546 | 545 |
547 if (profile.IsEmpty(app_locale_)) | 546 if (profile.IsEmpty(app_locale_)) |
548 return; | 547 return; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 existing_credit_card = it; | 665 existing_credit_card = it; |
667 break; | 666 break; |
668 } | 667 } |
669 } | 668 } |
670 if (!existing_credit_card) | 669 if (!existing_credit_card) |
671 return; | 670 return; |
672 | 671 |
673 DCHECK_NE(existing_credit_card->record_type(), credit_card.record_type()); | 672 DCHECK_NE(existing_credit_card->record_type(), credit_card.record_type()); |
674 DCHECK_EQ(existing_credit_card->Label(), credit_card.Label()); | 673 DCHECK_EQ(existing_credit_card->Label(), credit_card.Label()); |
675 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) { | 674 if (existing_credit_card->record_type() == CreditCard::MASKED_SERVER_CARD) { |
676 database_->UnmaskServerCreditCard(credit_card.server_id(), | 675 database_->UnmaskServerCreditCard(credit_card, |
677 credit_card.number()); | 676 credit_card.number()); |
678 } else { | 677 } else { |
679 database_->MaskServerCreditCard(credit_card.server_id()); | 678 database_->MaskServerCreditCard(credit_card.server_id()); |
680 } | 679 } |
681 | 680 |
682 Refresh(); | 681 Refresh(); |
683 } | 682 } |
684 | 683 |
685 void PersonalDataManager::ResetFullServerCard(const std::string& guid) { | 684 void PersonalDataManager::ResetFullServerCard(const std::string& guid) { |
686 for (const CreditCard* card : server_credit_cards_) { | 685 for (const CreditCard* card : server_credit_cards_) { |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1394 } | 1393 } |
1395 if (IsExperimentalWalletIntegrationEnabled() && | 1394 if (IsExperimentalWalletIntegrationEnabled() && |
1396 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1395 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1397 profiles_.insert( | 1396 profiles_.insert( |
1398 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1397 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1399 } | 1398 } |
1400 return profiles_; | 1399 return profiles_; |
1401 } | 1400 } |
1402 | 1401 |
1403 } // namespace autofill | 1402 } // namespace autofill |
OLD | NEW |