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

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

Issue 2800853004: UKM that threads together multiple form interaction events. (Closed)
Patch Set: 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_(
221 new payments::PaymentsClient(driver->GetURLRequestContext(), this)), 221 new payments::PaymentsClient(driver->GetURLRequestContext(), this)),
222 app_locale_(app_locale), 222 app_locale_(app_locale),
223 personal_data_(client->GetPersonalDataManager()), 223 personal_data_(client->GetPersonalDataManager()),
224 autocomplete_history_manager_( 224 autocomplete_history_manager_(
225 new AutocompleteHistoryManager(driver, client)), 225 new AutocompleteHistoryManager(driver, client)),
226 ukm_logger_(new AutofillMetrics::UkmLogger(client->GetUkmService())),
Roger McFarlane (Chromium) 2017/04/07 02:34:01 prefer base::MakeUnique<Foo>(bar, baz, boz) over n
csashi 2017/04/07 06:46:28 Done.
226 address_form_event_logger_( 227 address_form_event_logger_(
227 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), 228 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */,
229 ukm_logger_.get())),
228 credit_card_form_event_logger_( 230 credit_card_form_event_logger_(
229 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), 231 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */,
232 ukm_logger_.get())),
230 has_logged_autofill_enabled_(false), 233 has_logged_autofill_enabled_(false),
231 has_logged_address_suggestions_count_(false), 234 has_logged_address_suggestions_count_(false),
232 did_show_suggestions_(false), 235 did_show_suggestions_(false),
233 user_did_type_(false), 236 user_did_type_(false),
234 user_did_autofill_(false), 237 user_did_autofill_(false),
235 user_did_edit_autofilled_field_(false), 238 user_did_edit_autofilled_field_(false),
236 user_did_accept_upload_prompt_(false), 239 user_did_accept_upload_prompt_(false),
237 external_delegate_(NULL), 240 external_delegate_(NULL),
238 test_delegate_(NULL), 241 test_delegate_(NULL),
239 #if defined(OS_ANDROID) || defined(OS_IOS) 242 #if defined(OS_ANDROID) || defined(OS_IOS)
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field)) 513 if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field))
511 return; 514 return;
512 515
513 UpdatePendingForm(form); 516 UpdatePendingForm(form);
514 517
515 if (!user_did_type_) { 518 if (!user_did_type_) {
516 user_did_type_ = true; 519 user_did_type_ = true;
517 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE); 520 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
518 } 521 }
519 522
523 DCHECK(ukm_logger_);
524 if (ukm_logger_)
525 ukm_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_TYPE);
526
520 if (autofill_field->is_autofilled) { 527 if (autofill_field->is_autofilled) {
521 autofill_field->is_autofilled = false; 528 autofill_field->is_autofilled = false;
522 autofill_field->set_previously_autofilled(true); 529 autofill_field->set_previously_autofilled(true);
523 AutofillMetrics::LogUserHappinessMetric( 530 AutofillMetrics::LogUserHappinessMetric(
524 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD); 531 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
532 if (ukm_logger_)
533 ukm_logger_->LogUserHappinessMetric(
534 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD);
525 535
526 if (!user_did_edit_autofilled_field_) { 536 if (!user_did_edit_autofilled_field_) {
527 user_did_edit_autofilled_field_ = true; 537 user_did_edit_autofilled_field_ = true;
528 AutofillMetrics::LogUserHappinessMetric( 538 AutofillMetrics::LogUserHappinessMetric(
529 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE); 539 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD_ONCE);
530 } 540 }
531 } 541 }
532 542
533 UpdateInitialInteractionTimestamp(timestamp); 543 UpdateInitialInteractionTimestamp(timestamp);
534 } 544 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 816 }
807 817
808 void AutofillManager::OnDidFillAutofillFormData(const FormData& form, 818 void AutofillManager::OnDidFillAutofillFormData(const FormData& form,
809 const TimeTicks& timestamp) { 819 const TimeTicks& timestamp) {
810 if (test_delegate_) 820 if (test_delegate_)
811 test_delegate_->DidFillFormData(); 821 test_delegate_->DidFillFormData();
812 822
813 UpdatePendingForm(form); 823 UpdatePendingForm(form);
814 824
815 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL); 825 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
826 DCHECK(ukm_logger_);
827 if (ukm_logger_)
828 ukm_logger_->LogUserHappinessMetric(AutofillMetrics::USER_DID_AUTOFILL);
816 if (!user_did_autofill_) { 829 if (!user_did_autofill_) {
817 user_did_autofill_ = true; 830 user_did_autofill_ = true;
818 AutofillMetrics::LogUserHappinessMetric( 831 AutofillMetrics::LogUserHappinessMetric(
819 AutofillMetrics::USER_DID_AUTOFILL_ONCE); 832 AutofillMetrics::USER_DID_AUTOFILL_ONCE);
820 } 833 }
821 834
822 UpdateInitialInteractionTimestamp(timestamp); 835 UpdateInitialInteractionTimestamp(timestamp);
823 } 836 }
824 837
825 void AutofillManager::DidShowSuggestions(bool is_new_popup, 838 void AutofillManager::DidShowSuggestions(bool is_new_popup,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1094
1082 void AutofillManager::OnFullCardRequestFailed() { 1095 void AutofillManager::OnFullCardRequestFailed() {
1083 driver_->RendererShouldClearPreviewedForm(); 1096 driver_->RendererShouldClearPreviewedForm();
1084 } 1097 }
1085 1098
1086 void AutofillManager::ShowUnmaskPrompt( 1099 void AutofillManager::ShowUnmaskPrompt(
1087 const CreditCard& card, 1100 const CreditCard& card,
1088 AutofillClient::UnmaskCardReason reason, 1101 AutofillClient::UnmaskCardReason reason,
1089 base::WeakPtr<CardUnmaskDelegate> delegate) { 1102 base::WeakPtr<CardUnmaskDelegate> delegate) {
1090 client_->ShowUnmaskPrompt(card, reason, delegate); 1103 client_->ShowUnmaskPrompt(card, reason, delegate);
1104 DCHECK(ukm_logger_);
1105 if (ukm_logger_)
1106 ukm_logger_->LogUnmaskPromptEvent(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 AutofillMetrics::AutofillFormSubmittedState state =
1382 submission_time, 1398 submitted_form->LogQualityMetrics(
1383 client_->GetRapporServiceImpl(), 1399 load_time, interaction_time, submission_time,
1384 did_show_suggestions_, observed_submission); 1400 client_->GetRapporServiceImpl(), did_show_suggestions_,
1401 observed_submission);
1402 if (state < AutofillMetrics::AUTOFILL_FORM_SUBMITTED_STATE_ENUM_SIZE) {
1403 AutofillMetrics::LogAutofillFormSubmittedState(state);
1404 DCHECK(ukm_logger_);
1405 ukm_logger_->LogAutofillFormSubmittedState(submitted_form->source_url(),
1406 state);
1407 ukm_logger_->LogUkm();
1408 }
1385 1409
1386 if (submitted_form->ShouldBeCrowdsourced()) 1410 if (submitted_form->ShouldBeCrowdsourced())
1387 UploadFormData(*submitted_form, observed_submission); 1411 UploadFormData(*submitted_form, observed_submission);
1388 } 1412 }
1389 1413
1390 void AutofillManager::UploadFormData(const FormStructure& submitted_form, 1414 void AutofillManager::UploadFormData(const FormStructure& submitted_form,
1391 bool observed_submission) { 1415 bool observed_submission) {
1392 if (!download_manager_) 1416 if (!download_manager_)
1393 return; 1417 return;
1394 1418
(...skipping 14 matching lines...) Expand all
1409 submitted_form, was_autofilled, non_empty_types, 1433 submitted_form, was_autofilled, non_empty_types,
1410 std::string() /* login_form_signature */, observed_submission); 1434 std::string() /* login_form_signature */, observed_submission);
1411 } 1435 }
1412 1436
1413 void AutofillManager::Reset() { 1437 void AutofillManager::Reset() {
1414 // Note that upload_request_ is not reset here because the prompt to 1438 // Note that upload_request_ is not reset here because the prompt to
1415 // save a card is shown after page navigation. 1439 // save a card is shown after page navigation.
1416 ProcessPendingFormForUpload(); 1440 ProcessPendingFormForUpload();
1417 DCHECK(!pending_form_data_); 1441 DCHECK(!pending_form_data_);
1418 form_structures_.clear(); 1442 form_structures_.clear();
1419 address_form_event_logger_.reset( 1443 ukm_logger_.reset(new AutofillMetrics::UkmLogger(client_->GetUkmService()));
1420 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)); 1444 address_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
1421 credit_card_form_event_logger_.reset( 1445 false /* is_for_credit_card */, ukm_logger_.get()));
1422 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)); 1446 credit_card_form_event_logger_.reset(new AutofillMetrics::FormEventLogger(
1447 true /* is_for_credit_card */, ukm_logger_.get()));
1423 #if defined(OS_ANDROID) || defined(OS_IOS) 1448 #if defined(OS_ANDROID) || defined(OS_IOS)
1424 autofill_assistant_.Reset(); 1449 autofill_assistant_.Reset();
1425 #endif 1450 #endif
1426 has_logged_autofill_enabled_ = false; 1451 has_logged_autofill_enabled_ = false;
1427 has_logged_address_suggestions_count_ = false; 1452 has_logged_address_suggestions_count_ = false;
1428 did_show_suggestions_ = false; 1453 did_show_suggestions_ = false;
1429 user_did_type_ = false; 1454 user_did_type_ = false;
1430 user_did_autofill_ = false; 1455 user_did_autofill_ = false;
1431 user_did_edit_autofilled_field_ = false; 1456 user_did_edit_autofilled_field_ = false;
1432 masked_card_ = CreditCard(); 1457 masked_card_ = CreditCard();
1433 unmasking_query_id_ = -1; 1458 unmasking_query_id_ = -1;
1434 unmasking_form_ = FormData(); 1459 unmasking_form_ = FormData();
1435 unmasking_field_ = FormFieldData(); 1460 unmasking_field_ = FormFieldData();
1436 forms_loaded_timestamps_.clear(); 1461 forms_loaded_timestamps_.clear();
1437 initial_interaction_timestamp_ = TimeTicks(); 1462 initial_interaction_timestamp_ = TimeTicks();
1438 external_delegate_->Reset(); 1463 external_delegate_->Reset();
1439 } 1464 }
1440 1465
1441 AutofillManager::AutofillManager(AutofillDriver* driver, 1466 AutofillManager::AutofillManager(AutofillDriver* driver,
1442 AutofillClient* client, 1467 AutofillClient* client,
1443 PersonalDataManager* personal_data) 1468 PersonalDataManager* personal_data)
1444 : driver_(driver), 1469 : driver_(driver),
1445 client_(client), 1470 client_(client),
1446 payments_client_( 1471 payments_client_(
1447 new payments::PaymentsClient(driver->GetURLRequestContext(), this)), 1472 new payments::PaymentsClient(driver->GetURLRequestContext(), this)),
1448 app_locale_("en-US"), 1473 app_locale_("en-US"),
1449 personal_data_(personal_data), 1474 personal_data_(personal_data),
1450 autocomplete_history_manager_( 1475 autocomplete_history_manager_(
1451 new AutocompleteHistoryManager(driver, client)), 1476 new AutocompleteHistoryManager(driver, client)),
1477 ukm_logger_(new AutofillMetrics::UkmLogger(client->GetUkmService())),
1452 address_form_event_logger_( 1478 address_form_event_logger_(
1453 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */)), 1479 new AutofillMetrics::FormEventLogger(false /* is_for_credit_card */,
1480 ukm_logger_.get())),
1454 credit_card_form_event_logger_( 1481 credit_card_form_event_logger_(
1455 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */)), 1482 new AutofillMetrics::FormEventLogger(true /* is_for_credit_card */,
1483 ukm_logger_.get())),
1456 has_logged_autofill_enabled_(false), 1484 has_logged_autofill_enabled_(false),
1457 has_logged_address_suggestions_count_(false), 1485 has_logged_address_suggestions_count_(false),
1458 did_show_suggestions_(false), 1486 did_show_suggestions_(false),
1459 user_did_type_(false), 1487 user_did_type_(false),
1460 user_did_autofill_(false), 1488 user_did_autofill_(false),
1461 user_did_edit_autofilled_field_(false), 1489 user_did_edit_autofilled_field_(false),
1462 unmasking_query_id_(-1), 1490 unmasking_query_id_(-1),
1463 external_delegate_(NULL), 1491 external_delegate_(NULL),
1464 test_delegate_(NULL), 1492 test_delegate_(NULL),
1465 #if defined(OS_ANDROID) || defined(OS_IOS) 1493 #if defined(OS_ANDROID) || defined(OS_IOS)
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 parse_form_start_time); 1901 parse_form_start_time);
1874 } 1902 }
1875 1903
1876 if (!queryable_forms.empty() && download_manager_) { 1904 if (!queryable_forms.empty() && download_manager_) {
1877 // Query the server if at least one of the forms was parsed. 1905 // Query the server if at least one of the forms was parsed.
1878 download_manager_->StartQueryRequest(queryable_forms); 1906 download_manager_->StartQueryRequest(queryable_forms);
1879 } 1907 }
1880 1908
1881 if (!queryable_forms.empty() || !non_queryable_forms.empty()) { 1909 if (!queryable_forms.empty() || !non_queryable_forms.empty()) {
1882 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED); 1910 AutofillMetrics::LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
1911
1912 // Log pending events, if any.
1913 ukm_logger_->LogUkm();
1914
1915 // If user submits a form, we set the key to the |submitted_form|'s
1916 // |source_url()|.
1917 ukm_logger_->set_url(forms[0].origin);
1918 ukm_logger_->LogUserHappinessMetric(AutofillMetrics::FORMS_LOADED);
1883 #if defined(OS_IOS) 1919 #if defined(OS_IOS)
1884 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure 1920 // Log this from same location as AutofillMetrics::FORMS_LOADED to ensure
1885 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be 1921 // that KeyboardAccessoryButtonsIOS and UserHappiness UMA metrics will be
1886 // directly comparable. 1922 // directly comparable.
1887 KeyboardAccessoryMetricsLogger::OnFormsLoaded(); 1923 KeyboardAccessoryMetricsLogger::OnFormsLoaded();
1888 #endif 1924 #endif
1889 } 1925 }
1890 1926
1891 #if defined(OS_ANDROID) || defined(OS_IOS) 1927 #if defined(OS_ANDROID) || defined(OS_IOS)
1892 // When a credit card form is parsed and conditions are met, show an infobar 1928 // 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 } 2234 }
2199 #endif // ENABLE_FORM_DEBUG_DUMP 2235 #endif // ENABLE_FORM_DEBUG_DUMP
2200 2236
2201 void AutofillManager::LogCardUploadDecisionUkm( 2237 void AutofillManager::LogCardUploadDecisionUkm(
2202 AutofillMetrics::CardUploadDecisionMetric upload_decision) { 2238 AutofillMetrics::CardUploadDecisionMetric upload_decision) {
2203 AutofillMetrics::LogCardUploadDecisionUkm( 2239 AutofillMetrics::LogCardUploadDecisionUkm(
2204 client_->GetUkmService(), pending_upload_request_url_, upload_decision); 2240 client_->GetUkmService(), pending_upload_request_url_, upload_decision);
2205 } 2241 }
2206 2242
2207 } // namespace autofill 2243 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698