| 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 24 matching lines...) Expand all Loading... |
| 35 #include "build/build_config.h" | 35 #include "build/build_config.h" |
| 36 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 36 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 37 #include "components/autofill/core/browser/autofill_client.h" | 37 #include "components/autofill/core/browser/autofill_client.h" |
| 38 #include "components/autofill/core/browser/autofill_data_model.h" | 38 #include "components/autofill/core/browser/autofill_data_model.h" |
| 39 #include "components/autofill/core/browser/autofill_experiments.h" | 39 #include "components/autofill/core/browser/autofill_experiments.h" |
| 40 #include "components/autofill/core/browser/autofill_external_delegate.h" | 40 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 41 #include "components/autofill/core/browser/autofill_field.h" | 41 #include "components/autofill/core/browser/autofill_field.h" |
| 42 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" | 42 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" |
| 43 #include "components/autofill/core/browser/autofill_metrics.h" | 43 #include "components/autofill/core/browser/autofill_metrics.h" |
| 44 #include "components/autofill/core/browser/autofill_profile.h" | 44 #include "components/autofill/core/browser/autofill_profile.h" |
| 45 #include "components/autofill/core/browser/autofill_profile_comparator.h" |
| 45 #include "components/autofill/core/browser/autofill_type.h" | 46 #include "components/autofill/core/browser/autofill_type.h" |
| 46 #include "components/autofill/core/browser/country_names.h" | 47 #include "components/autofill/core/browser/country_names.h" |
| 47 #include "components/autofill/core/browser/credit_card.h" | 48 #include "components/autofill/core/browser/credit_card.h" |
| 48 #include "components/autofill/core/browser/field_types.h" | 49 #include "components/autofill/core/browser/field_types.h" |
| 49 #include "components/autofill/core/browser/form_structure.h" | 50 #include "components/autofill/core/browser/form_structure.h" |
| 50 #include "components/autofill/core/browser/personal_data_manager.h" | 51 #include "components/autofill/core/browser/personal_data_manager.h" |
| 51 #include "components/autofill/core/browser/phone_number.h" | 52 #include "components/autofill/core/browser/phone_number.h" |
| 52 #include "components/autofill/core/browser/phone_number_i18n.h" | 53 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 53 #include "components/autofill/core/browser/popup_item_ids.h" | 54 #include "components/autofill/core/browser/popup_item_ids.h" |
| 54 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h" | 55 #include "components/autofill/core/browser/ui/save_card_bubble_controller.h" |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 void AutofillManager::OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, | 1035 void AutofillManager::OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, |
| 1035 const std::string& real_pan) { | 1036 const std::string& real_pan) { |
| 1036 DCHECK(full_card_request_); | 1037 DCHECK(full_card_request_); |
| 1037 full_card_request_->OnDidGetRealPan(result, real_pan); | 1038 full_card_request_->OnDidGetRealPan(result, real_pan); |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 void AutofillManager::OnDidGetUploadDetails( | 1041 void AutofillManager::OnDidGetUploadDetails( |
| 1041 AutofillClient::PaymentsRpcResult result, | 1042 AutofillClient::PaymentsRpcResult result, |
| 1042 const base::string16& context_token, | 1043 const base::string16& context_token, |
| 1043 std::unique_ptr<base::DictionaryValue> legal_message) { | 1044 std::unique_ptr<base::DictionaryValue> legal_message) { |
| 1044 // TODO(jdonnelly): Log duration. | 1045 int card_upload_decision_metrics; |
| 1045 if (result == AutofillClient::SUCCESS) { | 1046 if (result == AutofillClient::SUCCESS) { |
| 1046 // Do *not* call payments_client_->Prepare() here. We shouldn't send | 1047 // Do *not* call payments_client_->Prepare() here. We shouldn't send |
| 1047 // credentials until the user has explicitly accepted a prompt to upload. | 1048 // credentials until the user has explicitly accepted a prompt to upload. |
| 1048 upload_request_.context_token = context_token; | 1049 upload_request_.context_token = context_token; |
| 1049 user_did_accept_upload_prompt_ = false; | 1050 user_did_accept_upload_prompt_ = false; |
| 1050 client_->ConfirmSaveCreditCardToCloud( | 1051 client_->ConfirmSaveCreditCardToCloud( |
| 1051 upload_request_.card, std::move(legal_message), | 1052 upload_request_.card, std::move(legal_message), |
| 1052 should_cvc_be_requested_, | 1053 should_cvc_be_requested_, |
| 1053 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 1054 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
| 1054 weak_ptr_factory_.GetWeakPtr())); | 1055 weak_ptr_factory_.GetWeakPtr())); |
| 1055 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, | 1056 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, |
| 1056 weak_ptr_factory_.GetWeakPtr())); | 1057 weak_ptr_factory_.GetWeakPtr())); |
| 1057 AutofillMetrics::CardUploadDecisionMetric card_upload_decision_metric = | 1058 card_upload_decision_metrics = should_cvc_be_requested_ |
| 1058 should_cvc_be_requested_ ? AutofillMetrics::UPLOAD_OFFERED_NO_CVC | 1059 ? AutofillMetrics::UPLOAD_OFFERED_NO_CVC |
| 1059 : AutofillMetrics::UPLOAD_OFFERED; | 1060 : AutofillMetrics::UPLOAD_OFFERED; |
| 1060 AutofillMetrics::LogCardUploadDecisionMetric(card_upload_decision_metric); | |
| 1061 LogCardUploadDecisionUkm(card_upload_decision_metric); | |
| 1062 } else { | 1061 } else { |
| 1063 // If the upload details request failed, fall back to a local save. The | 1062 // If the upload details request failed, fall back to a local save. The |
| 1064 // reasoning here is as follows: | 1063 // reasoning here is as follows: |
| 1065 // - This will sometimes fail intermittently, in which case it might be | 1064 // - This will sometimes fail intermittently, in which case it might be |
| 1066 // better to not fall back, because sometimes offering upload and sometimes | 1065 // better to not fall back, because sometimes offering upload and sometimes |
| 1067 // offering local save is a poor user experience. | 1066 // offering local save is a poor user experience. |
| 1068 // - However, in some cases, our local configuration limiting the feature to | 1067 // - However, in some cases, our local configuration limiting the feature to |
| 1069 // countries that Payments is known to support will not match Payments' own | 1068 // countries that Payments is known to support will not match Payments' own |
| 1070 // determination of what country the user is located in. In these cases, | 1069 // determination of what country the user is located in. In these cases, |
| 1071 // the upload details request will consistently fail and if we don't fall | 1070 // the upload details request will consistently fail and if we don't fall |
| 1072 // back to a local save then the user will never be offered any kind of | 1071 // back to a local save then the user will never be offered any kind of |
| 1073 // credit card save. | 1072 // credit card save. |
| 1074 client_->ConfirmSaveCreditCardLocally( | 1073 client_->ConfirmSaveCreditCardLocally( |
| 1075 upload_request_.card, | 1074 upload_request_.card, |
| 1076 base::Bind( | 1075 base::Bind( |
| 1077 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 1076 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
| 1078 base::Unretained(personal_data_), upload_request_.card)); | 1077 base::Unretained(personal_data_), upload_request_.card)); |
| 1079 AutofillMetrics::LogCardUploadDecisionMetric( | 1078 card_upload_decision_metrics = |
| 1080 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 1079 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED; |
| 1081 LogCardUploadDecisionUkm( | |
| 1082 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | |
| 1083 } | 1080 } |
| 1081 LogCardUploadDecisions(card_upload_decision_metrics); |
| 1084 pending_upload_request_url_ = GURL(); | 1082 pending_upload_request_url_ = GURL(); |
| 1085 } | 1083 } |
| 1086 | 1084 |
| 1087 void AutofillManager::OnDidUploadCard(AutofillClient::PaymentsRpcResult result, | 1085 void AutofillManager::OnDidUploadCard(AutofillClient::PaymentsRpcResult result, |
| 1088 const std::string& server_id) { | 1086 const std::string& server_id) { |
| 1089 // We don't do anything user-visible if the upload attempt fails. | 1087 // We don't do anything user-visible if the upload attempt fails. |
| 1090 // If the upload succeeds, we will keep a copy of the card as a full server | 1088 // If the upload succeeds, we will keep a copy of the card as a full server |
| 1091 // card on the device. | 1089 // card on the device. |
| 1092 if (result == AutofillClient::SUCCESS && !server_id.empty()) { | 1090 if (result == AutofillClient::SUCCESS && !server_id.empty()) { |
| 1093 upload_request_.card.set_record_type(CreditCard::FULL_SERVER_CARD); | 1091 upload_request_.card.set_record_type(CreditCard::FULL_SERVER_CARD); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1250 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && | 1248 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE && |
| 1251 IsValidCreditCardSecurityCode(field->value, | 1249 IsValidCreditCardSecurityCode(field->value, |
| 1252 upload_request_.card.network())) { | 1250 upload_request_.card.network())) { |
| 1253 upload_request_.cvc = field->value; | 1251 upload_request_.cvc = field->value; |
| 1254 break; | 1252 break; |
| 1255 } | 1253 } |
| 1256 } | 1254 } |
| 1257 | 1255 |
| 1258 // Upload requires that recently used or modified addresses meet the | 1256 // Upload requires that recently used or modified addresses meet the |
| 1259 // client-side validation rules. | 1257 // client-side validation rules. |
| 1260 autofill::AutofillMetrics::CardUploadDecisionMetric | |
| 1261 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; | |
| 1262 std::string rappor_metric_name; | 1258 std::string rappor_metric_name; |
| 1263 bool get_profiles_succeeded = | 1259 int upload_decision_metrics = GetProfilesForCreditCardUpload( |
| 1264 GetProfilesForCreditCardUpload(*imported_credit_card, | 1260 *imported_credit_card, &upload_request_.profiles, &rappor_metric_name); |
| 1265 &upload_request_.profiles, | |
| 1266 &get_profiles_decision_metric, | |
| 1267 &rappor_metric_name); | |
| 1268 | 1261 |
| 1269 pending_upload_request_url_ = GURL(submitted_form.source_url()); | 1262 pending_upload_request_url_ = GURL(submitted_form.source_url()); |
| 1270 | 1263 |
| 1271 // Both the CVC and address checks are done. Conform to the legacy order of | 1264 // Both the CVC and address checks are done. Conform to the legacy order of |
| 1272 // reporting on CVC then address. | 1265 // reporting on CVC then address. |
| 1273 should_cvc_be_requested_ = false; | 1266 should_cvc_be_requested_ = false; |
| 1274 if (upload_request_.cvc.empty()) { | 1267 if (upload_request_.cvc.empty()) { |
| 1275 if (IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()) { | 1268 should_cvc_be_requested_ = |
| 1276 should_cvc_be_requested_ = true; | 1269 (!upload_decision_metrics && |
| 1277 } else { | 1270 IsAutofillUpstreamRequestCvcIfMissingExperimentEnabled()); |
| 1278 AutofillMetrics::LogCardUploadDecisionMetric( | 1271 if (!should_cvc_be_requested_) { |
| 1279 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1272 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC; |
| 1280 LogCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1273 rappor_metric_name = "Autofill.CardUploadNotOfferedNoCvc"; |
| 1281 pending_upload_request_url_ = GURL(); | |
| 1282 CollectRapportSample(submitted_form.source_url(), | |
| 1283 "Autofill.CardUploadNotOfferedNoCvc"); | |
| 1284 return; | |
| 1285 } | 1274 } |
| 1286 } | 1275 } |
| 1287 if (!get_profiles_succeeded) { | 1276 if (upload_decision_metrics) { |
| 1288 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); | 1277 LogCardUploadDecisions(upload_decision_metrics); |
| 1289 AutofillMetrics::LogCardUploadDecisionMetric( | |
| 1290 get_profiles_decision_metric); | |
| 1291 LogCardUploadDecisionUkm(get_profiles_decision_metric); | |
| 1292 pending_upload_request_url_ = GURL(); | 1278 pending_upload_request_url_ = GURL(); |
| 1293 if (!rappor_metric_name.empty()) { | 1279 if (!rappor_metric_name.empty()) { |
| 1294 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); | 1280 CollectRapporSample(submitted_form.source_url(), rappor_metric_name); |
| 1295 } | 1281 } |
| 1296 return; | 1282 return; |
| 1297 } | 1283 } |
| 1298 | 1284 |
| 1299 // All required data is available, start the upload process. | 1285 // All required data is available, start the upload process. |
| 1300 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); | 1286 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); |
| 1301 } | 1287 } |
| 1302 } | 1288 } |
| 1303 | 1289 |
| 1304 bool AutofillManager::GetProfilesForCreditCardUpload( | 1290 int AutofillManager::GetProfilesForCreditCardUpload( |
| 1305 const CreditCard& card, | 1291 const CreditCard& card, |
| 1306 std::vector<AutofillProfile>* profiles, | 1292 std::vector<AutofillProfile>* profiles, |
| 1307 autofill::AutofillMetrics::CardUploadDecisionMetric* | |
| 1308 address_upload_decision_metric, | |
| 1309 std::string* rappor_metric_name) const { | 1293 std::string* rappor_metric_name) const { |
| 1310 std::vector<AutofillProfile> candidate_profiles; | 1294 std::vector<AutofillProfile> candidate_profiles; |
| 1311 const base::Time now = AutofillClock::Now(); | 1295 const base::Time now = AutofillClock::Now(); |
| 1312 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); | 1296 const base::TimeDelta fifteen_minutes = base::TimeDelta::FromMinutes(15); |
| 1297 int upload_decision_metrics = 0; |
| 1313 | 1298 |
| 1314 // First, collect all of the addresses used recently. | 1299 // First, collect all of the addresses used recently. |
| 1315 for (AutofillProfile* profile : personal_data_->GetProfiles()) { | 1300 for (AutofillProfile* profile : personal_data_->GetProfiles()) { |
| 1316 if ((now - profile->use_date()) < fifteen_minutes || | 1301 if ((now - profile->use_date()) < fifteen_minutes || |
| 1317 (now - profile->modification_date()) < fifteen_minutes) { | 1302 (now - profile->modification_date()) < fifteen_minutes) { |
| 1318 candidate_profiles.push_back(*profile); | 1303 candidate_profiles.push_back(*profile); |
| 1319 } | 1304 } |
| 1320 } | 1305 } |
| 1321 if (candidate_profiles.empty()) { | 1306 if (candidate_profiles.empty()) { |
| 1322 *address_upload_decision_metric = | 1307 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS; |
| 1323 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS; | |
| 1324 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; | 1308 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoAddress"; |
| 1325 return false; | |
| 1326 } | 1309 } |
| 1327 | 1310 |
| 1328 // If any of the names on the card or the addresses don't match (where | 1311 // If any of the names on the card or the addresses don't match (where |
| 1329 // matching is case insensitive and ignores middle initials if present), the | 1312 // matching is case insensitive and ignores middle initials if present), the |
| 1330 // candidate set is invalid. This matches the rules for name matching applied | 1313 // candidate set is invalid. This matches the rules for name matching applied |
| 1331 // server-side by Google Payments and ensures that we don't send upload | 1314 // server-side by Google Payments and ensures that we don't send upload |
| 1332 // requests that are guaranteed to fail. | 1315 // requests that are guaranteed to fail. |
| 1333 base::string16 verified_name; | 1316 base::string16 verified_name; |
| 1334 base::string16 card_name = | 1317 const base::string16 card_name = |
| 1335 card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); | 1318 card.GetInfo(AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); |
| 1336 if (!card_name.empty()) { | 1319 if (!card_name.empty()) { |
| 1337 verified_name = RemoveMiddleInitial(card_name); | 1320 verified_name = RemoveMiddleInitial(card_name); |
| 1338 } | 1321 } |
| 1339 for (const AutofillProfile& profile : candidate_profiles) { | 1322 for (const AutofillProfile& profile : candidate_profiles) { |
| 1340 base::string16 address_name = | 1323 const base::string16 address_name = |
| 1341 profile.GetInfo(AutofillType(NAME_FULL), app_locale_); | 1324 profile.GetInfo(AutofillType(NAME_FULL), app_locale_); |
| 1342 if (!address_name.empty()) { | 1325 if (!address_name.empty()) { |
| 1343 if (verified_name.empty()) { | 1326 if (verified_name.empty()) { |
| 1344 verified_name = RemoveMiddleInitial(address_name); | 1327 verified_name = RemoveMiddleInitial(address_name); |
| 1345 } else { | 1328 } else { |
| 1346 // TODO(crbug.com/590307): We only use ASCII case insensitivity here | 1329 // TODO(crbug.com/590307): We'll need to make the name comparison more |
| 1347 // because the feature is launching US-only and middle initials only | 1330 // sophisticated. |
| 1348 // make sense for Western-style names anyway. As we launch in more | |
| 1349 // countries, we'll need to make the name comparison more sophisticated. | |
| 1350 if (!base::EqualsCaseInsensitiveASCII( | 1331 if (!base::EqualsCaseInsensitiveASCII( |
| 1351 verified_name, RemoveMiddleInitial(address_name))) { | 1332 verified_name, RemoveMiddleInitial(address_name))) { |
| 1352 *address_upload_decision_metric = | 1333 if (!upload_decision_metrics) |
| 1334 *rappor_metric_name = |
| 1335 "Autofill.CardUploadNotOfferedConflictingNames"; |
| 1336 upload_decision_metrics |= |
| 1353 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES; | 1337 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES; |
| 1354 *rappor_metric_name = "Autofill.CardUploadNotOfferedConflictingNames"; | 1338 break; |
| 1355 return false; | |
| 1356 } | 1339 } |
| 1357 } | 1340 } |
| 1358 } | 1341 } |
| 1359 } | 1342 } |
| 1360 // If neither the card nor any of the addresses have a name associated with | 1343 // If neither the card nor any of the addresses have a name associated with |
| 1361 // them, the candidate set is invalid. | 1344 // them, the candidate set is invalid. |
| 1362 if (verified_name.empty()) { | 1345 if (verified_name.empty()) { |
| 1363 *address_upload_decision_metric = | 1346 if (!upload_decision_metrics) |
| 1364 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME; | 1347 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoName"; |
| 1365 *rappor_metric_name = "Autofill.CardUploadNotOfferedNoName"; | 1348 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME; |
| 1366 return false; | |
| 1367 } | 1349 } |
| 1368 | 1350 |
| 1369 // If any of the candidate addresses have a non-empty zip that doesn't match | 1351 // If any of the candidate addresses have a non-empty zip that doesn't match |
| 1370 // any other non-empty zip, then the candidate set is invalid. | 1352 // any other non-empty zip, then the candidate set is invalid. |
| 1371 base::string16 verified_zip; | 1353 base::string16 verified_zip; |
| 1372 for (const AutofillProfile& profile : candidate_profiles) { | 1354 for (const AutofillProfile& profile : candidate_profiles) { |
| 1373 // TODO(jdonnelly): Use GetInfo instead of GetRawInfo once zip codes are | 1355 // TODO(jdonnelly): Use GetInfo instead of GetRawInfo once zip codes are |
| 1374 // canonicalized. See http://crbug.com/587465. | 1356 // canonicalized. See http://crbug.com/587465. |
| 1375 base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP); | 1357 const base::string16 zip = profile.GetRawInfo(ADDRESS_HOME_ZIP); |
| 1376 if (!zip.empty()) { | 1358 if (!zip.empty()) { |
| 1377 if (verified_zip.empty()) { | 1359 if (verified_zip.empty()) { |
| 1378 verified_zip = zip; | 1360 verified_zip = zip; |
| 1379 } else { | 1361 } else { |
| 1380 // To compare two zips, we check to see if either is a prefix of the | 1362 // To compare two zips, we check to see if either is a prefix of the |
| 1381 // other. This allows us to consider a 5-digit zip and a zip+4 to be a | 1363 // other. This allows us to consider a 5-digit zip and a zip+4 to be a |
| 1382 // match if the first 5 digits are the same without hardcoding any | 1364 // match if the first 5 digits are the same without hardcoding any |
| 1383 // specifics of how postal codes are represented. (They can be numeric | 1365 // specifics of how postal codes are represented. (They can be numeric |
| 1384 // or alphanumeric and vary from 3 to 10 digits long by country. See | 1366 // or alphanumeric and vary from 3 to 10 digits long by country. See |
| 1385 // https://en.wikipedia.org/wiki/Postal_code#Presentation.) The Payments | 1367 // https://en.wikipedia.org/wiki/Postal_code#Presentation.) The Payments |
| 1386 // backend will apply a more sophisticated address-matching procedure. | 1368 // backend will apply a more sophisticated address-matching procedure. |
| 1387 // This check is simply meant to avoid offering upload in cases that are | 1369 // This check is simply meant to avoid offering upload in cases that are |
| 1388 // likely to fail. | 1370 // likely to fail. |
| 1389 if (!(StartsWith(verified_zip, zip, base::CompareCase::SENSITIVE) || | 1371 if (!(StartsWith(verified_zip, zip, base::CompareCase::SENSITIVE) || |
| 1390 StartsWith(zip, verified_zip, base::CompareCase::SENSITIVE))) { | 1372 StartsWith(zip, verified_zip, base::CompareCase::SENSITIVE))) { |
| 1391 *address_upload_decision_metric = | 1373 upload_decision_metrics |= |
| 1392 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS; | 1374 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS; |
| 1393 return false; | 1375 break; |
| 1394 } | 1376 } |
| 1395 } | 1377 } |
| 1396 } | 1378 } |
| 1397 } | 1379 } |
| 1398 | 1380 |
| 1399 // If none of the candidate addresses have a zip, the candidate set is | 1381 // If none of the candidate addresses have a zip, the candidate set is |
| 1400 // invalid. | 1382 // invalid. |
| 1401 if (verified_zip.empty()) { | 1383 if (verified_zip.empty()) |
| 1402 *address_upload_decision_metric = | 1384 upload_decision_metrics |= AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; |
| 1403 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE; | |
| 1404 return false; | |
| 1405 } | |
| 1406 | 1385 |
| 1407 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); | 1386 if (!upload_decision_metrics) |
| 1408 return true; | 1387 profiles->assign(candidate_profiles.begin(), candidate_profiles.end()); |
| 1388 |
| 1389 return upload_decision_metrics; |
| 1409 } | 1390 } |
| 1410 | 1391 |
| 1411 void AutofillManager::CollectRapportSample(const GURL& source_url, | 1392 void AutofillManager::CollectRapporSample( |
| 1412 const std::string& metric_name) | 1393 const GURL& source_url, |
| 1413 const { | 1394 const std::string& metric_name) const { |
| 1414 if (source_url.is_valid() && client_->GetRapporServiceImpl()) { | 1395 if (source_url.is_valid() && client_->GetRapporServiceImpl()) { |
| 1415 rappor::SampleDomainAndRegistryFromGURL(client_->GetRapporServiceImpl(), | 1396 rappor::SampleDomainAndRegistryFromGURL(client_->GetRapporServiceImpl(), |
| 1416 metric_name, source_url); | 1397 metric_name, source_url); |
| 1417 } | 1398 } |
| 1418 } | 1399 } |
| 1419 | 1400 |
| 1420 // Note that |submitted_form| is passed as a pointer rather than as a reference | 1401 // Note that |submitted_form| is passed as a pointer rather than as a reference |
| 1421 // so that we can get memory management right across threads. Note also that we | 1402 // so that we can get memory management right across threads. Note also that we |
| 1422 // explicitly pass in all the time stamps of interest, as the cached ones might | 1403 // explicitly pass in all the time stamps of interest, as the cached ones might |
| 1423 // get reset before this method executes. | 1404 // get reset before this method executes. |
| (...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2255 } | 2236 } |
| 2256 if (i > 0) | 2237 if (i > 0) |
| 2257 fputs("Next oldest form:\n", file); | 2238 fputs("Next oldest form:\n", file); |
| 2258 } | 2239 } |
| 2259 fputs("\n", file); | 2240 fputs("\n", file); |
| 2260 | 2241 |
| 2261 fclose(file); | 2242 fclose(file); |
| 2262 } | 2243 } |
| 2263 #endif // ENABLE_FORM_DEBUG_DUMP | 2244 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2264 | 2245 |
| 2265 void AutofillManager::LogCardUploadDecisionUkm( | 2246 void AutofillManager::LogCardUploadDecisions(int upload_decision_metrics) { |
| 2266 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | 2247 AutofillMetrics::LogCardUploadDecisionMetrics(upload_decision_metrics); |
| 2267 AutofillMetrics::LogCardUploadDecisionUkm( | 2248 AutofillMetrics::LogCardUploadDecisionsUkm(client_->GetUkmService(), |
| 2268 client_->GetUkmService(), pending_upload_request_url_, upload_decision); | 2249 pending_upload_request_url_, |
| 2250 upload_decision_metrics); |
| 2269 } | 2251 } |
| 2270 | 2252 |
| 2271 } // namespace autofill | 2253 } // namespace autofill |
| OLD | NEW |