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

Side by Side 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 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_external_delegate.h" 5 #include "components/autofill/core/browser/autofill_external_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } // namespace 56 } // namespace
57 57
58 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, 58 AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager,
59 AutofillDriver* driver) 59 AutofillDriver* driver)
60 : manager_(manager), 60 : manager_(manager),
61 driver_(driver), 61 driver_(driver),
62 query_id_(0), 62 query_id_(0),
63 display_warning_if_disabled_(false), 63 display_warning_if_disabled_(false),
64 has_suggestion_(false), 64 has_suggestion_(false),
65 has_shown_popup_for_current_edit_(false), 65 has_shown_popup_for_current_edit_(false),
66 should_show_scan_credit_card_(false),
66 has_shown_address_book_prompt(false), 67 has_shown_address_book_prompt(false),
67 weak_ptr_factory_(this) { 68 weak_ptr_factory_(this) {
68 DCHECK(manager); 69 DCHECK(manager);
69 } 70 }
70 71
71 AutofillExternalDelegate::~AutofillExternalDelegate() {} 72 AutofillExternalDelegate::~AutofillExternalDelegate() {}
72 73
73 void AutofillExternalDelegate::OnQuery(int query_id, 74 void AutofillExternalDelegate::OnQuery(int query_id,
74 const FormData& form, 75 const FormData& form,
75 const FormFieldData& field, 76 const FormFieldData& field,
76 const gfx::RectF& element_bounds, 77 const gfx::RectF& element_bounds,
77 bool display_warning_if_disabled) { 78 bool display_warning_if_disabled) {
78 if (!query_form_.SameFormAs(form)) 79 if (!query_form_.SameFormAs(form))
79 has_shown_address_book_prompt = false; 80 has_shown_address_book_prompt = false;
80 81
81 query_form_ = form; 82 query_form_ = form;
82 query_field_ = field; 83 query_field_ = field;
83 display_warning_if_disabled_ = display_warning_if_disabled; 84 display_warning_if_disabled_ = display_warning_if_disabled;
84 query_id_ = query_id; 85 query_id_ = query_id;
85 element_bounds_ = element_bounds; 86 element_bounds_ = element_bounds;
87 should_show_scan_credit_card_ =
88 manager_->ShouldShowScanCreditCard(query_form_, query_field_);
86 } 89 }
87 90
88 void AutofillExternalDelegate::OnSuggestionsReturned( 91 void AutofillExternalDelegate::OnSuggestionsReturned(
89 int query_id, 92 int query_id,
90 const std::vector<base::string16>& suggested_values, 93 const std::vector<base::string16>& suggested_values,
91 const std::vector<base::string16>& suggested_labels, 94 const std::vector<base::string16>& suggested_labels,
92 const std::vector<base::string16>& suggested_icons, 95 const std::vector<base::string16>& suggested_icons,
93 const std::vector<int>& suggested_unique_ids) { 96 const std::vector<int>& suggested_unique_ids) {
94 if (query_id != query_id_) 97 if (query_id != query_id_)
95 return; 98 return;
96 99
97 std::vector<base::string16> values(suggested_values); 100 std::vector<base::string16> values(suggested_values);
98 std::vector<base::string16> labels(suggested_labels); 101 std::vector<base::string16> labels(suggested_labels);
99 std::vector<base::string16> icons(suggested_icons); 102 std::vector<base::string16> icons(suggested_icons);
100 std::vector<int> ids(suggested_unique_ids); 103 std::vector<int> ids(suggested_unique_ids);
101 104
102 // Add or hide warnings as appropriate. 105 // Add or hide warnings as appropriate.
103 ApplyAutofillWarnings(&values, &labels, &icons, &ids); 106 ApplyAutofillWarnings(&values, &labels, &icons, &ids);
104 107
105 // Add a separator to go between the values and menu items. 108 // Add a separator to go between the values and menu items.
106 values.push_back(base::string16()); 109 values.push_back(base::string16());
107 labels.push_back(base::string16()); 110 labels.push_back(base::string16());
108 icons.push_back(base::string16()); 111 icons.push_back(base::string16());
109 ids.push_back(POPUP_ITEM_ID_SEPARATOR); 112 ids.push_back(POPUP_ITEM_ID_SEPARATOR);
110 113
111 if (manager_->ShouldShowScanCreditCard(query_form_, query_field_)) { 114 if (should_show_scan_credit_card_) {
112 values.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_SCAN_CREDIT_CARD)); 115 values.push_back(l10n_util::GetStringUTF16(IDS_AUTOFILL_SCAN_CREDIT_CARD));
113 labels.push_back(base::string16()); 116 labels.push_back(base::string16());
114 icons.push_back(base::string16()); 117 icons.push_back(base::string16());
115 ids.push_back(POPUP_ITEM_ID_SCAN_CREDIT_CARD); 118 ids.push_back(POPUP_ITEM_ID_SCAN_CREDIT_CARD);
119
120 if (!has_shown_popup_for_current_edit_) {
121 AutofillMetrics::LogScanCreditCardPromptMetric(
122 AutofillMetrics::SCAN_CARD_ITEM_SHOWN);
123 }
116 } 124 }
117 125
118 // Only include "Autofill Options" special menu item if we have Autofill 126 // Only include "Autofill Options" special menu item if we have Autofill
119 // suggestions. 127 // suggestions.
120 has_suggestion_ = false; 128 has_suggestion_ = false;
121 for (size_t i = 0; i < ids.size(); ++i) { 129 for (size_t i = 0; i < ids.size(); ++i) {
122 if (ids[i] > 0) { 130 if (ids[i] > 0) {
123 has_suggestion_ = true; 131 has_suggestion_ = true;
124 break; 132 break;
125 } 133 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 #else 269 #else
262 NOTREACHED(); 270 NOTREACHED();
263 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 271 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
264 } else if (identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD) { 272 } else if (identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD) {
265 manager_->client()->ScanCreditCard(base::Bind( 273 manager_->client()->ScanCreditCard(base::Bind(
266 &AutofillExternalDelegate::OnCreditCardScanned, GetWeakPtr())); 274 &AutofillExternalDelegate::OnCreditCardScanned, GetWeakPtr()));
267 } else { 275 } else {
268 FillAutofillFormData(identifier, false); 276 FillAutofillFormData(identifier, false);
269 } 277 }
270 278
279 if (should_show_scan_credit_card_) {
280 AutofillMetrics::LogScanCreditCardPromptMetric(
281 identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD
282 ? AutofillMetrics::SCAN_CARD_ITEM_SELECTED
283 : AutofillMetrics::SCAN_CARD_OTHER_ITEM_SELECTED);
284 }
285
271 manager_->client()->HideAutofillPopup(); 286 manager_->client()->HideAutofillPopup();
272 } 287 }
273 288
274 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value, 289 void AutofillExternalDelegate::RemoveSuggestion(const base::string16& value,
275 int identifier) { 290 int identifier) {
276 if (identifier > 0) 291 if (identifier > 0)
277 manager_->RemoveAutofillProfileOrCreditCard(identifier); 292 manager_->RemoveAutofillProfileOrCreditCard(identifier);
278 else 293 else
279 manager_->RemoveAutocompleteEntry(query_field_.name, value); 294 manager_->RemoveAutocompleteEntry(query_field_.name, value);
280 } 295 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 POPUP_ITEM_ID_DATALIST_ENTRY); 448 POPUP_ITEM_ID_DATALIST_ENTRY);
434 } 449 }
435 450
436 #if defined(OS_MACOSX) && !defined(OS_IOS) 451 #if defined(OS_MACOSX) && !defined(OS_IOS)
437 void AutofillExternalDelegate::PingRenderer() { 452 void AutofillExternalDelegate::PingRenderer() {
438 driver_->PingRenderer(); 453 driver_->PingRenderer();
439 } 454 }
440 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 455 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
441 456
442 } // namespace autofill 457 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698