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

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

Issue 2740633002: [Autofill] Add upstreaming UKM (Closed)
Patch Set: Fix for Android and iOS Created 3 years, 9 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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 upload_request_.context_token = context_token; 1032 upload_request_.context_token = context_token;
1033 user_did_accept_upload_prompt_ = false; 1033 user_did_accept_upload_prompt_ = false;
1034 client_->ConfirmSaveCreditCardToCloud( 1034 client_->ConfirmSaveCreditCardToCloud(
1035 upload_request_.card, std::move(legal_message), 1035 upload_request_.card, std::move(legal_message),
1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload, 1036 base::Bind(&AutofillManager::OnUserDidAcceptUpload,
1037 weak_ptr_factory_.GetWeakPtr())); 1037 weak_ptr_factory_.GetWeakPtr()));
1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, 1038 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData,
1039 weak_ptr_factory_.GetWeakPtr())); 1039 weak_ptr_factory_.GetWeakPtr()));
1040 AutofillMetrics::LogCardUploadDecisionMetric( 1040 AutofillMetrics::LogCardUploadDecisionMetric(
1041 AutofillMetrics::UPLOAD_OFFERED); 1041 AutofillMetrics::UPLOAD_OFFERED);
1042 AutofillMetrics::LogCardUploadDecisionMetricUkm(
rkaplow 2017/03/10 19:00:27 small optional comment - since the structure of A
sebsg 2017/03/10 19:25:33 Done.
1043 client_->GetUkmService(), pending_upload_request_url_,
1044 AutofillMetrics::UPLOAD_OFFERED);
1042 } else { 1045 } else {
1043 // If the upload details request failed, fall back to a local save. The 1046 // If the upload details request failed, fall back to a local save. The
1044 // reasoning here is as follows: 1047 // reasoning here is as follows:
1045 // - This will sometimes fail intermittently, in which case it might be 1048 // - This will sometimes fail intermittently, in which case it might be
1046 // better to not fall back, because sometimes offering upload and sometimes 1049 // better to not fall back, because sometimes offering upload and sometimes
1047 // offering local save is a poor user experience. 1050 // offering local save is a poor user experience.
1048 // - However, in some cases, our local configuration limiting the feature to 1051 // - However, in some cases, our local configuration limiting the feature to
1049 // countries that Payments is known to support will not match Payments' own 1052 // 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, 1053 // 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 1054 // 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 1055 // back to a local save then the user will never be offered any kind of
1053 // credit card save. 1056 // credit card save.
1054 client_->ConfirmSaveCreditCardLocally( 1057 client_->ConfirmSaveCreditCardLocally(
1055 upload_request_.card, 1058 upload_request_.card,
1056 base::Bind( 1059 base::Bind(
1057 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 1060 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
1058 base::Unretained(personal_data_), upload_request_.card)); 1061 base::Unretained(personal_data_), upload_request_.card));
1059 AutofillMetrics::LogCardUploadDecisionMetric( 1062 AutofillMetrics::LogCardUploadDecisionMetric(
1060 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); 1063 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
1064 AutofillMetrics::LogCardUploadDecisionMetricUkm(
1065 client_->GetUkmService(), pending_upload_request_url_,
1066 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
1061 } 1067 }
1068 pending_upload_request_url_ = GURL();
1062 } 1069 }
1063 1070
1064 void AutofillManager::OnDidUploadCard( 1071 void AutofillManager::OnDidUploadCard(
1065 AutofillClient::PaymentsRpcResult result) { 1072 AutofillClient::PaymentsRpcResult result) {
1066 // We don't do anything user-visible if the upload attempt fails. 1073 // We don't do anything user-visible if the upload attempt fails.
1067 // TODO(jdonnelly): Log duration. 1074 // TODO(jdonnelly): Log duration.
1068 } 1075 }
1069 1076
1070 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card, 1077 void AutofillManager::OnFullCardRequestSucceeded(const CreditCard& card,
1071 const base::string16& cvc) { 1078 const base::string16& cvc) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 // client-side validation rules. 1218 // client-side validation rules.
1212 autofill::AutofillMetrics::CardUploadDecisionMetric 1219 autofill::AutofillMetrics::CardUploadDecisionMetric
1213 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED; 1220 get_profiles_decision_metric = AutofillMetrics::UPLOAD_OFFERED;
1214 std::string rappor_metric_name; 1221 std::string rappor_metric_name;
1215 bool get_profiles_succeeded = 1222 bool get_profiles_succeeded =
1216 GetProfilesForCreditCardUpload(*imported_credit_card, 1223 GetProfilesForCreditCardUpload(*imported_credit_card,
1217 &upload_request_.profiles, 1224 &upload_request_.profiles,
1218 &get_profiles_decision_metric, 1225 &get_profiles_decision_metric,
1219 &rappor_metric_name); 1226 &rappor_metric_name);
1220 1227
1228 pending_upload_request_url_ = GURL(submitted_form.source_url());
1229
1221 // Both the CVC and address checks are done. Conform to the legacy order of 1230 // Both the CVC and address checks are done. Conform to the legacy order of
1222 // reporting on CVC then address. 1231 // reporting on CVC then address.
1223 if (upload_request_.cvc.empty()) { 1232 if (upload_request_.cvc.empty()) {
1224 AutofillMetrics::LogCardUploadDecisionMetric( 1233 AutofillMetrics::LogCardUploadDecisionMetric(
1225 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); 1234 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
1235 AutofillMetrics::LogCardUploadDecisionMetricUkm(
1236 client_->GetUkmService(), pending_upload_request_url_,
1237 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
1238 pending_upload_request_url_ = GURL();
1226 CollectRapportSample(submitted_form.source_url(), 1239 CollectRapportSample(submitted_form.source_url(),
1227 "Autofill.CardUploadNotOfferedNoCvc"); 1240 "Autofill.CardUploadNotOfferedNoCvc");
1228 return; 1241 return;
1229 } 1242 }
1230 if (!get_profiles_succeeded) { 1243 if (!get_profiles_succeeded) {
1231 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED); 1244 DCHECK(get_profiles_decision_metric != AutofillMetrics::UPLOAD_OFFERED);
1232 AutofillMetrics::LogCardUploadDecisionMetric( 1245 AutofillMetrics::LogCardUploadDecisionMetric(
1233 get_profiles_decision_metric); 1246 get_profiles_decision_metric);
1247 AutofillMetrics::LogCardUploadDecisionMetricUkm(
1248 client_->GetUkmService(), pending_upload_request_url_,
1249 get_profiles_decision_metric);
1250 pending_upload_request_url_ = GURL();
1234 if (!rappor_metric_name.empty()) { 1251 if (!rappor_metric_name.empty()) {
1235 CollectRapportSample(submitted_form.source_url(), rappor_metric_name); 1252 CollectRapportSample(submitted_form.source_url(), rappor_metric_name);
1236 } 1253 }
1237 return; 1254 return;
1238 } 1255 }
1239 1256
1240 // All required data is available, start the upload process. 1257 // All required data is available, start the upload process.
1241 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_); 1258 payments_client_->GetUploadDetails(upload_request_.profiles, app_locale_);
1242 } 1259 }
1243 } 1260 }
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 if (i > 0) 2208 if (i > 0)
2192 fputs("Next oldest form:\n", file); 2209 fputs("Next oldest form:\n", file);
2193 } 2210 }
2194 fputs("\n", file); 2211 fputs("\n", file);
2195 2212
2196 fclose(file); 2213 fclose(file);
2197 } 2214 }
2198 #endif // ENABLE_FORM_DEBUG_DUMP 2215 #endif // ENABLE_FORM_DEBUG_DUMP
2199 2216
2200 } // namespace autofill 2217 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698