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

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: components/autofill review. 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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 AutofillClient::PaymentsRpcResult result, 844 AutofillClient::PaymentsRpcResult result,
845 const base::string16& context_token, 845 const base::string16& context_token,
846 scoped_ptr<base::DictionaryValue> legal_message) { 846 scoped_ptr<base::DictionaryValue> legal_message) {
847 // TODO(jdonnelly): Log duration. 847 // TODO(jdonnelly): Log duration.
848 if (result == AutofillClient::SUCCESS) { 848 if (result == AutofillClient::SUCCESS) {
849 // Do *not* call payments_client_->Prepare() here. We shouldn't send 849 // Do *not* call payments_client_->Prepare() here. We shouldn't send
850 // credentials until the user has explicitly accepted a prompt to upload. 850 // credentials until the user has explicitly accepted a prompt to upload.
851 upload_request_.context_token = context_token; 851 upload_request_.context_token = context_token;
852 user_did_accept_upload_prompt_ = false; 852 user_did_accept_upload_prompt_ = false;
853 client_->ConfirmSaveCreditCardToCloud( 853 client_->ConfirmSaveCreditCardToCloud(
854 upload_request_.card, std::move(legal_message),
854 base::Bind(&AutofillManager::OnUserDidAcceptUpload, 855 base::Bind(&AutofillManager::OnUserDidAcceptUpload,
855 weak_ptr_factory_.GetWeakPtr()), 856 weak_ptr_factory_.GetWeakPtr()));
856 std::move(legal_message));
857 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, 857 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData,
858 weak_ptr_factory_.GetWeakPtr())); 858 weak_ptr_factory_.GetWeakPtr()));
859 AutofillMetrics::LogCardUploadDecisionMetric( 859 AutofillMetrics::LogCardUploadDecisionMetric(
860 AutofillMetrics::UPLOAD_OFFERED); 860 AutofillMetrics::UPLOAD_OFFERED);
861 } else { 861 } else {
862 // If the upload details request failed, fall back to a local save. The 862 // If the upload details request failed, fall back to a local save. The
863 // reasoning here is as follows: 863 // reasoning here is as follows:
864 // - This will sometimes fail intermittently, in which case it might be 864 // - This will sometimes fail intermittently, in which case it might be
865 // better to not fall back, because sometimes offering upload and sometimes 865 // better to not fall back, because sometimes offering upload and sometimes
866 // offering local save is a poor user experience. 866 // offering local save is a poor user experience.
867 // - However, in some cases, our local configuration limiting the feature to 867 // - However, in some cases, our local configuration limiting the feature to
868 // countries that Payments is known to support will not match Payments' own 868 // countries that Payments is known to support will not match Payments' own
869 // determination of what country the user is located in. In these cases, 869 // determination of what country the user is located in. In these cases,
870 // the upload details request will consistently fail and if we don't fall 870 // the upload details request will consistently fail and if we don't fall
871 // back to a local save then the user will never be offered any kind of 871 // back to a local save then the user will never be offered any kind of
872 // credit card save. 872 // credit card save.
873 client_->ConfirmSaveCreditCardLocally(base::Bind( 873 client_->ConfirmSaveCreditCardLocally(
874 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 874 upload_request_.card,
875 base::Unretained(personal_data_), upload_request_.card)); 875 base::Bind(
876 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
877 base::Unretained(personal_data_), upload_request_.card));
876 AutofillMetrics::LogCardUploadDecisionMetric( 878 AutofillMetrics::LogCardUploadDecisionMetric(
877 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 879 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
878 } 880 }
879 } 881 }
880 882
881 void AutofillManager::OnDidUploadCard( 883 void AutofillManager::OnDidUploadCard(
882 AutofillClient::PaymentsRpcResult result) { 884 AutofillClient::PaymentsRpcResult result) {
883 // We don't do anything user-visible if the upload attempt fails. 885 // We don't do anything user-visible if the upload attempt fails.
884 // TODO(jdonnelly): Log duration. 886 // TODO(jdonnelly): Log duration.
885 } 887 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 if (imported_credit_card) { 971 if (imported_credit_card) {
970 // Don't offer to save any cards that were recently unmasked. 972 // Don't offer to save any cards that were recently unmasked.
971 for (const CreditCard& unmasked_card : recently_unmasked_cards_) { 973 for (const CreditCard& unmasked_card : recently_unmasked_cards_) {
972 if (unmasked_card.TypeAndLastFourDigits() == 974 if (unmasked_card.TypeAndLastFourDigits() ==
973 imported_credit_card->TypeAndLastFourDigits()) 975 imported_credit_card->TypeAndLastFourDigits())
974 return; 976 return;
975 } 977 }
976 978
977 upload_request_ = payments::PaymentsClient::UploadRequestDetails(); 979 upload_request_ = payments::PaymentsClient::UploadRequestDetails();
978 if (!IsCreditCardUploadEnabled()) { 980 if (!IsCreditCardUploadEnabled()) {
979 client_->ConfirmSaveCreditCardLocally(base::Bind( 981 client_->ConfirmSaveCreditCardLocally(
980 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 982 *imported_credit_card,
981 base::Unretained(personal_data_), *imported_credit_card)); 983 base::Bind(
984 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
985 base::Unretained(personal_data_), *imported_credit_card));
982 } else { 986 } else {
983 // Check for a CVC in order to determine whether we can prompt the user to 987 // Check for a CVC in order to determine whether we can prompt the user to
984 // upload their card. 988 // upload their card.
985 for (const auto& field : submitted_form) { 989 for (const auto& field : submitted_form) {
986 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) { 990 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) {
987 upload_request_.cvc = field->value; 991 upload_request_.cvc = field->value;
988 break; 992 break;
989 } 993 }
990 } 994 }
991 995
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 if (i > 0) 1706 if (i > 0)
1703 fputs("Next oldest form:\n", file); 1707 fputs("Next oldest form:\n", file);
1704 } 1708 }
1705 fputs("\n", file); 1709 fputs("\n", file);
1706 1710
1707 fclose(file); 1711 fclose(file);
1708 } 1712 }
1709 #endif // ENABLE_FORM_DEBUG_DUMP 1713 #endif // ENABLE_FORM_DEBUG_DUMP
1710 1714
1711 } // namespace autofill 1715 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_client.h ('k') | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698