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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 1540423004: Add card details and legal message to Android save credit card infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Justin's nits. Created 4 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
OLDNEW
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/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 if (identifier < 0) 670 if (identifier < 0)
671 return false; 671 return false;
672 672
673 const CreditCard* credit_card = nullptr; 673 const CreditCard* credit_card = nullptr;
674 const AutofillProfile* profile = nullptr; 674 const AutofillProfile* profile = nullptr;
675 if (GetCreditCard(identifier, &credit_card)) { 675 if (GetCreditCard(identifier, &credit_card)) {
676 if (credit_card->record_type() != CreditCard::LOCAL_CARD) 676 if (credit_card->record_type() != CreditCard::LOCAL_CARD)
677 return false; 677 return false;
678 678
679 if (title) 679 if (title)
680 title->assign(credit_card->TypeAndLastFourDigits()); 680 title->assign(credit_card->TypeAndLastFourDigitsForDisplay());
681 if (body) { 681 if (body) {
682 body->assign(l10n_util::GetStringUTF16( 682 body->assign(l10n_util::GetStringUTF16(
683 IDS_AUTOFILL_DELETE_CREDIT_CARD_SUGGESTION_CONFIRMATION_BODY)); 683 IDS_AUTOFILL_DELETE_CREDIT_CARD_SUGGESTION_CONFIRMATION_BODY));
684 } 684 }
685 685
686 return true; 686 return true;
687 } else if (GetProfile(identifier, &profile)) { 687 } else if (GetProfile(identifier, &profile)) {
688 if (profile->record_type() != AutofillProfile::LOCAL_PROFILE) 688 if (profile->record_type() != AutofillProfile::LOCAL_PROFILE)
689 return false; 689 return false;
690 690
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 AutofillClient::PaymentsRpcResult result, 841 AutofillClient::PaymentsRpcResult result,
842 const base::string16& context_token, 842 const base::string16& context_token,
843 scoped_ptr<base::DictionaryValue> legal_message) { 843 scoped_ptr<base::DictionaryValue> legal_message) {
844 // TODO(jdonnelly): Log duration. 844 // TODO(jdonnelly): Log duration.
845 if (result == AutofillClient::SUCCESS) { 845 if (result == AutofillClient::SUCCESS) {
846 // Do *not* call payments_client_->Prepare() here. We shouldn't send 846 // Do *not* call payments_client_->Prepare() here. We shouldn't send
847 // credentials until the user has explicitly accepted a prompt to upload. 847 // credentials until the user has explicitly accepted a prompt to upload.
848 upload_request_.context_token = context_token; 848 upload_request_.context_token = context_token;
849 user_did_accept_upload_prompt_ = false; 849 user_did_accept_upload_prompt_ = false;
850 client_->ConfirmSaveCreditCardToCloud( 850 client_->ConfirmSaveCreditCardToCloud(
851 upload_request_.card, std::move(legal_message),
851 base::Bind(&AutofillManager::OnUserDidAcceptUpload, 852 base::Bind(&AutofillManager::OnUserDidAcceptUpload,
852 weak_ptr_factory_.GetWeakPtr()), 853 weak_ptr_factory_.GetWeakPtr()));
853 std::move(legal_message));
854 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, 854 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData,
855 weak_ptr_factory_.GetWeakPtr())); 855 weak_ptr_factory_.GetWeakPtr()));
856 AutofillMetrics::LogCardUploadDecisionMetric( 856 AutofillMetrics::LogCardUploadDecisionMetric(
857 AutofillMetrics::UPLOAD_OFFERED); 857 AutofillMetrics::UPLOAD_OFFERED);
858 } else { 858 } else {
859 // If the upload details request failed, fall back to a local save. The 859 // If the upload details request failed, fall back to a local save. The
860 // reasoning here is as follows: 860 // reasoning here is as follows:
861 // - This will sometimes fail intermittently, in which case it might be 861 // - This will sometimes fail intermittently, in which case it might be
862 // better to not fall back, because sometimes offering upload and sometimes 862 // better to not fall back, because sometimes offering upload and sometimes
863 // offering local save is a poor user experience. 863 // offering local save is a poor user experience.
864 // - However, in some cases, our local configuration limiting the feature to 864 // - However, in some cases, our local configuration limiting the feature to
865 // countries that Payments is known to support will not match Payments' own 865 // countries that Payments is known to support will not match Payments' own
866 // determination of what country the user is located in. In these cases, 866 // determination of what country the user is located in. In these cases,
867 // the upload details request will consistently fail and if we don't fall 867 // the upload details request will consistently fail and if we don't fall
868 // back to a local save then the user will never be offered any kind of 868 // back to a local save then the user will never be offered any kind of
869 // credit card save. 869 // credit card save.
870 client_->ConfirmSaveCreditCardLocally(base::Bind( 870 client_->ConfirmSaveCreditCardLocally(
871 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 871 upload_request_.card,
872 base::Unretained(personal_data_), upload_request_.card)); 872 base::Bind(
873 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
874 base::Unretained(personal_data_), upload_request_.card));
873 AutofillMetrics::LogCardUploadDecisionMetric( 875 AutofillMetrics::LogCardUploadDecisionMetric(
874 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 876 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
875 } 877 }
876 } 878 }
877 879
878 void AutofillManager::OnDidUploadCard( 880 void AutofillManager::OnDidUploadCard(
879 AutofillClient::PaymentsRpcResult result) { 881 AutofillClient::PaymentsRpcResult result) {
880 // We don't do anything user-visible if the upload attempt fails. 882 // We don't do anything user-visible if the upload attempt fails.
881 // TODO(jdonnelly): Log duration. 883 // TODO(jdonnelly): Log duration.
882 } 884 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 961
960 DumpAutofillData(imported_credit_card); 962 DumpAutofillData(imported_credit_card);
961 } 963 }
962 #endif // ENABLE_FORM_DEBUG_DUMP 964 #endif // ENABLE_FORM_DEBUG_DUMP
963 965
964 // If credit card information was submitted, we need to confirm whether to 966 // If credit card information was submitted, we need to confirm whether to
965 // save it. 967 // save it.
966 if (imported_credit_card) { 968 if (imported_credit_card) {
967 // Don't offer to save any cards that were recently unmasked. 969 // Don't offer to save any cards that were recently unmasked.
968 for (const CreditCard& unmasked_card : recently_unmasked_cards_) { 970 for (const CreditCard& unmasked_card : recently_unmasked_cards_) {
969 if (unmasked_card.TypeAndLastFourDigits() == 971 if (unmasked_card.TypeAndLastFourDigitsForDisplay() ==
970 imported_credit_card->TypeAndLastFourDigits()) 972 imported_credit_card->TypeAndLastFourDigitsForDisplay())
971 return; 973 return;
972 } 974 }
973 975
974 upload_request_ = payments::PaymentsClient::UploadRequestDetails(); 976 upload_request_ = payments::PaymentsClient::UploadRequestDetails();
975 if (!IsCreditCardUploadEnabled()) { 977 if (!IsCreditCardUploadEnabled()) {
976 client_->ConfirmSaveCreditCardLocally(base::Bind( 978 client_->ConfirmSaveCreditCardLocally(
977 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 979 *imported_credit_card,
978 base::Unretained(personal_data_), *imported_credit_card)); 980 base::Bind(
981 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
982 base::Unretained(personal_data_), *imported_credit_card));
979 } else { 983 } else {
980 // Check for a CVC in order to determine whether we can prompt the user to 984 // Check for a CVC in order to determine whether we can prompt the user to
981 // upload their card. 985 // upload their card.
982 for (const auto& field : submitted_form) { 986 for (const auto& field : submitted_form) {
983 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) { 987 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) {
984 upload_request_.cvc = field->value; 988 upload_request_.cvc = field->value;
985 break; 989 break;
986 } 990 }
987 } 991 }
988 992
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 if (i > 0) 1703 if (i > 0)
1700 fputs("Next oldest form:\n", file); 1704 fputs("Next oldest form:\n", file);
1701 } 1705 }
1702 fputs("\n", file); 1706 fputs("\n", file);
1703 1707
1704 fclose(file); 1708 fclose(file);
1705 } 1709 }
1706 #endif // ENABLE_FORM_DEBUG_DUMP 1710 #endif // ENABLE_FORM_DEBUG_DUMP
1707 1711
1708 } // namespace autofill 1712 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698