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

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

Issue 2861223004: Adds new metric to distinguish between no address and no recent address. (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 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1277
1278 // Upload requires that recently used or modified addresses meet the 1278 // Upload requires that recently used or modified addresses meet the
1279 // client-side validation rules. 1279 // client-side validation rules.
1280 std::string rappor_metric_name; 1280 std::string rappor_metric_name;
1281 int upload_decision_metrics = GetProfilesForCreditCardUpload( 1281 int upload_decision_metrics = GetProfilesForCreditCardUpload(
1282 *imported_credit_card, &upload_request_.profiles, &rappor_metric_name); 1282 *imported_credit_card, &upload_request_.profiles, &rappor_metric_name);
1283 1283
1284 pending_upload_request_url_ = GURL(submitted_form.source_url()); 1284 pending_upload_request_url_ = GURL(submitted_form.source_url());
1285 1285
1286 // 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
1287 // reporting on CVC then address. 1287 // reporting on CVC then address.
Jared Saul 2017/05/05 22:17:50 "Conform to the legacy order of reporting on CVC t
csashi 2017/05/05 22:42:26 Done.
1288 should_cvc_be_requested_ = false; 1288 should_cvc_be_requested_ = false;
1289 if (upload_request_.cvc.empty()) { 1289 if (upload_request_.cvc.empty()) {
1290 should_cvc_be_requested_ = 1290 should_cvc_be_requested_ =
1291 (!upload_decision_metrics && 1291 (!upload_decision_metrics &&
1292 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()); 1292 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled());
1293 if (!should_cvc_be_requested_) { 1293 if (!should_cvc_be_requested_) {
1294 if (found_cvc_field_) 1294 if (found_cvc_field_)
1295 upload_decision_metrics |= found_cvc_value_ 1295 upload_decision_metrics |= found_cvc_value_
1296 ? AutofillMetrics::INVALID_CVC_VALUE 1296 ? AutofillMetrics::INVALID_CVC_VALUE
1297 : AutofillMetrics::CVC_VALUE_NOT_FOUND; 1297 : AutofillMetrics::CVC_VALUE_NOT_FOUND;
(...skipping 17 matching lines...) Expand all
1315 } 1315 }
1316 1316
1317 int AutofillManager::GetProfilesForCreditCardUpload( 1317 int AutofillManager::GetProfilesForCreditCardUpload(
1318 const CreditCard& card, 1318 const CreditCard& card,
1319 std::vector<AutofillProfile>* profiles, 1319 std::vector<AutofillProfile>* profiles,
1320 std::string* rappor_metric_name) const { 1320 std::string* rappor_metric_name) const {
1321 std::vector<AutofillProfile> candidate_profiles; 1321 std::vector<AutofillProfile> candidate_profiles;
1322 const base::Time now = AutofillClock::Now(); 1322 const base::Time now = AutofillClock::Now();
1323 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); 1323 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15);
1324 int upload_decision_metrics = 0; 1324 int upload_decision_metrics = 0;
1325 bool has_profile = false;
1325 1326
1326 // First, collect all of the addresses used recently. 1327 // First, collect all of the addresses used recently.
1327 for (AutofillProfile* profile : personal_data_->GetProfiles()) { 1328 for (AutofillProfile* profile : personal_data_->GetProfiles()) {
1329 has_profile = true;
1328 if ((now - profile->use_date()) < fifteen_minutes || 1330 if ((now - profile->use_date()) < fifteen_minutes ||
1329 (now - profile->modification_date()) < fifteen_minutes) { 1331 (now - profile->modification_date()) < fifteen_minutes) {
1330 candidate_profiles.push_back(*profile); 1332 candidate_profiles.push_back(*profile);
1331 } 1333 }
1332 } 1334 }
1333 if (candidate_profiles.empty()) { 1335 if (candidate_profiles.empty()) {
1334 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS; 1336 upload_decision_metrics |=
1337 has_profile
1338 ? AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS
1339 : AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS;
Jared Saul 2017/05/05 22:17:50 nit: Could we change this to reflect it's new clea
csashi 2017/05/05 22:42:26 Done.
1335 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; 1340 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress";
1336 } 1341 }
1337 1342
1338 // If any of the names on the card or the addresses don't match (where 1343 // If any of the names on the card or the addresses don't match (where
1339 // matching is case insensitive and ignores middle initials if present), the 1344 // matching is case insensitive and ignores middle initials if present), the
1340 // candidate set is invalid. This matches the rules for name matching applied 1345 // candidate set is invalid. This matches the rules for name matching applied
1341 // server-side by Google Payments and ensures that we don't send upload 1346 // server-side by Google Payments and ensures that we don't send upload
1342 // requests that are guaranteed to fail. 1347 // requests that are guaranteed to fail.
1343 base::string16 verified_name; 1348 base::string16 verified_name;
1344 const base::string16 card_name = 1349 const base::string16 card_name =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 upload_decision_metrics |= 1405 upload_decision_metrics |=
1401 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS; 1406 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS;
1402 break; 1407 break;
1403 } 1408 }
1404 } 1409 }
1405 } 1410 }
1406 } 1411 }
1407 1412
1408 // If none of the candidate addresses have a zip, the candidate set is 1413 // If none of the candidate addresses have a zip, the candidate set is
1409 // invalid. 1414 // invalid.
1410 if (verified_zip.empty()) 1415 if (verified_zip.empty() && !candidate_profiles.empty())
1411 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; 1416 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE;
1412 1417
1413 if (!upload_decision_metrics) 1418 if (!upload_decision_metrics)
1414 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); 1419 profiles->assign(candidate_profiles.begin(), candidate_profiles.end());
1415 1420
1416 return upload_decision_metrics; 1421 return upload_decision_metrics;
1417 } 1422 }
1418 1423
1419 void AutofillManager::CollectRapporSample( 1424 void AutofillManager::CollectRapporSample(
1420 const GURL& source_url, 1425 const GURL& source_url,
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 #endif // ENABLE_FORM_DEBUG_DUMP 2276 #endif // ENABLE_FORM_DEBUG_DUMP
2272 2277
2273 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { 2278 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) {
2274 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); 2279 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics);
2275 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), 2280 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(),
2276 pending_upload_request_url_, 2281 pending_upload_request_url_,
2277 upload_decision_metrics); 2282 upload_decision_metrics);
2278 } 2283 }
2279 2284
2280 } // namespace autofill 2285 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698