summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.cc6
-rw-r--r--components/autofill/core/browser/autofill_external_delegate.h3
-rw-r--r--components/autofill/core/browser/autofill_external_delegate_unittest.cc46
-rw-r--r--components/autofill/core/browser/autofill_metrics.cc5
-rw-r--r--components/autofill/core/browser/autofill_metrics.h3
-rw-r--r--components/autofill/core/browser/autofill_popup_delegate.h3
-rw-r--r--components/password_manager/core/browser/password_autofill_manager.cc3
-rw-r--r--components/password_manager/core/browser/password_autofill_manager.h3
-rw-r--r--components/password_manager/core/browser/password_autofill_manager_unittest.cc2
9 files changed, 58 insertions, 16 deletions
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index 5545f99..eda826c 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -199,7 +199,8 @@ void AutofillExternalDelegate::DidSelectSuggestion(
}
void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
- int identifier) {
+ int identifier,
+ int position) {
if (identifier == POPUP_ITEM_ID_AUTOFILL_OPTIONS) {
// User selected 'Autofill Options'.
manager_->ShowAutofillSettings();
@@ -254,6 +255,9 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
manager_->client()->ScanCreditCard(base::Bind(
&AutofillExternalDelegate::OnCreditCardScanned, GetWeakPtr()));
} else {
+ if (identifier > 0) // Denotes an Autofill suggestion.
+ AutofillMetrics::LogSuggestionAcceptedIndex(position);
+
FillAutofillFormData(identifier, false);
}
diff --git a/components/autofill/core/browser/autofill_external_delegate.h b/components/autofill/core/browser/autofill_external_delegate.h
index 3803e24..7f09d74 100644
--- a/components/autofill/core/browser/autofill_external_delegate.h
+++ b/components/autofill/core/browser/autofill_external_delegate.h
@@ -41,7 +41,8 @@ class AutofillExternalDelegate : public AutofillPopupDelegate {
void DidSelectSuggestion(const base::string16& value,
int identifier) override;
void DidAcceptSuggestion(const base::string16& value,
- int identifier) override;
+ int identifier,
+ int position) override;
bool GetDeletionConfirmationText(const base::string16& value,
int identifier,
base::string16* title,
diff --git a/components/autofill/core/browser/autofill_external_delegate_unittest.cc b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
index e9bef06..18939bb 100644
--- a/components/autofill/core/browser/autofill_external_delegate_unittest.cc
+++ b/components/autofill/core/browser/autofill_external_delegate_unittest.cc
@@ -181,7 +181,8 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
// This should trigger a call to hide the popup since we've selected an
// option.
external_delegate_->DidAcceptSuggestion(autofill_item[0].value,
- autofill_item[0].frontend_id);
+ autofill_item[0].frontend_id,
+ 0);
}
// Test that data list elements for a node will appear in the Autofill popup.
@@ -325,7 +326,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
// Ensure it doesn't try to fill the form in with the negative id.
EXPECT_CALL(autofill_client_, HideAutofillPopup());
EXPECT_CALL(*autofill_manager_, FillOrPreviewForm(_, _, _, _, _)).Times(0);
- external_delegate_->DidAcceptSuggestion(base::string16(), -1);
+ external_delegate_->DidAcceptSuggestion(base::string16(), -1, 0);
}
// Test that the ClearPreview call is only sent if the form was being previewed
@@ -363,13 +364,32 @@ TEST_F(AutofillExternalDelegateUnitTest,
// Test that the driver is directed to accept the data list after being notified
// that the user accepted the data list suggestion.
-TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) {
+TEST_F(AutofillExternalDelegateUnitTest,
+ ExternalDelegateAcceptDatalistSuggestion) {
EXPECT_CALL(autofill_client_, HideAutofillPopup());
base::string16 dummy_string(ASCIIToUTF16("baz qux"));
EXPECT_CALL(*autofill_driver_,
RendererShouldAcceptDataListSuggestion(dummy_string));
external_delegate_->DidAcceptSuggestion(dummy_string,
- POPUP_ITEM_ID_DATALIST_ENTRY);
+ POPUP_ITEM_ID_DATALIST_ENTRY,
+ 0);
+}
+
+// Test that an accepted autofill suggestion will fill the form and log the
+// proper metric.
+TEST_F(AutofillExternalDelegateUnitTest,
+ ExternalDelegateAcceptAutofillSuggestion) {
+ EXPECT_CALL(autofill_client_, HideAutofillPopup());
+ base::string16 dummy_string(ASCIIToUTF16("John Legend"));
+ EXPECT_CALL(*autofill_manager_,
+ FillOrPreviewForm(
+ AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _,
+ kAutofillProfileId));
+ base::HistogramTester histogram;
+ external_delegate_->DidAcceptSuggestion(dummy_string,
+ kAutofillProfileId,
+ 2); // Row 2
+ histogram.ExpectUniqueSample("Autofill.SuggestionAcceptedIndex", 2, 1);
}
// Test that the driver is directed to clear the form after being notified that
@@ -379,7 +399,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) {
EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledForm());
external_delegate_->DidAcceptSuggestion(base::string16(),
- POPUP_ITEM_ID_CLEAR_FORM);
+ POPUP_ITEM_ID_CLEAR_FORM,
+ 0);
}
// Test that autofill client will scan a credit card after use accepted the
@@ -388,7 +409,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardMenuItem) {
EXPECT_CALL(autofill_client_, ScanCreditCard(_));
EXPECT_CALL(autofill_client_, HideAutofillPopup());
external_delegate_->DidAcceptSuggestion(base::string16(),
- POPUP_ITEM_ID_SCAN_CREDIT_CARD);
+ POPUP_ITEM_ID_SCAN_CREDIT_CARD,
+ 0);
}
TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
@@ -411,7 +433,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
IssueOnQuery(kQueryId);
IssueOnSuggestionsReturned();
external_delegate_->DidAcceptSuggestion(base::string16(),
- POPUP_ITEM_ID_SCAN_CREDIT_CARD);
+ POPUP_ITEM_ID_SCAN_CREDIT_CARD,
+ 0);
histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt",
AutofillMetrics::SCAN_CARD_ITEM_SHOWN, 1);
histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt",
@@ -428,7 +451,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
IssueOnQuery(kQueryId);
IssueOnSuggestionsReturned();
external_delegate_->DidAcceptSuggestion(base::string16(),
- POPUP_ITEM_ID_CLEAR_FORM);
+ POPUP_ITEM_ID_CLEAR_FORM,
+ 0);
histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt",
AutofillMetrics::SCAN_CARD_ITEM_SHOWN, 1);
histogram.ExpectBucketCount("Autofill.ScanCreditCardPrompt",
@@ -445,7 +469,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
IssueOnQuery(kQueryId);
IssueOnSuggestionsReturned();
external_delegate_->DidAcceptSuggestion(base::string16(),
- POPUP_ITEM_ID_CLEAR_FORM);
+ POPUP_ITEM_ID_CLEAR_FORM,
+ 0);
histogram.ExpectTotalCount("Autofill.ScanCreditCardPrompt", 0);
}
}
@@ -490,7 +515,8 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) {
EXPECT_CALL(*autofill_driver_,
RendererShouldFillFieldWithValue(dummy_string));
external_delegate_->DidAcceptSuggestion(dummy_string,
- POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
+ POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY,
+ 0);
}
} // namespace autofill
diff --git a/components/autofill/core/browser/autofill_metrics.cc b/components/autofill/core/browser/autofill_metrics.cc
index b761247..fae07e8 100644
--- a/components/autofill/core/browser/autofill_metrics.cc
+++ b/components/autofill/core/browser/autofill_metrics.cc
@@ -606,6 +606,11 @@ void AutofillMetrics::LogAddressSuggestionsCount(size_t num_suggestions) {
UMA_HISTOGRAM_COUNTS("Autofill.AddressSuggestionsCount", num_suggestions);
}
+// static
+void AutofillMetrics::LogSuggestionAcceptedIndex(int index) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Autofill.SuggestionAcceptedIndex", index);
+}
+
void AutofillMetrics::LogPasswordFormQueryVolume(
PasswordFormQueryVolumeMetric metric) {
UMA_HISTOGRAM_ENUMERATION("Autofill.PasswordFormQueryVolume", metric,
diff --git a/components/autofill/core/browser/autofill_metrics.h b/components/autofill/core/browser/autofill_metrics.h
index 3d67990..c7420e4 100644
--- a/components/autofill/core/browser/autofill_metrics.h
+++ b/components/autofill/core/browser/autofill_metrics.h
@@ -559,6 +559,9 @@ class AutofillMetrics {
// form.
static void LogAddressSuggestionsCount(size_t num_suggestions);
+ // Log the index of the selected suggestion in the Autofill popup.
+ static void LogSuggestionAcceptedIndex(int index);
+
// Log password form query: current and if one-to-two fields password forms
// were allowed.
static void LogPasswordFormQueryVolume(PasswordFormQueryVolumeMetric metric);
diff --git a/components/autofill/core/browser/autofill_popup_delegate.h b/components/autofill/core/browser/autofill_popup_delegate.h
index 8c77edb..99a6675 100644
--- a/components/autofill/core/browser/autofill_popup_delegate.h
+++ b/components/autofill/core/browser/autofill_popup_delegate.h
@@ -26,7 +26,8 @@ class AutofillPopupDelegate {
// Inform the delegate that a row in the popup has been chosen.
virtual void DidAcceptSuggestion(const base::string16& value,
- int identifier) = 0;
+ int identifier,
+ int position) = 0;
// Returns whether the given value can be deleted, and if true,
// fills out |title| and |body|.
diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc
index a9b6644..c8d8378 100644
--- a/components/password_manager/core/browser/password_autofill_manager.cc
+++ b/components/password_manager/core/browser/password_autofill_manager.cc
@@ -212,7 +212,8 @@ void PasswordAutofillManager::DidSelectSuggestion(const base::string16& value,
}
void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value,
- int identifier) {
+ int identifier,
+ int position) {
bool success = FillSuggestion(form_data_key_, value);
DCHECK(success);
autofill_client_->HideAutofillPopup();
diff --git a/components/password_manager/core/browser/password_autofill_manager.h b/components/password_manager/core/browser/password_autofill_manager.h
index 96e998f..0b52172 100644
--- a/components/password_manager/core/browser/password_autofill_manager.h
+++ b/components/password_manager/core/browser/password_autofill_manager.h
@@ -34,7 +34,8 @@ class PasswordAutofillManager : public autofill::AutofillPopupDelegate {
void DidSelectSuggestion(const base::string16& value,
int identifier) override;
void DidAcceptSuggestion(const base::string16& value,
- int identifier) override;
+ int identifier,
+ int position) override;
bool GetDeletionConfirmationText(const base::string16& value,
int identifier,
base::string16* title,
diff --git a/components/password_manager/core/browser/password_autofill_manager_unittest.cc b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
index d811161..7dd87dc 100644
--- a/components/password_manager/core/browser/password_autofill_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_autofill_manager_unittest.cc
@@ -199,7 +199,7 @@ TEST_F(PasswordAutofillManagerTest, ExternalDelegatePasswordSuggestions) {
// Accepting a suggestion should trigger a call to hide the popup.
EXPECT_CALL(*autofill_client, HideAutofillPopup());
password_autofill_manager_->DidAcceptSuggestion(
- test_username_, autofill::POPUP_ITEM_ID_PASSWORD_ENTRY);
+ test_username_, autofill::POPUP_ITEM_ID_PASSWORD_ENTRY, 1);
}
// Test that OnShowPasswordSuggestions correctly matches the given FormFieldData