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 24 matching lines...) Expand all Loading... | |
| 35 #include "components/autofill/core/browser/autocomplete_history_manager.h" | 35 #include "components/autofill/core/browser/autocomplete_history_manager.h" |
| 36 #include "components/autofill/core/browser/autofill_client.h" | 36 #include "components/autofill/core/browser/autofill_client.h" |
| 37 #include "components/autofill/core/browser/autofill_data_model.h" | 37 #include "components/autofill/core/browser/autofill_data_model.h" |
| 38 #include "components/autofill/core/browser/autofill_experiments.h" | 38 #include "components/autofill/core/browser/autofill_experiments.h" |
| 39 #include "components/autofill/core/browser/autofill_external_delegate.h" | 39 #include "components/autofill/core/browser/autofill_external_delegate.h" |
| 40 #include "components/autofill/core/browser/autofill_field.h" | 40 #include "components/autofill/core/browser/autofill_field.h" |
| 41 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" | 41 #include "components/autofill/core/browser/autofill_manager_test_delegate.h" |
| 42 #include "components/autofill/core/browser/autofill_metrics.h" | 42 #include "components/autofill/core/browser/autofill_metrics.h" |
| 43 #include "components/autofill/core/browser/autofill_profile.h" | 43 #include "components/autofill/core/browser/autofill_profile.h" |
| 44 #include "components/autofill/core/browser/autofill_type.h" | 44 #include "components/autofill/core/browser/autofill_type.h" |
| 45 #include "components/autofill/core/browser/autofill_ukm.h" | |
| 45 #include "components/autofill/core/browser/country_names.h" | 46 #include "components/autofill/core/browser/country_names.h" |
| 46 #include "components/autofill/core/browser/credit_card.h" | 47 #include "components/autofill/core/browser/credit_card.h" |
| 47 #include "components/autofill/core/browser/field_types.h" | 48 #include "components/autofill/core/browser/field_types.h" |
| 48 #include "components/autofill/core/browser/form_structure.h" | 49 #include "components/autofill/core/browser/form_structure.h" |
| 49 #include "components/autofill/core/browser/personal_data_manager.h" | 50 #include "components/autofill/core/browser/personal_data_manager.h" |
| 50 #include "components/autofill/core/browser/phone_number.h" | 51 #include "components/autofill/core/browser/phone_number.h" |
| 51 #include "components/autofill/core/browser/phone_number_i18n.h" | 52 #include "components/autofill/core/browser/phone_number_i18n.h" |
| 52 #include "components/autofill/core/browser/popup_item_ids.h" | 53 #include "components/autofill/core/browser/popup_item_ids.h" |
| 53 #include "components/autofill/core/browser/validation.h" | 54 #include "components/autofill/core/browser/validation.h" |
| 54 #include "components/autofill/core/common/autofill_clock.h" | 55 #include "components/autofill/core/common/autofill_clock.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 cc_field_http_warning_suggestion.label = | 200 cc_field_http_warning_suggestion.label = |
| 200 l10n_util::GetStringUTF16(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE); | 201 l10n_util::GetStringUTF16(IDS_AUTOFILL_HTTP_WARNING_LEARN_MORE); |
| 201 cc_field_http_warning_suggestion.icon = | 202 cc_field_http_warning_suggestion.icon = |
| 202 (source_url.is_valid() && source_url.SchemeIs("http")) | 203 (source_url.is_valid() && source_url.SchemeIs("http")) |
| 203 ? base::ASCIIToUTF16("httpWarning") | 204 ? base::ASCIIToUTF16("httpWarning") |
| 204 : base::ASCIIToUTF16("httpsInvalid"); | 205 : base::ASCIIToUTF16("httpsInvalid"); |
| 205 | 206 |
| 206 return cc_field_http_warning_suggestion; | 207 return cc_field_http_warning_suggestion; |
| 207 } | 208 } |
| 208 | 209 |
| 210 // Logs the card upload decision ukm based on the specified |url| and | |
| 211 // |upload_decision|. Returns whether the metric was logged sucessfully. | |
| 212 bool LogCardUploadDecisionMetricUkm( | |
| 213 ukm::UkmService* ukm_service, | |
| 214 const GURL& url, | |
| 215 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
| 216 if (upload_decision >= AutofillMetrics::NUM_CARD_UPLOAD_DECISION_METRICS) | |
|
Mathieu
2017/03/09 18:40:49
DCHECK(ukm_service);
sebsg
2017/03/09 19:57:04
As discussed offline, will not add this.
| |
| 217 return false; | |
| 218 | |
| 219 std::map<std::string, int> metrics; | |
|
Mathieu
2017/03/09 18:40:49
is there a fancy initialization like:
const std::
sebsg
2017/03/09 19:57:04
Done.
| |
| 220 metrics.insert( | |
| 221 std::make_pair("UploadDecision", static_cast<int>(upload_decision))); | |
| 222 return AutofillUkm::LogUkm(ukm_service, url, "Autofill.CardUploadDecision", | |
| 223 metrics); | |
| 224 } | |
| 225 | |
| 209 } // namespace | 226 } // namespace |
| 210 | 227 |
| 211 AutofillManager::AutofillManager( | 228 AutofillManager::AutofillManager( |
| 212 AutofillDriver* driver, | 229 AutofillDriver* driver, |
| 213 AutofillClient* client, | 230 AutofillClient* client, |
| 214 const std::string& app_locale, | 231 const std::string& app_locale, |
| 215 AutofillDownloadManagerState enable_download_manager) | 232 AutofillDownloadManagerState enable_download_manager) |
| 216 : driver_(driver), | 233 : driver_(driver), |
| 217 client_(client), | 234 client_(client), |
| 218 payments_client_( | 235 payments_client_( |
| (...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1032 upload_request_.context_token = context_token; | 1049 upload_request_.context_token = context_token; |
| 1033 user_did_accept_upload_prompt_ = false; | 1050 user_did_accept_upload_prompt_ = false; |
| 1034 client_->ConfirmSaveCreditCardToCloud( | 1051 client_->ConfirmSaveCreditCardToCloud( |
| 1035 upload_request_.card, std::move(legal_message), | 1052 upload_request_.card, std::move(legal_message), |
| 1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, | 1053 base::Bind(&AutofillManager::OnUserDidAcceptUpload, |
| 1037 weak_ptr_factory_.GetWeakPtr())); | 1054 weak_ptr_factory_.GetWeakPtr())); |
| 1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, | 1055 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, |
| 1039 weak_ptr_factory_.GetWeakPtr())); | 1056 weak_ptr_factory_.GetWeakPtr())); |
| 1040 AutofillMetrics::LogCardUploadDecisionMetric( | 1057 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1041 AutofillMetrics::UPLOAD_OFFERED); | 1058 AutofillMetrics::UPLOAD_OFFERED); |
| 1059 LogCardUploadDecisionMetricUkm(client_->GetUkmService(), | |
| 1060 pending_upload_request_url_, | |
| 1061 AutofillMetrics::UPLOAD_OFFERED); | |
| 1042 } else { | 1062 } else { |
| 1043 // If the upload details request failed, fall back to a local save. The | 1063 // If the upload details request failed, fall back to a local save. The |
| 1044 // reasoning here is as follows: | 1064 // reasoning here is as follows: |
| 1045 // - This will sometimes fail intermittently, in which case it might be | 1065 // - This will sometimes fail intermittently, in which case it might be |
| 1046 // better to not fall back, because sometimes offering upload and sometimes | 1066 // better to not fall back, because sometimes offering upload and sometimes |
| 1047 // offering local save is a poor user experience. | 1067 // offering local save is a poor user experience. |
| 1048 // - However, in some cases, our local configuration limiting the feature to | 1068 // - However, in some cases, our local configuration limiting the feature to |
| 1049 // countries that Payments is known to support will not match Payments' own | 1069 // countries that Payments is known to support will not match Payments' own |
| 1050 // determination of what country the user is located in. In these cases, | 1070 // determination of what country the user is located in. In these cases, |
| 1051 // the upload details request will consistently fail and if we don't fall | 1071 // the upload details request will consistently fail and if we don't fall |
| 1052 // back to a local save then the user will never be offered any kind of | 1072 // back to a local save then the user will never be offered any kind of |
| 1053 // credit card save. | 1073 // credit card save. |
| 1054 client_->ConfirmSaveCreditCardLocally( | 1074 client_->ConfirmSaveCreditCardLocally( |
| 1055 upload_request_.card, | 1075 upload_request_.card, |
| 1056 base::Bind( | 1076 base::Bind( |
| 1057 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), | 1077 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), |
| 1058 base::Unretained(personal_data_), upload_request_.card)); | 1078 base::Unretained(personal_data_), upload_request_.card)); |
| 1059 AutofillMetrics::LogCardUploadDecisionMetric( | 1079 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1060 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 1080 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 1081 LogCardUploadDecisionMetricUkm( | |
| 1082 client_->GetUkmService(), pending_upload_request_url_, | |
| 1083 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | |
| 1061 } | 1084 } |
| 1085 pending_upload_request_url_ = GURL(); | |
| 1062 } | 1086 } |
| 1063 | 1087 |
| 1064 void AutofillManager::OnDidUploadCard( | 1088 void AutofillManager::OnDidUploadCard( |
| 1065 AutofillClient::PaymentsRpcResult result) { | 1089 AutofillClient::PaymentsRpcResult result) { |
| 1066 // We don't do anything user-visible if the upload attempt fails. | 1090 // We don't do anything user-visible if the upload attempt fails. |
| 1067 // TODO(jdonnelly): Log duration. | 1091 // TODO(jdonnelly): Log duration. |
| 1068 } | 1092 } |
| 1069 | 1093 |
| 1070 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, | 1094 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, |
| 1071 const base::string16& cvc) { | 1095 const base::string16& cvc) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1211 // client-side validation rules. | 1235 // client-side validation rules. |
| 1212 autofill::AutofillMetrics::CardUploadDecisionMetric | 1236 autofill::AutofillMetrics::CardUploadDecisionMetric |
| 1213 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; | 1237 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; |
| 1214 std::string rappor_metric_name; | 1238 std::string rappor_metric_name; |
| 1215 bool get_profiles_succeeded = | 1239 bool get_profiles_succeeded = |
| 1216 GetProfilesForCreditCardUpload(*imported_credit_card, | 1240 GetProfilesForCreditCardUpload(*imported_credit_card, |
| 1217 &upload_request_.profiles, | 1241 &upload_request_.profiles, |
| 1218 &get_profiles_decision_metric, | 1242 &get_profiles_decision_metric, |
| 1219 &rappor_metric_name); | 1243 &rappor_metric_name); |
| 1220 | 1244 |
| 1245 pending_upload_request_url_ = GURL(submitted_form.source_url()); | |
| 1246 | |
| 1221 // Both the CVC and address checks are done. Conform to the legacy order of | 1247 // Both the CVC and address checks are done. Conform to the legacy order of |
| 1222 // reporting on CVC then address. | 1248 // reporting on CVC then address. |
| 1223 if (upload_request_.cvc.empty()) { | 1249 if (upload_request_.cvc.empty()) { |
| 1224 AutofillMetrics::LogCardUploadDecisionMetric( | 1250 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1225 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 1251 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 1252 LogCardUploadDecisionMetricUkm( | |
| 1253 client_->GetUkmService(), pending_upload_request_url_, | |
| 1254 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | |
| 1255 pending_upload_request_url_ = GURL(); | |
| 1226 CollectRapportSample(submitted_form.source_url(), | 1256 CollectRapportSample(submitted_form.source_url(), |
| 1227 "Autofill.CardUploadNotOfferedNoCvc"); | 1257 "Autofill.CardUploadNotOfferedNoCvc"); |
| 1228 return; | 1258 return; |
| 1229 } | 1259 } |
| 1230 if (!get_profiles_succeeded) { | 1260 if (!get_profiles_succeeded) { |
| 1231 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); | 1261 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); |
| 1232 AutofillMetrics::LogCardUploadDecisionMetric( | 1262 AutofillMetrics::LogCardUploadDecisionMetric( |
| 1233 get_profiles_decision_metric); | 1263 get_profiles_decision_metric); |
| 1264 LogCardUploadDecisionMetricUkm(client_->GetUkmService(), | |
| 1265 pending_upload_request_url_, | |
| 1266 get_profiles_decision_metric); | |
| 1267 pending_upload_request_url_ = GURL(); | |
| 1234 if (!rappor_metric_name.empty()) { | 1268 if (!rappor_metric_name.empty()) { |
| 1235 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); | 1269 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); |
| 1236 } | 1270 } |
| 1237 return; | 1271 return; |
| 1238 } | 1272 } |
| 1239 | 1273 |
| 1240 // All required data is available, start the upload process. | 1274 // All required data is available, start the upload process. |
| 1241 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); | 1275 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); |
| 1242 } | 1276 } |
| 1243 } | 1277 } |
| (...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2191 if (i > 0) | 2225 if (i > 0) |
| 2192 fputs("Next oldest form:\n", file); | 2226 fputs("Next oldest form:\n", file); |
| 2193 } | 2227 } |
| 2194 fputs("\n", file); | 2228 fputs("\n", file); |
| 2195 | 2229 |
| 2196 fclose(file); | 2230 fclose(file); |
| 2197 } | 2231 } |
| 2198 #endif // ENABLE_FORM_DEBUG_DUMP | 2232 #endif // ENABLE_FORM_DEBUG_DUMP |
| 2199 | 2233 |
| 2200 } // namespace autofill | 2234 } // namespace autofill |
| OLD | NEW |