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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 cc_field_http_warning_suggestion.label = | 199 cc_field_http_warning_suggestion.label = |
200 l10n_util::GetStringUTF16(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE); | 200 l10n_util::GetStringUTF16(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE); |
201 cc_field_http_warning_suggestion.icon = | 201 cc_field_http_warning_suggestion.icon = |
202 (source_url.is_valid() && source_url.SchemeIs("http")) | 202 (source_url.is_valid() && source_url.SchemeIs("http")) |
203 ? base::ASCIIToUTF16("httpWarning") | 203 ? base::ASCIIToUTF16("httpWarning") |
204 : base::ASCIIToUTF16("httpsInvalid"); | 204 : base::ASCIIToUTF16("httpsInvalid"); |
205 | 205 |
206 return cc_field_http_warning_suggestion; | 206 return cc_field_http_warning_suggestion; |
207 } | 207 } |
208 | 208 |
| 209 // Logs the card upload decision ukm based on the specified |url| and |
| 210 // |upload_decision|. Returns whether the metric was logged sucessfully. |
| 211 bool LogCardUploadDecisionMetricUkm( |
| 212 ukm::UkmService* ukm_service, |
| 213 const GURL& url, |
| 214 AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
| 215 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) |
| 216 return false; |
| 217 |
| 218 std::map<std::string, int> metrics = { |
| 219 {"UploadDecision", static_cast<int>(upload_decision)}}; |
| 220 return AutofillMetrics::LogUkm(ukm_service, url, |
| 221 "Autofill.CardUploadDecision", metrics); |
| 222 } |
| 223 |
209 } // namespace | 224 } // namespace |
210 | 225 |
211 AutofillManager::AutofillManager( | 226 AutofillManager::AutofillManager( |
212 AutofillDriver* driver, | 227 AutofillDriver* driver, |
213 AutofillClient* client, | 228 AutofillClient* client, |
214 const std::string& app_locale, | 229 const std::string& app_locale, |
215 AutofillDownloadManagerState enable_download_manager) | 230 AutofillDownloadManagerState enable_download_manager) |
216 : driver_(driver), | 231 : driver_(driver), |
217 client_(client), | 232 client_(client), |
218 payments_client_( | 233 payments_client_( |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 upload_request_.context_token = context_token; | 1047 upload_request_.context_token = context_token; |
1033 user_did_accept_upload_prompt_ = false; | 1048 user_did_accept_upload_prompt_ = false; |
1034 client_->ConfirmSaveCreditCardToCloud( | 1049 client_->ConfirmSaveCreditCardToCloud( |
1035 upload_request_.card, std::move(legal_message), | 1050 upload_request_.card, std::move(legal_message), |
1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 1051 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
1037 weak_ptr_factory_.GetWeakPtr())); | 1052 weak_ptr_factory_.GetWeakPtr())); |
1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, | 1053 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, |
1039 weak_ptr_factory_.GetWeakPtr())); | 1054 weak_ptr_factory_.GetWeakPtr())); |
1040 AutofillMetrics::LogCardUploadDecisionMetric( | 1055 AutofillMetrics::LogCardUploadDecisionMetric( |
1041 AutofillMetrics::UPLOAD_OFFERED); | 1056 AutofillMetrics::UPLOAD_OFFERED); |
| 1057 LogCardUploadDecisionMetricUkm(client_->GetUkmService(), |
| 1058 pending_upload_request_url_, |
| 1059 AutofillMetrics::UPLOAD_OFFERED); |
1042 } else { | 1060 } else { |
1043 // If the upload details request failed, fall back to a local save. The | 1061 // If the upload details request failed, fall back to a local save. The |
1044 // reasoning here is as follows: | 1062 // reasoning here is as follows: |
1045 // - This will sometimes fail intermittently, in which case it might be | 1063 // - This will sometimes fail intermittently, in which case it might be |
1046 // better to not fall back, because sometimes offering upload and sometimes | 1064 // better to not fall back, because sometimes offering upload and sometimes |
1047 // offering local save is a poor user experience. | 1065 // offering local save is a poor user experience. |
1048 // - However, in some cases, our local configuration limiting the feature to | 1066 // - However, in some cases, our local configuration limiting the feature to |
1049 // countries that Payments is known to support will not match Payments' own | 1067 // 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, | 1068 // 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 | 1069 // 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 | 1070 // back to a local save then the user will never be offered any kind of |
1053 // credit card save. | 1071 // credit card save. |
1054 client_->ConfirmSaveCreditCardLocally( | 1072 client_->ConfirmSaveCreditCardLocally( |
1055 upload_request_.card, | 1073 upload_request_.card, |
1056 base::Bind( | 1074 base::Bind( |
1057 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 1075 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
1058 base::Unretained(personal_data_), upload_request_.card)); | 1076 base::Unretained(personal_data_), upload_request_.card)); |
1059 AutofillMetrics::LogCardUploadDecisionMetric( | 1077 AutofillMetrics::LogCardUploadDecisionMetric( |
1060 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 1078 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 1079 LogCardUploadDecisionMetricUkm( |
| 1080 client_->GetUkmService(), pending_upload_request_url_, |
| 1081 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
1061 } | 1082 } |
| 1083 pending_upload_request_url_ = GURL(); |
1062 } | 1084 } |
1063 | 1085 |
1064 void AutofillManager::OnDidUploadCard( | 1086 void AutofillManager::OnDidUploadCard( |
1065 AutofillClient::PaymentsRpcResult result) { | 1087 AutofillClient::PaymentsRpcResult result) { |
1066 // We don't do anything user-visible if the upload attempt fails. | 1088 // We don't do anything user-visible if the upload attempt fails. |
1067 // TODO(jdonnelly): Log duration. | 1089 // TODO(jdonnelly): Log duration. |
1068 } | 1090 } |
1069 | 1091 |
1070 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, | 1092 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, |
1071 const base::string16& cvc) { | 1093 const base::string16& cvc) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 // client-side validation rules. | 1233 // client-side validation rules. |
1212 autofill::AutofillMetrics::CardUploadDecisionMetric | 1234 autofill::AutofillMetrics::CardUploadDecisionMetric |
1213 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; | 1235 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; |
1214 std::string rappor_metric_name; | 1236 std::string rappor_metric_name; |
1215 bool get_profiles_succeeded = | 1237 bool get_profiles_succeeded = |
1216 GetProfilesForCreditCardUpload(*imported_credit_card, | 1238 GetProfilesForCreditCardUpload(*imported_credit_card, |
1217 &upload_request_.profiles, | 1239 &upload_request_.profiles, |
1218 &get_profiles_decision_metric, | 1240 &get_profiles_decision_metric, |
1219 &rappor_metric_name); | 1241 &rappor_metric_name); |
1220 | 1242 |
| 1243 pending_upload_request_url_ = GURL(submitted_form.source_url()); |
| 1244 |
1221 // Both the CVC and address checks are done. Conform to the legacy order of | 1245 // Both the CVC and address checks are done. Conform to the legacy order of |
1222 // reporting on CVC then address. | 1246 // reporting on CVC then address. |
1223 if (upload_request_.cvc.empty()) { | 1247 if (upload_request_.cvc.empty()) { |
1224 AutofillMetrics::LogCardUploadDecisionMetric( | 1248 AutofillMetrics::LogCardUploadDecisionMetric( |
1225 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1249 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1250 LogCardUploadDecisionMetricUkm( |
| 1251 client_->GetUkmService(), pending_upload_request_url_, |
| 1252 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1253 pending_upload_request_url_ = GURL(); |
1226 CollectRapportSample(submitted_form.source_url(), | 1254 CollectRapportSample(submitted_form.source_url(), |
1227 "Autofill.CardUploadNotOfferedNoCvc"); | 1255 "Autofill.CardUploadNotOfferedNoCvc"); |
1228 return; | 1256 return; |
1229 } | 1257 } |
1230 if (!get_profiles_succeeded) { | 1258 if (!get_profiles_succeeded) { |
1231 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); | 1259 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); |
1232 AutofillMetrics::LogCardUploadDecisionMetric( | 1260 AutofillMetrics::LogCardUploadDecisionMetric( |
1233 get_profiles_decision_metric); | 1261 get_profiles_decision_metric); |
| 1262 LogCardUploadDecisionMetricUkm(client_->GetUkmService(), |
| 1263 pending_upload_request_url_, |
| 1264 get_profiles_decision_metric); |
| 1265 pending_upload_request_url_ = GURL(); |
1234 if (!rappor_metric_name.empty()) { | 1266 if (!rappor_metric_name.empty()) { |
1235 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); | 1267 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); |
1236 } | 1268 } |
1237 return; | 1269 return; |
1238 } | 1270 } |
1239 | 1271 |
1240 // All required data is available, start the upload process. | 1272 // All required data is available, start the upload process. |
1241 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); | 1273 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); |
1242 } | 1274 } |
1243 } | 1275 } |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2191 if (i > 0) | 2223 if (i > 0) |
2192 fputs("Next oldest form:\n", file); | 2224 fputs("Next oldest form:\n", file); |
2193 } | 2225 } |
2194 fputs("\n", file); | 2226 fputs("\n", file); |
2195 | 2227 |
2196 fclose(file); | 2228 fclose(file); |
2197 } | 2229 } |
2198 #endif // ENABLE_FORM_DEBUG_DUMP | 2230 #endif // ENABLE_FORM_DEBUG_DUMP |
2199 | 2231 |
2200 } // namespace autofill | 2232 } // namespace autofill |
OLD | NEW |