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/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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 851 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
852 weak_ptr_factory_.GetWeakPtr()), | 852 weak_ptr_factory_.GetWeakPtr()), |
853 std::move(legal_message)); | 853 upload_request_.card, 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 base::Bind( |
872 base::Unretained(personal_data_), upload_request_.card)); | 872 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
| 873 base::Unretained(personal_data_), upload_request_.card), |
| 874 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.TypeAndLastFourDigits() == |
970 imported_credit_card->TypeAndLastFourDigits()) | 972 imported_credit_card->TypeAndLastFourDigits()) |
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 base::Bind( |
978 base::Unretained(personal_data_), *imported_credit_card)); | 980 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
| 981 base::Unretained(personal_data_), *imported_credit_card), |
| 982 *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 Loading... |
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 |
OLD | NEW |