| 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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 } | 1276 } |
| 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 | |
| 1287 // reporting on CVC then address. | |
| 1288 should_cvc_be_requested_ = false; | 1286 should_cvc_be_requested_ = false; |
| 1289 if (upload_request_.cvc.empty()) { | 1287 if (upload_request_.cvc.empty()) { |
| 1290 should_cvc_be_requested_ = | 1288 should_cvc_be_requested_ = |
| 1291 (!upload_decision_metrics && | 1289 (!upload_decision_metrics && |
| 1292 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()); | 1290 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()); |
| 1293 if (!should_cvc_be_requested_) { | 1291 if (!should_cvc_be_requested_) { |
| 1294 if (found_cvc_field_) | 1292 if (found_cvc_field_) |
| 1295 upload_decision_metrics |= found_cvc_value_ | 1293 upload_decision_metrics |= found_cvc_value_ |
| 1296 ? AutofillMetrics::INVALID_CVC_VALUE | 1294 ? AutofillMetrics::INVALID_CVC_VALUE |
| 1297 : AutofillMetrics::CVC_VALUE_NOT_FOUND; | 1295 : AutofillMetrics::CVC_VALUE_NOT_FOUND; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1315 } | 1313 } |
| 1316 | 1314 |
| 1317 int AutofillManager::GetProfilesForCreditCardUpload( | 1315 int AutofillManager::GetProfilesForCreditCardUpload( |
| 1318 const CreditCard& card, | 1316 const CreditCard& card, |
| 1319 std::vector<AutofillProfile>* profiles, | 1317 std::vector<AutofillProfile>* profiles, |
| 1320 std::string* rappor_metric_name) const { | 1318 std::string* rappor_metric_name) const { |
| 1321 std::vector<AutofillProfile> candidate_profiles; | 1319 std::vector<AutofillProfile> candidate_profiles; |
| 1322 const base::Time now = AutofillClock::Now(); | 1320 const base::Time now = AutofillClock::Now(); |
| 1323 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); | 1321 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); |
| 1324 int upload_decision_metrics = 0; | 1322 int upload_decision_metrics = 0; |
| 1323 bool has_profile = false; |
| 1325 | 1324 |
| 1326 // First, collect all of the addresses used recently. | 1325 // First, collect all of the addresses used recently. |
| 1327 for (AutofillProfile* profile : personal_data_->GetProfiles()) { | 1326 for (AutofillProfile* profile : personal_data_->GetProfiles()) { |
| 1327 has_profile = true; |
| 1328 if ((now - profile->use_date()) < fifteen_minutes || | 1328 if ((now - profile->use_date()) < fifteen_minutes || |
| 1329 (now - profile->modification_date()) < fifteen_minutes) { | 1329 (now - profile->modification_date()) < fifteen_minutes) { |
| 1330 candidate_profiles.push_back(*profile); | 1330 candidate_profiles.push_back(*profile); |
| 1331 } | 1331 } |
| 1332 } | 1332 } |
| 1333 if (candidate_profiles.empty()) { | 1333 if (candidate_profiles.empty()) { |
| 1334 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS; | 1334 upload_decision_metrics |= |
| 1335 has_profile |
| 1336 ? AutofillMetrics::UPLOAD_NOT_OFFERED_NO_RECENTLY_USED_ADDRESS |
| 1337 : AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS_PROFILE; |
| 1335 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; | 1338 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; |
| 1336 } | 1339 } |
| 1337 | 1340 |
| 1338 // If any of the names on the card or the addresses don't match (where | 1341 // 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 | 1342 // matching is case insensitive and ignores middle initials if present), the |
| 1340 // candidate set is invalid. This matches the rules for name matching applied | 1343 // 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 | 1344 // server-side by Google Payments and ensures that we don't send upload |
| 1342 // requests that are guaranteed to fail. | 1345 // requests that are guaranteed to fail. |
| 1343 base::string16 verified_name; | 1346 base::string16 verified_name; |
| 1344 const base::string16 card_name = | 1347 const base::string16 card_name = |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 upload_decision_metrics |= | 1403 upload_decision_metrics |= |
| 1401 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS; | 1404 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS; |
| 1402 break; | 1405 break; |
| 1403 } | 1406 } |
| 1404 } | 1407 } |
| 1405 } | 1408 } |
| 1406 } | 1409 } |
| 1407 | 1410 |
| 1408 // If none of the candidate addresses have a zip, the candidate set is | 1411 // If none of the candidate addresses have a zip, the candidate set is |
| 1409 // invalid. | 1412 // invalid. |
| 1410 if (verified_zip.empty()) | 1413 if (verified_zip.empty() && !candidate_profiles.empty()) |
| 1411 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; | 1414 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; |
| 1412 | 1415 |
| 1413 if (!upload_decision_metrics) | 1416 if (!upload_decision_metrics) |
| 1414 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); | 1417 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); |
| 1415 | 1418 |
| 1416 return upload_decision_metrics; | 1419 return upload_decision_metrics; |
| 1417 } | 1420 } |
| 1418 | 1421 |
| 1419 void AutofillManager::CollectRapporSample( | 1422 void AutofillManager::CollectRapporSample( |
| 1420 const GURL& source_url, | 1423 const GURL& source_url, |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2271 #endif // ENABLE_FORM_DEBUG_DUMP | 2274 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2272 | 2275 |
| 2273 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { | 2276 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { |
| 2274 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); | 2277 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); |
| 2275 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), | 2278 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), |
| 2276 pending_upload_request_url_, | 2279 pending_upload_request_url_, |
| 2277 upload_decision_metrics); | 2280 upload_decision_metrics); |
| 2278 } | 2281 } |
| 2279 | 2282 |
| 2280 } // namespace autofill | 2283 } // namespace autofill |
| OLD | NEW |