| 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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 upload_request_.context_token = context_token; | 1032 upload_request_.context_token = context_token; |
| 1033 user_did_accept_upload_prompt_ = false; | 1033 user_did_accept_upload_prompt_ = false; |
| 1034 client_->ConfirmSaveCreditCardToCloud( | 1034 client_->ConfirmSaveCreditCardToCloud( |
| 1035 upload_request_.card, std::move(legal_message), | 1035 upload_request_.card, std::move(legal_message), |
| 1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
| 1037 weak_ptr_factory_.GetWeakPtr())); | 1037 weak_ptr_factory_.GetWeakPtr())); |
| 1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, | 1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, |
| 1039 weak_ptr_factory_.GetWeakPtr())); | 1039 weak_ptr_factory_.GetWeakPtr())); |
| 1040 AutofillMetrics::LogCardUploadDecisionMetric( | 1040 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1041 AutofillMetrics::UPLOAD_OFFERED); | 1041 AutofillMetrics::UPLOAD_OFFERED); |
| 1042 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 1042 } else { | 1043 } else { |
| 1043 // If the upload details request failed, fall back to a local save. The | 1044 // If the upload details request failed, fall back to a local save. The |
| 1044 // reasoning here is as follows: | 1045 // reasoning here is as follows: |
| 1045 // - This will sometimes fail intermittently, in which case it might be | 1046 // - This will sometimes fail intermittently, in which case it might be |
| 1046 // better to not fall back, because sometimes offering upload and sometimes | 1047 // better to not fall back, because sometimes offering upload and sometimes |
| 1047 // offering local save is a poor user experience. | 1048 // offering local save is a poor user experience. |
| 1048 // - However, in some cases, our local configuration limiting the feature to | 1049 // - However, in some cases, our local configuration limiting the feature to |
| 1049 // countries that Payments is known to support will not match Payments' own | 1050 // countries that Payments is known to support will not match Payments' own |
| 1050 // determination of what country the user is located in. In these cases, | 1051 // determination of what country the user is located in. In these cases, |
| 1051 // the upload details request will consistently fail and if we don't fall | 1052 // the upload details request will consistently fail and if we don't fall |
| 1052 // back to a local save then the user will never be offered any kind of | 1053 // back to a local save then the user will never be offered any kind of |
| 1053 // credit card save. | 1054 // credit card save. |
| 1054 client_->ConfirmSaveCreditCardLocally( | 1055 client_->ConfirmSaveCreditCardLocally( |
| 1055 upload_request_.card, | 1056 upload_request_.card, |
| 1056 base::Bind( | 1057 base::Bind( |
| 1057 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 1058 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
| 1058 base::Unretained(personal_data_), upload_request_.card)); | 1059 base::Unretained(personal_data_), upload_request_.card)); |
| 1059 AutofillMetrics::LogCardUploadDecisionMetric( | 1060 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1060 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 1061 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 1062 LogCardUploadDecisionUkm( |
| 1063 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 1061 } | 1064 } |
| 1065 pending_upload_request_url_ = GURL(); |
| 1062 } | 1066 } |
| 1063 | 1067 |
| 1064 void AutofillManager::OnDidUploadCard( | 1068 void AutofillManager::OnDidUploadCard( |
| 1065 AutofillClient::PaymentsRpcResult result) { | 1069 AutofillClient::PaymentsRpcResult result) { |
| 1066 // We don't do anything user-visible if the upload attempt fails. | 1070 // We don't do anything user-visible if the upload attempt fails. |
| 1067 // TODO(jdonnelly): Log duration. | 1071 // TODO(jdonnelly): Log duration. |
| 1068 } | 1072 } |
| 1069 | 1073 |
| 1070 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, | 1074 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, |
| 1071 const base::string16& cvc) { | 1075 const base::string16& cvc) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 // client-side validation rules. | 1215 // client-side validation rules. |
| 1212 autofill::AutofillMetrics::CardUploadDecisionMetric | 1216 autofill::AutofillMetrics::CardUploadDecisionMetric |
| 1213 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; | 1217 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; |
| 1214 std::string rappor_metric_name; | 1218 std::string rappor_metric_name; |
| 1215 bool get_profiles_succeeded = | 1219 bool get_profiles_succeeded = |
| 1216 GetProfilesForCreditCardUpload(*imported_credit_card, | 1220 GetProfilesForCreditCardUpload(*imported_credit_card, |
| 1217 &upload_request_.profiles, | 1221 &upload_request_.profiles, |
| 1218 &get_profiles_decision_metric, | 1222 &get_profiles_decision_metric, |
| 1219 &rappor_metric_name); | 1223 &rappor_metric_name); |
| 1220 | 1224 |
| 1225 pending_upload_request_url_ = GURL(submitted_form.source_url()); |
| 1226 |
| 1221 // Both the CVC and address checks are done. Conform to the legacy order of | 1227 // Both the CVC and address checks are done. Conform to the legacy order of |
| 1222 // reporting on CVC then address. | 1228 // reporting on CVC then address. |
| 1223 if (upload_request_.cvc.empty()) { | 1229 if (upload_request_.cvc.empty()) { |
| 1224 AutofillMetrics::LogCardUploadDecisionMetric( | 1230 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1225 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1231 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1232 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1233 pending_upload_request_url_ = GURL(); |
| 1226 CollectRapportSample(submitted_form.source_url(), | 1234 CollectRapportSample(submitted_form.source_url(), |
| 1227 "Autofill.CardUploadNotOfferedNoCvc"); | 1235 "Autofill.CardUploadNotOfferedNoCvc"); |
| 1228 return; | 1236 return; |
| 1229 } | 1237 } |
| 1230 if (!get_profiles_succeeded) { | 1238 if (!get_profiles_succeeded) { |
| 1231 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); | 1239 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); |
| 1232 AutofillMetrics::LogCardUploadDecisionMetric( | 1240 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1233 get_profiles_decision_metric); | 1241 get_profiles_decision_metric); |
| 1242 LogCardUploadDecisionUkm(get_profiles_decision_metric); |
| 1243 pending_upload_request_url_ = GURL(); |
| 1234 if (!rappor_metric_name.empty()) { | 1244 if (!rappor_metric_name.empty()) { |
| 1235 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); | 1245 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); |
| 1236 } | 1246 } |
| 1237 return; | 1247 return; |
| 1238 } | 1248 } |
| 1239 | 1249 |
| 1240 // All required data is available, start the upload process. | 1250 // All required data is available, start the upload process. |
| 1241 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); | 1251 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); |
| 1242 } | 1252 } |
| 1243 } | 1253 } |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2190 } | 2200 } |
| 2191 if (i > 0) | 2201 if (i > 0) |
| 2192 fputs("Next oldest form:\n", file); | 2202 fputs("Next oldest form:\n", file); |
| 2193 } | 2203 } |
| 2194 fputs("\n", file); | 2204 fputs("\n", file); |
| 2195 | 2205 |
| 2196 fclose(file); | 2206 fclose(file); |
| 2197 } | 2207 } |
| 2198 #endif // ENABLE_FORM_DEBUG_DUMP | 2208 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2199 | 2209 |
| 2210 void AutofillManager::LogCardUploadDecisionUkm( |
| 2211 AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
| 2212 AutofillMetrics::LogCardUploadDecisionUkm( |
| 2213 client_->GetUkmService(), pending_upload_request_url_, upload_decision); |
| 2214 } |
| 2215 |
| 2200 } // namespace autofill | 2216 } // namespace autofill |
| OLD | NEW |