Chromium Code Reviews| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), | 227 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), |
| 228 credit_card_form_event_logger_( | 228 credit_card_form_event_logger_( |
| 229 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), | 229 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), |
| 230 has_logged_autofill_enabled_(false), | 230 has_logged_autofill_enabled_(false), |
| 231 has_logged_address_suggestions_count_(false), | 231 has_logged_address_suggestions_count_(false), |
| 232 did_show_suggestions_(false), | 232 did_show_suggestions_(false), |
| 233 user_did_type_(false), | 233 user_did_type_(false), |
| 234 user_did_autofill_(false), | 234 user_did_autofill_(false), |
| 235 user_did_edit_autofilled_field_(false), | 235 user_did_edit_autofilled_field_(false), |
| 236 user_did_accept_upload_prompt_(false), | 236 user_did_accept_upload_prompt_(false), |
| 237 upload_cvc_should_be_requested_(false), | |
| 237 external_delegate_(NULL), | 238 external_delegate_(NULL), |
| 238 test_delegate_(NULL), | 239 test_delegate_(NULL), |
| 239 #if defined(OS_ANDROID) || defined(OS_IOS) | 240 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 240 autofill_assistant_(this), | 241 autofill_assistant_(this), |
| 241 #endif | 242 #endif |
| 242 weak_ptr_factory_(this) { | 243 weak_ptr_factory_(this) { |
| 243 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { | 244 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { |
| 244 download_manager_.reset(new AutofillDownloadManager(driver, this)); | 245 download_manager_.reset(new AutofillDownloadManager(driver, this)); |
| 245 } | 246 } |
| 246 CountryNames::SetLocaleString(app_locale_); | 247 CountryNames::SetLocaleString(app_locale_); |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 void AutofillManager::OnDidGetUploadDetails( | 1025 void AutofillManager::OnDidGetUploadDetails( |
| 1025 AutofillClient::PaymentsRpcResult result, | 1026 AutofillClient::PaymentsRpcResult result, |
| 1026 const base::string16& context_token, | 1027 const base::string16& context_token, |
| 1027 std::unique_ptr<base::DictionaryValue> legal_message) { | 1028 std::unique_ptr<base::DictionaryValue> legal_message) { |
| 1028 // TODO(jdonnelly): Log duration. | 1029 // TODO(jdonnelly): Log duration. |
| 1029 if (result == AutofillClient::SUCCESS) { | 1030 if (result == AutofillClient::SUCCESS) { |
| 1030 // Do *not* call payments_client_->Prepare() here. We shouldn't send | 1031 // Do *not* call payments_client_->Prepare() here. We shouldn't send |
| 1031 // credentials until the user has explicitly accepted a prompt to upload. | 1032 // credentials until the user has explicitly accepted a prompt to upload. |
| 1032 upload_request_.context_token = context_token; | 1033 upload_request_.context_token = context_token; |
| 1033 user_did_accept_upload_prompt_ = false; | 1034 user_did_accept_upload_prompt_ = false; |
| 1035 | |
| 1034 client_->ConfirmSaveCreditCardToCloud( | 1036 client_->ConfirmSaveCreditCardToCloud( |
| 1035 upload_request_.card, std::move(legal_message), | 1037 upload_request_.card, std::move(legal_message), |
| 1038 upload_cvc_should_be_requested_, | |
| 1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 1039 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
| 1037 weak_ptr_factory_.GetWeakPtr())); | 1040 weak_ptr_factory_.GetWeakPtr())); |
| 1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, | 1041 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, |
| 1039 weak_ptr_factory_.GetWeakPtr())); | 1042 weak_ptr_factory_.GetWeakPtr())); |
| 1040 AutofillMetrics::LogCardUploadDecisionMetric( | 1043 AutofillMetrics::CardUploadDecisionMetric cardUploadDecisionMetric = |
| 1041 AutofillMetrics::UPLOAD_OFFERED); | 1044 upload_cvc_should_be_requested_ ? AutofillMetrics::UPLOAD_OFFERED_NO_CVC |
|
csashi
2017/03/31 21:48:15
s/NO_CVC/CVC_MISSING or CVC_REQUESTED ?
Jared Saul
2017/04/01 04:18:02
Ooh, I really like UPLOAD_OFFERED_CVC_MISSING, but
| |
| 1042 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 1045 : AutofillMetrics::UPLOAD_OFFERED; |
| 1046 AutofillMetrics::LogCardUploadDecisionMetric(cardUploadDecisionMetric); | |
| 1047 LogCardUploadDecisionUkm(cardUploadDecisionMetric); | |
| 1043 } else { | 1048 } else { |
| 1044 // If the upload details request failed, fall back to a local save. The | 1049 // If the upload details request failed, fall back to a local save. The |
| 1045 // reasoning here is as follows: | 1050 // reasoning here is as follows: |
| 1046 // - This will sometimes fail intermittently, in which case it might be | 1051 // - This will sometimes fail intermittently, in which case it might be |
| 1047 // better to not fall back, because sometimes offering upload and sometimes | 1052 // better to not fall back, because sometimes offering upload and sometimes |
| 1048 // offering local save is a poor user experience. | 1053 // offering local save is a poor user experience. |
| 1049 // - However, in some cases, our local configuration limiting the feature to | 1054 // - However, in some cases, our local configuration limiting the feature to |
| 1050 // countries that Payments is known to support will not match Payments' own | 1055 // countries that Payments is known to support will not match Payments' own |
| 1051 // determination of what country the user is located in. In these cases, | 1056 // determination of what country the user is located in. In these cases, |
| 1052 // the upload details request will consistently fail and if we don't fall | 1057 // the upload details request will consistently fail and if we don't fall |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1092 | 1097 |
| 1093 void AutofillManager::OnUnmaskVerificationResult( | 1098 void AutofillManager::OnUnmaskVerificationResult( |
| 1094 AutofillClient::PaymentsRpcResult result) { | 1099 AutofillClient::PaymentsRpcResult result) { |
| 1095 client_->OnUnmaskVerificationResult(result); | 1100 client_->OnUnmaskVerificationResult(result); |
| 1096 } | 1101 } |
| 1097 | 1102 |
| 1098 void AutofillManager::OnUserDidAcceptUpload() { | 1103 void AutofillManager::OnUserDidAcceptUpload() { |
| 1099 user_did_accept_upload_prompt_ = true; | 1104 user_did_accept_upload_prompt_ = true; |
| 1100 if (!upload_request_.risk_data.empty()) { | 1105 if (!upload_request_.risk_data.empty()) { |
| 1101 upload_request_.app_locale = app_locale_; | 1106 upload_request_.app_locale = app_locale_; |
| 1107 // If the upload request does not have card CVC, populate it with the value | |
| 1108 // provided by the user: | |
| 1109 if (upload_request_.cvc.empty()) { | |
| 1110 upload_request_.cvc = | |
| 1111 client_->GetSaveCardBubbleController()->GetUserProvidedCvc(); | |
| 1112 } | |
| 1102 payments_client_->UploadCard(upload_request_); | 1113 payments_client_->UploadCard(upload_request_); |
| 1103 } | 1114 } |
| 1104 } | 1115 } |
| 1105 | 1116 |
| 1106 void AutofillManager::OnDidGetUploadRiskData(const std::string& risk_data) { | 1117 void AutofillManager::OnDidGetUploadRiskData(const std::string& risk_data) { |
| 1107 upload_request_.risk_data = risk_data; | 1118 upload_request_.risk_data = risk_data; |
| 1108 if (user_did_accept_upload_prompt_) { | 1119 if (user_did_accept_upload_prompt_) { |
| 1109 upload_request_.app_locale = app_locale_; | 1120 upload_request_.app_locale = app_locale_; |
| 1121 // If the upload request does not have card CVC, populate it with the value | |
| 1122 // provided by the user: | |
| 1123 if (upload_request_.cvc.empty()) { | |
| 1124 upload_request_.cvc = | |
| 1125 client_->GetSaveCardBubbleController()->GetUserProvidedCvc(); | |
| 1126 } | |
| 1110 payments_client_->UploadCard(upload_request_); | 1127 payments_client_->UploadCard(upload_request_); |
| 1111 } | 1128 } |
| 1112 } | 1129 } |
| 1113 | 1130 |
| 1114 void AutofillManager::OnDidEndTextFieldEditing() { | 1131 void AutofillManager::OnDidEndTextFieldEditing() { |
| 1115 external_delegate_->DidEndTextFieldEditing(); | 1132 external_delegate_->DidEndTextFieldEditing(); |
| 1116 } | 1133 } |
| 1117 | 1134 |
| 1118 bool AutofillManager::IsAutofillEnabled() const { | 1135 bool AutofillManager::IsAutofillEnabled() const { |
| 1119 return ::autofill::IsAutofillEnabled(client_->GetPrefs()); | 1136 return ::autofill::IsAutofillEnabled(client_->GetPrefs()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1192 upload_request_.card = *imported_credit_card; | 1209 upload_request_.card = *imported_credit_card; |
| 1193 | 1210 |
| 1194 // In order to prompt the user to upload their card, we must have both: | 1211 // In order to prompt the user to upload their card, we must have both: |
| 1195 // 1) Card with CVC | 1212 // 1) Card with CVC |
| 1196 // 2) 1+ recently-used or modified addresses that meet the client-side | 1213 // 2) 1+ recently-used or modified addresses that meet the client-side |
| 1197 // validation rules | 1214 // validation rules |
| 1198 // Here we perform both checks before returning or logging anything, | 1215 // Here we perform both checks before returning or logging anything, |
| 1199 // because if only one of the two is missing, it may be fixable. | 1216 // because if only one of the two is missing, it may be fixable. |
| 1200 | 1217 |
| 1201 // Check for a CVC to determine whether we can prompt the user to upload | 1218 // Check for a CVC to determine whether we can prompt the user to upload |
| 1202 // their card. If no CVC is present, do nothing. We could fall back to a | 1219 // their card. If no CVC is present and the experiment is off, do nothing. |
| 1203 // local save but we believe that sometimes offering upload and sometimes | 1220 // We could fall back to a local save but we believe that sometimes offering |
| 1204 // offering local save is a confusing user experience. | 1221 // upload and sometimes offering local save is a confusing user experience. |
|
csashi
2017/03/31 21:48:15
You can remove these 2 lines (rationale for these
Jared Saul
2017/04/01 04:18:02
These lines were already here, they just got moved
| |
| 1222 // If no CVC and the experiment is on, request CVC from the user in the | |
| 1223 // bubble and save using the provided value. | |
| 1205 for (const auto& field : submitted_form) { | 1224 for (const auto& field : submitted_form) { |
| 1206 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && | 1225 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && |
| 1207 IsValidCreditCardSecurityCode(field->value, | 1226 IsValidCreditCardSecurityCode(field->value, |
| 1208 upload_request_.card.type())) { | 1227 upload_request_.card.type())) { |
| 1209 upload_request_.cvc = field->value; | 1228 upload_request_.cvc = field->value; |
| 1210 break; | 1229 break; |
| 1211 } | 1230 } |
| 1212 } | 1231 } |
| 1213 | 1232 |
| 1214 // Upload requires that recently used or modified addresses meet the | 1233 // Upload requires that recently used or modified addresses meet the |
| 1215 // client-side validation rules. | 1234 // client-side validation rules. |
| 1216 autofill::AutofillMetrics::CardUploadDecisionMetric | 1235 autofill::AutofillMetrics::CardUploadDecisionMetric |
| 1217 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; | 1236 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; |
| 1218 std::string rappor_metric_name; | 1237 std::string rappor_metric_name; |
| 1219 bool get_profiles_succeeded = | 1238 bool get_profiles_succeeded = |
| 1220 GetProfilesForCreditCardUpload(*imported_credit_card, | 1239 GetProfilesForCreditCardUpload(*imported_credit_card, |
| 1221 &upload_request_.profiles, | 1240 &upload_request_.profiles, |
| 1222 &get_profiles_decision_metric, | 1241 &get_profiles_decision_metric, |
| 1223 &rappor_metric_name); | 1242 &rappor_metric_name); |
| 1224 | 1243 |
| 1225 pending_upload_request_url_ = GURL(submitted_form.source_url()); | 1244 pending_upload_request_url_ = GURL(submitted_form.source_url()); |
| 1226 | 1245 |
| 1227 // Both the CVC and address checks are done. Conform to the legacy order of | 1246 // Both the CVC and address checks are done. Conform to the legacy order of |
| 1228 // reporting on CVC then address. | 1247 // reporting on CVC then address. |
| 1248 upload_cvc_should_be_requested_ = false; | |
| 1229 if (upload_request_.cvc.empty()) { | 1249 if (upload_request_.cvc.empty()) { |
| 1230 AutofillMetrics::LogCardUploadDecisionMetric( | 1250 if (IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()) { |
| 1231 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1251 upload_cvc_should_be_requested_ = true; |
| 1232 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1252 } else { |
| 1233 pending_upload_request_url_ = GURL(); | 1253 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1234 CollectRapportSample(submitted_form.source_url(), | 1254 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1235 "Autofill.CardUploadNotOfferedNoCvc"); | 1255 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1236 return; | 1256 pending_upload_request_url_ = GURL(); |
| 1257 CollectRapportSample(submitted_form.source_url(), | |
| 1258 "Autofill.CardUploadNotOfferedNoCvc"); | |
| 1259 return; | |
| 1260 } | |
| 1237 } | 1261 } |
| 1238 if (!get_profiles_succeeded) { | 1262 if (!get_profiles_succeeded) { |
| 1239 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); | 1263 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); |
| 1240 AutofillMetrics::LogCardUploadDecisionMetric( | 1264 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1241 get_profiles_decision_metric); | 1265 get_profiles_decision_metric); |
| 1242 LogCardUploadDecisionUkm(get_profiles_decision_metric); | 1266 LogCardUploadDecisionUkm(get_profiles_decision_metric); |
| 1243 pending_upload_request_url_ = GURL(); | 1267 pending_upload_request_url_ = GURL(); |
| 1244 if (!rappor_metric_name.empty()) { | 1268 if (!rappor_metric_name.empty()) { |
| 1245 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); | 1269 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); |
| 1246 } | 1270 } |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2198 } | 2222 } |
| 2199 #endif // ENABLE_FORM_DEBUG_DUMP | 2223 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2200 | 2224 |
| 2201 void AutofillManager::LogCardUploadDecisionUkm( | 2225 void AutofillManager::LogCardUploadDecisionUkm( |
| 2202 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 2226 AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
| 2203 AutofillMetrics::LogCardUploadDecisionUkm( | 2227 AutofillMetrics::LogCardUploadDecisionUkm( |
| 2204 client_->GetUkmService(), pending_upload_request_url_, upload_decision); | 2228 client_->GetUkmService(), pending_upload_request_url_, upload_decision); |
| 2205 } | 2229 } |
| 2206 | 2230 |
| 2207 } // namespace autofill | 2231 } // namespace autofill |
| OLD | NEW |