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

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2863913003: Uses fine grained histogram buckets for CVC errors. (Closed)
Patch Set: Created 3 years, 7 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 true /* is_for_credit_card */, 238 true /* is_for_credit_card */,
239 form_interactions_ukm_logger_.get())), 239 form_interactions_ukm_logger_.get())),
240 has_logged_autofill_enabled_(false), 240 has_logged_autofill_enabled_(false),
241 has_logged_address_suggestions_count_(false), 241 has_logged_address_suggestions_count_(false),
242 did_show_suggestions_(false), 242 did_show_suggestions_(false),
243 user_did_type_(false), 243 user_did_type_(false),
244 user_did_autofill_(false), 244 user_did_autofill_(false),
245 user_did_edit_autofilled_field_(false), 245 user_did_edit_autofilled_field_(false),
246 user_did_accept_upload_prompt_(false), 246 user_did_accept_upload_prompt_(false),
247 should_cvc_be_requested_(false), 247 should_cvc_be_requested_(false),
248 found_cvc_field_(false),
249 found_cvc_value_(false),
248 external_delegate_(NULL), 250 external_delegate_(NULL),
249 test_delegate_(NULL), 251 test_delegate_(NULL),
250 #if defined(OS_ANDROID) || defined(OS_IOS) 252 #if defined(OS_ANDROID) || defined(OS_IOS)
251 autofill_assistant_(this), 253 autofill_assistant_(this),
252 #endif 254 #endif
253 weak_ptr_factory_(this) { 255 weak_ptr_factory_(this) {
254 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) { 256 if (enable_download_manager == ENABLE_AUTOFILL_DOWNLOAD_MANAGER) {
255 download_manager_.reset(new AutofillDownloadManager(driver, this)); 257 download_manager_.reset(new AutofillDownloadManager(driver, this));
256 } 258 }
257 CountryNames::SetLocaleString(app_locale_); 259 CountryNames::SetLocaleString(app_locale_);
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
1048 // credentials until the user has explicitly accepted a prompt to upload. 1050 // credentials until the user has explicitly accepted a prompt to upload.
1049 upload_request_.context_token = context_token; 1051 upload_request_.context_token = context_token;
1050 user_did_accept_upload_prompt_ = false; 1052 user_did_accept_upload_prompt_ = false;
1051 client_->ConfirmSaveCreditCardToCloud( 1053 client_->ConfirmSaveCreditCardToCloud(
1052 upload_request_.card, std::move(legal_message), 1054 upload_request_.card, std::move(legal_message),
1053 should_cvc_be_requested_, 1055 should_cvc_be_requested_,
1054 base::Bind(&AutofillManager::OnUserDidAcceptUpload, 1056 base::Bind(&AutofillManager::OnUserDidAcceptUpload,
1055 weak_ptr_factory_.GetWeakPtr())); 1057 weak_ptr_factory_.GetWeakPtr()));
1056 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, 1058 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData,
1057 weak_ptr_factory_.GetWeakPtr())); 1059 weak_ptr_factory_.GetWeakPtr()));
1058 card_upload_decision_metrics = should_cvc_be_requested_ 1060 card_upload_decision_metrics = AutofillMetrics::UPLOAD_OFFERED;
1059 ? AutofillMetrics::UPLOAD_OFFERED_NO_CVC 1061 if (!found_cvc_field_ || !found_cvc_value_)
1060 : AutofillMetrics::UPLOAD_OFFERED; 1062 DCHECK(should_cvc_be_requested_);
1063 if (found_cvc_field_) {
1064 if (found_cvc_value_) {
1065 if (should_cvc_be_requested_)
1066 card_upload_decision_metrics |= AutofillMetrics::INVALID_CVC_VALUE;
1067 } else {
1068 card_upload_decision_metrics |= AutofillMetrics::CVC_VALUE_NOT_FOUND;
1069 }
1070 } else {
1071 card_upload_decision_metrics |= AutofillMetrics::CVC_FIELD_NOT_FOUND;
1072 }
1061 } else { 1073 } else {
1062 // If the upload details request failed, fall back to a local save. The 1074 // If the upload details request failed, fall back to a local save. The
1063 // reasoning here is as follows: 1075 // reasoning here is as follows:
1064 // - This will sometimes fail intermittently, in which case it might be 1076 // - This will sometimes fail intermittently, in which case it might be
1065 // better to not fall back, because sometimes offering upload and sometimes 1077 // better to not fall back, because sometimes offering upload and sometimes
1066 // offering local save is a poor user experience. 1078 // offering local save is a poor user experience.
1067 // - However, in some cases, our local configuration limiting the feature to 1079 // - However, in some cases, our local configuration limiting the feature to
1068 // countries that Payments is known to support will not match Payments' own 1080 // countries that Payments is known to support will not match Payments' own
1069 // determination of what country the user is located in. In these cases, 1081 // determination of what country the user is located in. In these cases,
1070 // the upload details request will consistently fail and if we don't fall 1082 // the upload details request will consistently fail and if we don't fall
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 // validation rules 1253 // validation rules
1242 // Here we perform both checks before returning or logging anything, 1254 // Here we perform both checks before returning or logging anything,
1243 // because if only one of the two is missing, it may be fixable. 1255 // because if only one of the two is missing, it may be fixable.
1244 1256
1245 // Check for a CVC to determine whether we can prompt the user to upload 1257 // Check for a CVC to determine whether we can prompt the user to upload
1246 // their card. If no CVC is present and the experiment is off, do nothing. 1258 // their card. If no CVC is present and the experiment is off, do nothing.
1247 // We could fall back to a local save but we believe that sometimes offering 1259 // We could fall back to a local save but we believe that sometimes offering
1248 // upload and sometimes offering local save is a confusing user experience. 1260 // upload and sometimes offering local save is a confusing user experience.
1249 // If no CVC and the experiment is on, request CVC from the user in the 1261 // If no CVC and the experiment is on, request CVC from the user in the
1250 // bubble and save using the provided value. 1262 // bubble and save using the provided value.
1263 found_cvc_field_ = false;
1264 found_cvc_value_ = false;
1251 for (const auto& field : submitted_form) { 1265 for (const auto& field : submitted_form) {
1252 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && 1266 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) {
1253 IsValidCreditCardSecurityCode(field->value, 1267 found_cvc_field_ = true;
1254 upload_request_.card.network())) { 1268 if (!field->value.empty())
1255 upload_request_.cvc = field->value; 1269 found_cvc_value_ = true;
1256 break; 1270 if (IsValidCreditCardSecurityCode(field->value,
1271 upload_request_.card.network())) {
1272 upload_request_.cvc = field->value;
1273 break;
1274 }
1257 } 1275 }
1258 } 1276 }
1259 1277
1260 // Upload requires that recently used or modified addresses meet the 1278 // Upload requires that recently used or modified addresses meet the
1261 // client-side validation rules. 1279 // client-side validation rules.
1262 std::string rappor_metric_name; 1280 std::string rappor_metric_name;
1263 int upload_decision_metrics = GetProfilesForCreditCardUpload( 1281 int upload_decision_metrics = GetProfilesForCreditCardUpload(
1264 *imported_credit_card, &upload_request_.profiles, &rappor_metric_name); 1282 *imported_credit_card, &upload_request_.profiles, &rappor_metric_name);
1265 1283
1266 pending_upload_request_url_ = GURL(submitted_form.source_url()); 1284 pending_upload_request_url_ = GURL(submitted_form.source_url());
1267 1285
1268 // Both the CVC and address checks are done. Conform to the legacy order of 1286 // Both the CVC and address checks are done. Conform to the legacy order of
1269 // reporting on CVC then address. 1287 // reporting on CVC then address.
1270 should_cvc_be_requested_ = false; 1288 should_cvc_be_requested_ = false;
1271 if (upload_request_.cvc.empty()) { 1289 if (upload_request_.cvc.empty()) {
1272 should_cvc_be_requested_ = 1290 should_cvc_be_requested_ =
1273 (!upload_decision_metrics && 1291 (!upload_decision_metrics &&
1274 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()); 1292 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled());
1275 if (!should_cvc_be_requested_) { 1293 if (!should_cvc_be_requested_) {
1276 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC; 1294 if (found_cvc_field_)
1295 upload_decision_metrics |= found_cvc_value_
1296 ? AutofillMetrics::INVALID_CVC_VALUE
1297 : AutofillMetrics::CVC_VALUE_NOT_FOUND;
1298 else
1299 upload_decision_metrics |= AutofillMetrics::CVC_FIELD_NOT_FOUND;
1277 rappor_metric_name = "Autofill.CardUploadNotOfferedNoCvc"; 1300 rappor_metric_name = "Autofill.CardUploadNotOfferedNoCvc";
1278 } 1301 }
1279 } 1302 }
1280 if (upload_decision_metrics) { 1303 if (upload_decision_metrics) {
1281 LogCardUploadDecisions(upload_decision_metrics); 1304 LogCardUploadDecisions(upload_decision_metrics);
1282 pending_upload_request_url_ = GURL(); 1305 pending_upload_request_url_ = GURL();
1283 if (!rappor_metric_name.empty()) { 1306 if (!rappor_metric_name.empty()) {
1284 CollectRapporSample(submitted_form.source_url(), rappor_metric_name); 1307 CollectRapporSample(submitted_form.source_url(), rappor_metric_name);
1285 } 1308 }
1286 return; 1309 return;
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
2248 #endif // ENABLE_FORM_DEBUG_DUMP 2271 #endif // ENABLE_FORM_DEBUG_DUMP
2249 2272
2250 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { 2273 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) {
2251 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); 2274 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics);
2252 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), 2275 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(),
2253 pending_upload_request_url_, 2276 pending_upload_request_url_,
2254 upload_decision_metrics); 2277 upload_decision_metrics);
2255 } 2278 }
2256 2279
2257 } // namespace autofill 2280 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698