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

Unified Diff: components/autofill/core/browser/autofill_manager.cc

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: Updates unit tests. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/autofill_manager.cc
diff --git a/components/autofill/core/browser/autofill_manager.cc b/components/autofill/core/browser/autofill_manager.cc
index d599bce07603f84b97bd881bbe88c249078ea123..ba3f2de89d3d2c1e4385ce9bd71d15b1098b0975 100644
--- a/components/autofill/core/browser/autofill_manager.cc
+++ b/components/autofill/core/browser/autofill_manager.cc
@@ -217,16 +217,23 @@ AutofillManager::AutofillManager(
AutofillDownloadManagerState enable_download_manager)
: driver_(driver),
client_(client),
- payments_client_(
- new payments::PaymentsClient(driver->GetURLRequestContext(), this)),
+ payments_client_(base::MakeUnique<payments::PaymentsClient>(
+ driver->GetURLRequestContext(),
+ this)),
app_locale_(app_locale),
personal_data_(client->GetPersonalDataManager()),
autocomplete_history_manager_(
- new AutocompleteHistoryManager(driver, client)),
+ base::MakeUnique<AutocompleteHistoryManager>(driver, client)),
+ ukm_logger_(base::MakeUnique<AutofillMetrics::UkmLogger>(
+ client->GetUkmService())),
address_form_event_logger_(
- new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)),
+ base::MakeUnique<AutofillMetrics::FormEventLogger>(
+ false /* is_for_credit_card */,
+ ukm_logger_.get())),
credit_card_form_event_logger_(
- new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)),
+ base::MakeUnique<AutofillMetrics::FormEventLogger>(
+ true /* is_for_credit_card */,
+ ukm_logger_.get())),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
@@ -515,6 +522,7 @@ void AutofillManager::OnTextFieldDidChange(const FormData& form,
if (!user_did_type_) {
user_did_type_ = true;
AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
+ ukm_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
}
if (autofill_field->is_autofilled) {
@@ -522,6 +530,8 @@ void AutofillManager::OnTextFieldDidChange(const FormData& form,
autofill_field->set_previously_autofilled(true);
AutofillMetrics::LogUserHappinessMetric(
AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
+ ukm_logger_->LogUserHappinessMetric(
+ AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
if (!user_did_edit_autofilled_field_) {
user_did_edit_autofilled_field_ = true;
@@ -813,6 +823,7 @@ void AutofillManager::OnDidFillAutofillFormData(const FormData& form,
UpdatePendingForm(form);
AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
+ ukm_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
if (!user_did_autofill_) {
user_did_autofill_ = true;
AutofillMetrics::LogUserHappinessMetric(
@@ -1088,6 +1099,7 @@ void AutofillManager::ShowUnmaskPrompt(
AutofillClient::UnmaskCardReason reason,
base::WeakPtr<CardUnmaskDelegate> delegate) {
client_->ShowUnmaskPrompt(card, reason, delegate);
+ ukm_logger_->LogUnmaskPromptEvent(AutofillMetrics::UNMASK_PROMPT_SHOWN);
}
void AutofillManager::OnUnmaskVerificationResult(
@@ -1378,10 +1390,16 @@ void AutofillManager::UploadFormDataAsyncCallback(
const TimeTicks& interaction_time,
const TimeTicks& submission_time,
bool observed_submission) {
- submitted_form->LogQualityMetrics(load_time, interaction_time,
- submission_time,
- client_->GetRapporServiceImpl(),
- did_show_suggestions_, observed_submission);
+ AutofillMetrics::AutofillFormSubmittedState state =
+ submitted_form->LogQualityMetrics(
+ load_time, interaction_time, submission_time,
+ client_->GetRapporServiceImpl(), did_show_suggestions_,
+ observed_submission);
+ if (state < AutofillMetrics::AUTOFILL_FORM_SUBMITTED_STATE_ENUM_SIZE) {
sebsg 2017/04/10 19:20:19 Do we expect that this is ever bigger than max? If
csashi 2017/04/10 20:15:57 Done.
+ if (ukm_logger_->url() != submitted_form->source_url())
+ ukm_logger_->set_url(submitted_form->source_url());
+ AutofillMetrics::LogAutofillFormSubmittedState(state, ukm_logger_.get());
+ }
if (submitted_form->ShouldBeCrowdsourced())
UploadFormData(*submitted_form, observed_submission);
@@ -1416,10 +1434,11 @@ void AutofillManager::Reset() {
ProcessPendingFormForUpload();
DCHECK(!pending_form_data_);
form_structures_.clear();
- address_form_event_logger_.reset(
- new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */));
- credit_card_form_event_logger_.reset(
- new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */));
+ ukm_logger_.reset(new AutofillMetrics::UkmLogger(client_->GetUkmService()));
+ address_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
+ false /* is_for_credit_card */, ukm_logger_.get()));
+ credit_card_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
+ true /* is_for_credit_card */, ukm_logger_.get()));
#if defined(OS_ANDROID) || defined(OS_IOS)
autofill_assistant_.Reset();
#endif
@@ -1443,16 +1462,23 @@ AutofillManager::AutofillManager(AutofillDriver* driver,
PersonalDataManager* personal_data)
: driver_(driver),
client_(client),
- payments_client_(
- new payments::PaymentsClient(driver->GetURLRequestContext(), this)),
+ payments_client_(base::MakeUnique<payments::PaymentsClient>(
+ driver->GetURLRequestContext(),
+ this)),
app_locale_("en-US"),
personal_data_(personal_data),
autocomplete_history_manager_(
- new AutocompleteHistoryManager(driver, client)),
+ base::MakeUnique<AutocompleteHistoryManager>(driver, client)),
+ ukm_logger_(base::MakeUnique<AutofillMetrics::UkmLogger>(
+ client->GetUkmService())),
address_form_event_logger_(
- new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)),
+ base::MakeUnique<AutofillMetrics::FormEventLogger>(
+ false /* is_for_credit_card */,
+ ukm_logger_.get())),
credit_card_form_event_logger_(
- new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)),
+ base::MakeUnique<AutofillMetrics::FormEventLogger>(
+ true /* is_for_credit_card */,
+ ukm_logger_.get())),
has_logged_autofill_enabled_(false),
has_logged_address_suggestions_count_(false),
did_show_suggestions_(false),
@@ -1679,7 +1705,8 @@ void AutofillManager::FillOrPreviewDataModelForm(
std::unique_ptr<FormStructure> AutofillManager::ValidateSubmittedForm(
const FormData& form) {
- std::unique_ptr<FormStructure> submitted_form(new FormStructure(form));
+ std::unique_ptr<FormStructure> submitted_form(
+ base::MakeUnique<FormStructure>(form));
if (!ShouldUploadForm(*submitted_form))
return std::unique_ptr<FormStructure>();
@@ -1880,6 +1907,14 @@ void AutofillManager::ParseForms(const std::vector<FormData>& forms) {
if (!queryable_forms.empty() || !non_queryable_forms.empty()) {
AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
+
+ // Log pending events, if any.
+ ukm_logger_->LogUkm();
+
+ // If user submits a form later, we set the key to the |submitted_form|'s
sebsg 2017/04/10 19:20:19 I would reformulate to something like, setup the u
csashi 2017/04/10 20:15:57 Done.
+ // |source_url()|.
+ ukm_logger_->set_url(forms[0].origin);
+ ukm_logger_->LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
#if defined(OS_IOS)
// Log this from same location as AutofillMetrics::FORMS_LOADED to ensure
// that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be

Powered by Google App Engine
This is Rietveld 408576698