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

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

Issue 785953004: Add histogram for "scan credit card" usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years 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_external_delegate.cc
diff --git a/components/autofill/core/browser/autofill_external_delegate.cc b/components/autofill/core/browser/autofill_external_delegate.cc
index 82a6d670a75666653ddc900ea3b480499efa17c8..c31dcd03b223be0674b9beb334351d87e499abed 100644
--- a/components/autofill/core/browser/autofill_external_delegate.cc
+++ b/components/autofill/core/browser/autofill_external_delegate.cc
@@ -63,6 +63,7 @@ AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager,
display_warning_if_disabled_(false),
has_suggestion_(false),
has_shown_popup_for_current_edit_(false),
+ should_show_scan_credit_card_(false),
has_shown_address_book_prompt(false),
weak_ptr_factory_(this) {
DCHECK(manager);
@@ -83,6 +84,8 @@ void AutofillExternalDelegate::OnQuery(int query_id,
display_warning_if_disabled_ = display_warning_if_disabled;
query_id_ = query_id;
element_bounds_ = element_bounds;
+ should_show_scan_credit_card_ =
+ manager_->ShouldShowScanCreditCard(query_form_, query_field_);
}
void AutofillExternalDelegate::OnSuggestionsReturned(
@@ -108,11 +111,16 @@ void AutofillExternalDelegate::OnSuggestionsReturned(
icons.push_back(base::string16());
ids.push_back(POPUP_ITEM_ID_SEPARATOR);
- if (manager_->ShouldShowScanCreditCard(query_form_, query_field_)) {
+ if (should_show_scan_credit_card_) {
values.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_SCAN_CREDIT_CARD));
labels.push_back(base::string16());
icons.push_back(base::string16());
ids.push_back(POPUP_ITEM_ID_SCAN_CREDIT_CARD);
+
+ if (!has_shown_popup_for_current_edit_) {
+ AutofillMetrics::LogScanCreditCardPromptMetric(
+ AutofillMetrics::SCAN_CARD_ITEM_SHOWN);
+ }
}
// Only include "Autofill Options" special menu item if we have Autofill
@@ -268,6 +276,13 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value,
FillAutofillFormData(identifier, false);
}
+ if (should_show_scan_credit_card_) {
+ AutofillMetrics::LogScanCreditCardPromptMetric(
+ identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD
+ ? AutofillMetrics::SCAN_CARD_ITEM_SELECTED
+ : AutofillMetrics::SCAN_CARD_OTHER_ITEM_SELECTED);
+ }
+
manager_->client()->HideAutofillPopup();
}

Powered by Google App Engine
This is Rietveld 408576698