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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 // Reject the credit card if we did not detect enough filled credit card | 440 // Reject the credit card if we did not detect enough filled credit card |
441 // fields or if the credit card number does not seem to be valid. | 441 // fields or if the credit card number does not seem to be valid. |
442 if (local_imported_credit_card.get() && | 442 if (local_imported_credit_card.get() && |
443 !local_imported_credit_card->IsComplete()) { | 443 !local_imported_credit_card->IsComplete()) { |
444 local_imported_credit_card.reset(); | 444 local_imported_credit_card.reset(); |
445 } | 445 } |
446 | 446 |
447 // Don't import if we already have this info. | 447 // Don't import if we already have this info. |
448 // Don't present an infobar if we have already saved this card number. | 448 // Don't present an infobar if we have already saved this card number. |
449 bool merged_credit_card = false; | 449 bool merged_credit_card = false; |
450 if (local_imported_credit_card.get()) { | 450 if (local_imported_credit_card) { |
451 for (CreditCard* card : local_credit_cards_) { | 451 for (CreditCard* card : local_credit_cards_) { |
452 // Make a local copy so that the data in |local_credit_cards_| isn't | 452 // Make a local copy so that the data in |local_credit_cards_| isn't |
453 // modified directly by the UpdateFromImportedCard() call. | 453 // modified directly by the UpdateFromImportedCard() call. |
454 CreditCard card_copy(*card); | 454 CreditCard card_copy(*card); |
455 if (card_copy.UpdateFromImportedCard(*local_imported_credit_card.get(), | 455 if (card_copy.UpdateFromImportedCard(*local_imported_credit_card.get(), |
456 app_locale_)) { | 456 app_locale_)) { |
457 merged_credit_card = true; | 457 merged_credit_card = true; |
458 UpdateCreditCard(card_copy); | 458 UpdateCreditCard(card_copy); |
459 local_imported_credit_card.reset(); | 459 local_imported_credit_card.reset(); |
460 break; | 460 break; |
461 } | 461 } |
462 } | 462 } |
463 } | 463 } |
464 | 464 |
| 465 // Also don't offer to save if we already have this stored as a full wallet |
| 466 // card. (In particular this comes up just after filling and submitting a |
| 467 // Wallet card.) |
| 468 if (local_imported_credit_card) { |
| 469 for (CreditCard* card : server_credit_cards_) { |
| 470 if (card->record_type() == CreditCard::FULL_SERVER_CARD && |
| 471 local_imported_credit_card->IsLocalDuplicateOfServerCard(*card)) { |
| 472 local_imported_credit_card.reset(); |
| 473 break; |
| 474 } |
| 475 } |
| 476 } |
| 477 |
465 if (imported_profile.get()) { | 478 if (imported_profile.get()) { |
466 // We always save imported profiles. | 479 // We always save imported profiles. |
467 SaveImportedProfile(*imported_profile); | 480 SaveImportedProfile(*imported_profile); |
468 } | 481 } |
469 *imported_credit_card = local_imported_credit_card.Pass(); | 482 *imported_credit_card = local_imported_credit_card.Pass(); |
470 | 483 |
471 if (imported_profile.get() || *imported_credit_card || merged_credit_card) | 484 if (imported_profile.get() || *imported_credit_card || merged_credit_card) |
472 return true; | 485 return true; |
473 | 486 |
474 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, | 487 FOR_EACH_OBSERVER(PersonalDataManagerObserver, observers_, |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 } | 1275 } |
1263 if (IsExperimentalWalletIntegrationEnabled() && | 1276 if (IsExperimentalWalletIntegrationEnabled() && |
1264 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1277 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1265 profiles_.insert( | 1278 profiles_.insert( |
1266 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1279 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1267 } | 1280 } |
1268 return profiles_; | 1281 return profiles_; |
1269 } | 1282 } |
1270 | 1283 |
1271 } // namespace autofill | 1284 } // namespace autofill |
OLD | NEW |