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

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

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: Renames UkmLogger->FormInteractionsUkmLogger, LogUkm->SubmitUkm. 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 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 } // namespace 211 } // namespace
212 212
213 AutofillManager::AutofillManager( 213 AutofillManager::AutofillManager(
214 AutofillDriver* driver, 214 AutofillDriver* driver,
215 AutofillClient* client, 215 AutofillClient* client,
216 const std::string& app_locale, 216 const std::string& app_locale,
217 AutofillDownloadManagerState enable_download_manager) 217 AutofillDownloadManagerState enable_download_manager)
218 : driver_(driver), 218 : driver_(driver),
219 client_(client), 219 client_(client),
220 payments_client_( 220 payments_client_(base::MakeUnique<payments::PaymentsClient>(
221 new payments::PaymentsClient(driver->GetURLRequestContext(), this)), 221 driver->GetURLRequestContext(),
222 this)),
222 app_locale_(app_locale), 223 app_locale_(app_locale),
223 personal_data_(client->GetPersonalDataManager()), 224 personal_data_(client->GetPersonalDataManager()),
224 autocomplete_history_manager_( 225 autocomplete_history_manager_(
225 new AutocompleteHistoryManager(driver, client)), 226 base::MakeUnique<AutocompleteHistoryManager>(driver, client)),
227 form_interactions_ukm_logger_(
228 base::MakeUnique<AutofillMetrics::FormInteractionsUkmLogger>(
229 client->GetUkmService())),
226 address_form_event_logger_( 230 address_form_event_logger_(
227 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), 231 base::MakeUnique<AutofillMetrics::FormEventLogger>(
232 false /* is_for_credit_card */,
233 form_interactions_ukm_logger_.get())),
228 credit_card_form_event_logger_( 234 credit_card_form_event_logger_(
229 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), 235 base::MakeUnique<AutofillMetrics::FormEventLogger>(
236 true /* is_for_credit_card */,
237 form_interactions_ukm_logger_.get())),
230 has_logged_autofill_enabled_(false), 238 has_logged_autofill_enabled_(false),
231 has_logged_address_suggestions_count_(false), 239 has_logged_address_suggestions_count_(false),
232 did_show_suggestions_(false), 240 did_show_suggestions_(false),
233 user_did_type_(false), 241 user_did_type_(false),
234 user_did_autofill_(false), 242 user_did_autofill_(false),
235 user_did_edit_autofilled_field_(false), 243 user_did_edit_autofilled_field_(false),
236 user_did_accept_upload_prompt_(false), 244 user_did_accept_upload_prompt_(false),
237 external_delegate_(NULL), 245 external_delegate_(NULL),
238 test_delegate_(NULL), 246 test_delegate_(NULL),
239 #if defined(OS_ANDROID) || defined(OS_IOS) 247 #if defined(OS_ANDROID) || defined(OS_IOS)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 FormStructure* form_structure = NULL; 516 FormStructure* form_structure = NULL;
509 AutofillField* autofill_field = NULL; 517 AutofillField* autofill_field = NULL;
510 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field)) 518 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field))
511 return; 519 return;
512 520
513 UpdatePendingForm(form); 521 UpdatePendingForm(form);
514 522
515 if (!user_did_type_) { 523 if (!user_did_type_) {
516 user_did_type_ = true; 524 user_did_type_ = true;
517 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE); 525 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
526 form_interactions_ukm_logger_->LogUserHappinessMetric(
527 AutofillMetrics::USER_DID_TYPE);
518 } 528 }
519 529
520 if (autofill_field->is_autofilled) { 530 if (autofill_field->is_autofilled) {
521 autofill_field->is_autofilled = false; 531 autofill_field->is_autofilled = false;
522 autofill_field->set_previously_autofilled(true); 532 autofill_field->set_previously_autofilled(true);
523 AutofillMetrics::LogUserHappinessMetric( 533 AutofillMetrics::LogUserHappinessMetric(
524 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD); 534 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
535 form_interactions_ukm_logger_->LogUserHappinessMetric(
536 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
525 537
526 if (!user_did_edit_autofilled_field_) { 538 if (!user_did_edit_autofilled_field_) {
527 user_did_edit_autofilled_field_ = true; 539 user_did_edit_autofilled_field_ = true;
528 AutofillMetrics::LogUserHappinessMetric( 540 AutofillMetrics::LogUserHappinessMetric(
529 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); 541 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
530 } 542 }
531 } 543 }
532 544
533 UpdateInitialInteractionTimestamp(timestamp); 545 UpdateInitialInteractionTimestamp(timestamp);
534 } 546 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 818 }
807 819
808 void AutofillManager::OnDidFillAutofillFormData(const FormData& form, 820 void AutofillManager::OnDidFillAutofillFormData(const FormData& form,
809 const TimeTicks& timestamp) { 821 const TimeTicks& timestamp) {
810 if (test_delegate_) 822 if (test_delegate_)
811 test_delegate_->DidFillFormData(); 823 test_delegate_->DidFillFormData();
812 824
813 UpdatePendingForm(form); 825 UpdatePendingForm(form);
814 826
815 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); 827 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
828 form_interactions_ukm_logger_->LogUserHappinessMetric(
829 AutofillMetrics::USER_DID_AUTOFILL);
816 if (!user_did_autofill_) { 830 if (!user_did_autofill_) {
817 user_did_autofill_ = true; 831 user_did_autofill_ = true;
818 AutofillMetrics::LogUserHappinessMetric( 832 AutofillMetrics::LogUserHappinessMetric(
819 AutofillMetrics::USER_DID_AUTOFILL_ONCE); 833 AutofillMetrics::USER_DID_AUTOFILL_ONCE);
820 } 834 }
821 835
822 UpdateInitialInteractionTimestamp(timestamp); 836 UpdateInitialInteractionTimestamp(timestamp);
823 } 837 }
824 838
825 void AutofillManager::DidShowSuggestions(bool is_new_popup, 839 void AutofillManager::DidShowSuggestions(bool is_new_popup,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1095
1082 void AutofillManager::OnFullCardRequestFailed() { 1096 void AutofillManager::OnFullCardRequestFailed() {
1083 driver_->RendererShouldClearPreviewedForm(); 1097 driver_->RendererShouldClearPreviewedForm();
1084 } 1098 }
1085 1099
1086 void AutofillManager::ShowUnmaskPrompt( 1100 void AutofillManager::ShowUnmaskPrompt(
1087 const CreditCard& card, 1101 const CreditCard& card,
1088 AutofillClient::UnmaskCardReason reason, 1102 AutofillClient::UnmaskCardReason reason,
1089 base::WeakPtr<CardUnmaskDelegate> delegate) { 1103 base::WeakPtr<CardUnmaskDelegate> delegate) {
1090 client_->ShowUnmaskPrompt(card, reason, delegate); 1104 client_->ShowUnmaskPrompt(card, reason, delegate);
1105 form_interactions_ukm_logger_->LogUnmaskPromptEvent(
1106 AutofillMetrics::UNMASK_PROMPT_SHOWN);
1091 } 1107 }
1092 1108
1093 void AutofillManager::OnUnmaskVerificationResult( 1109 void AutofillManager::OnUnmaskVerificationResult(
1094 AutofillClient::PaymentsRpcResult result) { 1110 AutofillClient::PaymentsRpcResult result) {
1095 client_->OnUnmaskVerificationResult(result); 1111 client_->OnUnmaskVerificationResult(result);
1096 } 1112 }
1097 1113
1098 void AutofillManager::OnUserDidAcceptUpload() { 1114 void AutofillManager::OnUserDidAcceptUpload() {
1099 user_did_accept_upload_prompt_ = true; 1115 user_did_accept_upload_prompt_ = true;
1100 if (!upload_request_.risk_data.empty()) { 1116 if (!upload_request_.risk_data.empty()) {
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 // Note that |submitted_form| is passed as a pointer rather than as a reference 1387 // Note that |submitted_form| is passed as a pointer rather than as a reference
1372 // so that we can get memory management right across threads. Note also that we 1388 // so that we can get memory management right across threads. Note also that we
1373 // explicitly pass in all the time stamps of interest, as the cached ones might 1389 // explicitly pass in all the time stamps of interest, as the cached ones might
1374 // get reset before this method executes. 1390 // get reset before this method executes.
1375 void AutofillManager::UploadFormDataAsyncCallback( 1391 void AutofillManager::UploadFormDataAsyncCallback(
1376 const FormStructure* submitted_form, 1392 const FormStructure* submitted_form,
1377 const TimeTicks& load_time, 1393 const TimeTicks& load_time,
1378 const TimeTicks& interaction_time, 1394 const TimeTicks& interaction_time,
1379 const TimeTicks& submission_time, 1395 const TimeTicks& submission_time,
1380 bool observed_submission) { 1396 bool observed_submission) {
1381 submitted_form->LogQualityMetrics(load_time, interaction_time, 1397 submitted_form->LogQualityMetrics(
1382 submission_time, 1398 load_time, interaction_time, submission_time,
1383 client_->GetRapporServiceImpl(), 1399 client_->GetRapporServiceImpl(), form_interactions_ukm_logger_.get(),
1384 did_show_suggestions_, observed_submission); 1400 did_show_suggestions_, observed_submission);
1385
1386 if (submitted_form->ShouldBeCrowdsourced()) 1401 if (submitted_form->ShouldBeCrowdsourced())
1387 UploadFormData(*submitted_form, observed_submission); 1402 UploadFormData(*submitted_form, observed_submission);
1388 } 1403 }
1389 1404
1390 void AutofillManager::UploadFormData(const FormStructure& submitted_form, 1405 void AutofillManager::UploadFormData(const FormStructure& submitted_form,
1391 bool observed_submission) { 1406 bool observed_submission) {
1392 if (!download_manager_) 1407 if (!download_manager_)
1393 return; 1408 return;
1394 1409
1395 // Check if the form is among the forms that were recently auto-filled. 1410 // Check if the form is among the forms that were recently auto-filled.
(...skipping 13 matching lines...) Expand all
1409 submitted_form, was_autofilled, non_empty_types, 1424 submitted_form, was_autofilled, non_empty_types,
1410 std::string() /* login_form_signature */, observed_submission); 1425 std::string() /* login_form_signature */, observed_submission);
1411 } 1426 }
1412 1427
1413 void AutofillManager::Reset() { 1428 void AutofillManager::Reset() {
1414 // Note that upload_request_ is not reset here because the prompt to 1429 // Note that upload_request_ is not reset here because the prompt to
1415 // save a card is shown after page navigation. 1430 // save a card is shown after page navigation.
1416 ProcessPendingFormForUpload(); 1431 ProcessPendingFormForUpload();
1417 DCHECK(!pending_form_data_); 1432 DCHECK(!pending_form_data_);
1418 form_structures_.clear(); 1433 form_structures_.clear();
1419 address_form_event_logger_.reset( 1434 form_interactions_ukm_logger_.reset(
1420 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); 1435 new AutofillMetrics::FormInteractionsUkmLogger(client_->GetUkmService()));
1421 credit_card_form_event_logger_.reset( 1436 address_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
1422 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); 1437 false /* is_for_credit_card */, form_interactions_ukm_logger_.get()));
1438 credit_card_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
1439 true /* is_for_credit_card */, form_interactions_ukm_logger_.get()));
1423 #if defined(OS_ANDROID) || defined(OS_IOS) 1440 #if defined(OS_ANDROID) || defined(OS_IOS)
1424 autofill_assistant_.Reset(); 1441 autofill_assistant_.Reset();
1425 #endif 1442 #endif
1426 has_logged_autofill_enabled_ = false; 1443 has_logged_autofill_enabled_ = false;
1427 has_logged_address_suggestions_count_ = false; 1444 has_logged_address_suggestions_count_ = false;
1428 did_show_suggestions_ = false; 1445 did_show_suggestions_ = false;
1429 user_did_type_ = false; 1446 user_did_type_ = false;
1430 user_did_autofill_ = false; 1447 user_did_autofill_ = false;
1431 user_did_edit_autofilled_field_ = false; 1448 user_did_edit_autofilled_field_ = false;
1432 masked_card_ = CreditCard(); 1449 masked_card_ = CreditCard();
1433 unmasking_query_id_ = -1; 1450 unmasking_query_id_ = -1;
1434 unmasking_form_ = FormData(); 1451 unmasking_form_ = FormData();
1435 unmasking_field_ = FormFieldData(); 1452 unmasking_field_ = FormFieldData();
1436 forms_loaded_timestamps_.clear(); 1453 forms_loaded_timestamps_.clear();
1437 initial_interaction_timestamp_ = TimeTicks(); 1454 initial_interaction_timestamp_ = TimeTicks();
1438 external_delegate_->Reset(); 1455 external_delegate_->Reset();
1439 } 1456 }
1440 1457
1441 AutofillManager::AutofillManager(AutofillDriver* driver, 1458 AutofillManager::AutofillManager(AutofillDriver* driver,
1442 AutofillClient* client, 1459 AutofillClient* client,
1443 PersonalDataManager* personal_data) 1460 PersonalDataManager* personal_data)
1444 : driver_(driver), 1461 : driver_(driver),
1445 client_(client), 1462 client_(client),
1446 payments_client_( 1463 payments_client_(base::MakeUnique<payments::PaymentsClient>(
1447 new payments::PaymentsClient(driver->GetURLRequestContext(), this)), 1464 driver->GetURLRequestContext(),
1465 this)),
1448 app_locale_("en-US"), 1466 app_locale_("en-US"),
1449 personal_data_(personal_data), 1467 personal_data_(personal_data),
1450 autocomplete_history_manager_( 1468 autocomplete_history_manager_(
1451 new AutocompleteHistoryManager(driver, client)), 1469 base::MakeUnique<AutocompleteHistoryManager>(driver, client)),
1470 form_interactions_ukm_logger_(
1471 base::MakeUnique<AutofillMetrics::FormInteractionsUkmLogger>(
1472 client->GetUkmService())),
1452 address_form_event_logger_( 1473 address_form_event_logger_(
1453 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), 1474 base::MakeUnique<AutofillMetrics::FormEventLogger>(
1475 false /* is_for_credit_card */,
1476 form_interactions_ukm_logger_.get())),
1454 credit_card_form_event_logger_( 1477 credit_card_form_event_logger_(
1455 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), 1478 base::MakeUnique<AutofillMetrics::FormEventLogger>(
1479 true /* is_for_credit_card */,
1480 form_interactions_ukm_logger_.get())),
1456 has_logged_autofill_enabled_(false), 1481 has_logged_autofill_enabled_(false),
1457 has_logged_address_suggestions_count_(false), 1482 has_logged_address_suggestions_count_(false),
1458 did_show_suggestions_(false), 1483 did_show_suggestions_(false),
1459 user_did_type_(false), 1484 user_did_type_(false),
1460 user_did_autofill_(false), 1485 user_did_autofill_(false),
1461 user_did_edit_autofilled_field_(false), 1486 user_did_edit_autofilled_field_(false),
1462 unmasking_query_id_(-1), 1487 unmasking_query_id_(-1),
1463 external_delegate_(NULL), 1488 external_delegate_(NULL),
1464 test_delegate_(NULL), 1489 test_delegate_(NULL),
1465 #if defined(OS_ANDROID) || defined(OS_IOS) 1490 #if defined(OS_ANDROID) || defined(OS_IOS)
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 // Note that this may invalidate |data_model|, particularly if it is a Mac 1697 // Note that this may invalidate |data_model|, particularly if it is a Mac
1673 // address book entry. 1698 // address book entry.
1674 if (action == AutofillDriver::FORM_DATA_ACTION_FILL) 1699 if (action == AutofillDriver::FORM_DATA_ACTION_FILL)
1675 personal_data_->RecordUseOf(data_model); 1700 personal_data_->RecordUseOf(data_model);
1676 1701
1677 driver_->SendFormDataToRenderer(query_id, action, result); 1702 driver_->SendFormDataToRenderer(query_id, action, result);
1678 } 1703 }
1679 1704
1680 std::unique_ptr<FormStructure> AutofillManager::ValidateSubmittedForm( 1705 std::unique_ptr<FormStructure> AutofillManager::ValidateSubmittedForm(
1681 const FormData& form) { 1706 const FormData& form) {
1682 std::unique_ptr<FormStructure> submitted_form(new FormStructure(form)); 1707 std::unique_ptr<FormStructure> submitted_form(
1708 base::MakeUnique<FormStructure>(form));
1683 if (!ShouldUploadForm(*submitted_form)) 1709 if (!ShouldUploadForm(*submitted_form))
1684 return std::unique_ptr<FormStructure>(); 1710 return std::unique_ptr<FormStructure>();
1685 1711
1686 // Ignore forms not present in our cache. These are typically forms with 1712 // Ignore forms not present in our cache. These are typically forms with
1687 // wonky JavaScript that also makes them not auto-fillable. 1713 // wonky JavaScript that also makes them not auto-fillable.
1688 FormStructure* cached_submitted_form; 1714 FormStructure* cached_submitted_form;
1689 if (!FindCachedForm(form, &cached_submitted_form)) 1715 if (!FindCachedForm(form, &cached_submitted_form))
1690 return std::unique_ptr<FormStructure>(); 1716 return std::unique_ptr<FormStructure>();
1691 1717
1692 submitted_form->UpdateFromCache(*cached_submitted_form, false); 1718 submitted_form->UpdateFromCache(*cached_submitted_form, false);
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 parse_form_start_time); 1899 parse_form_start_time);
1874 } 1900 }
1875 1901
1876 if (!queryable_forms.empty() && download_manager_) { 1902 if (!queryable_forms.empty() && download_manager_) {
1877 // Query the server if at least one of the forms was parsed. 1903 // Query the server if at least one of the forms was parsed.
1878 download_manager_->StartQueryRequest(queryable_forms); 1904 download_manager_->StartQueryRequest(queryable_forms);
1879 } 1905 }
1880 1906
1881 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { 1907 if (!queryable_forms.empty() || !non_queryable_forms.empty()) {
1882 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); 1908 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
1909
1910 // Submit pending events, if any.
1911 form_interactions_ukm_logger_->SubmitUkm();
1912
1913 // Setup the url for metrics that we will collect for this form.
1914 form_interactions_ukm_logger_->set_url(forms[0].origin);
1915 form_interactions_ukm_logger_->LogUserHappinessMetric(
1916 AutofillMetrics::FORMS_LOADED);
1883 #if defined(OS_IOS) 1917 #if defined(OS_IOS)
1884 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure 1918 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure
1885 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be 1919 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be
1886 // directly comparable. 1920 // directly comparable.
1887 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); 1921 KeyboardAccessoryMetricsLogger::OnFormsLoaded();
1888 #endif 1922 #endif
1889 } 1923 }
1890 1924
1891 #if defined(OS_ANDROID) || defined(OS_IOS) 1925 #if defined(OS_ANDROID) || defined(OS_IOS)
1892 // When a credit card form is parsed and conditions are met, show an infobar 1926 // When a credit card form is parsed and conditions are met, show an infobar
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 } 2232 }
2199 #endif // ENABLE_FORM_DEBUG_DUMP 2233 #endif // ENABLE_FORM_DEBUG_DUMP
2200 2234
2201 void AutofillManager::LogCardUploadDecisionUkm( 2235 void AutofillManager::LogCardUploadDecisionUkm(
2202 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 2236 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
2203 AutofillMetrics::LogCardUploadDecisionUkm( 2237 AutofillMetrics::LogCardUploadDecisionUkm(
2204 client_->GetUkmService(), pending_upload_request_url_, upload_decision); 2238 client_->GetUkmService(), pending_upload_request_url_, upload_decision);
2205 } 2239 }
2206 2240
2207 } // namespace autofill 2241 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698