Chromium Code Reviews| 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 80ad335a44a0e4c50f92eb406bdb0d6884ee5045..92014a79ce4cae5f3cf57073bb7776e6606042c2 100644 |
| --- a/components/autofill/core/browser/autofill_external_delegate.cc |
| +++ b/components/autofill/core/browser/autofill_external_delegate.cc |
| @@ -49,7 +49,8 @@ AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, |
| display_warning_if_disabled_(false), |
| has_suggestion_(false), |
| has_shown_popup_for_current_edit_(false), |
| - weak_ptr_factory_(this) { |
| + weak_ptr_factory_(this), |
| + has_shown_address_book_prompt(false) { |
| DCHECK(manager); |
| } |
| @@ -60,6 +61,9 @@ void AutofillExternalDelegate::OnQuery(int query_id, |
| const FormFieldData& field, |
| const gfx::RectF& element_bounds, |
| bool display_warning_if_disabled) { |
| + if (query_form_ != form) |
| + has_shown_address_book_prompt = false; |
| + |
| query_form_ = form; |
| query_field_ = field; |
| display_warning_if_disabled_ = display_warning_if_disabled; |
| @@ -117,8 +121,6 @@ void AutofillExternalDelegate::OnSuggestionsReturned( |
| // updated to match. |
| InsertDataListValues(&values, &labels, &icons, &ids); |
| -// Temporarily disabled. See http://crbug.com/408695 |
| -#if 0 |
| #if defined(OS_MACOSX) && !defined(OS_IOS) |
| if (values.empty() && |
| manager_->ShouldShowAccessAddressBookSuggestion(query_form_, |
| @@ -129,10 +131,13 @@ void AutofillExternalDelegate::OnSuggestionsReturned( |
| icons.push_back(base::ASCIIToUTF16("macContactsIcon")); |
| ids.push_back(POPUP_ITEM_ID_MAC_ACCESS_CONTACTS); |
| - EmitHistogram(SHOWED_ACCESS_ADDRESS_BOOK_ENTRY); |
| + if (!has_shown_address_book_prompt) { |
| + has_shown_address_book_prompt = true; |
| + EmitHistogram(SHOWED_ACCESS_ADDRESS_BOOK_ENTRY); |
| + manager_->ShowedAccessAddressBookPrompt(); |
| + } |
| } |
| #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| -#endif |
| if (values.empty()) { |
| // No suggestions, any popup currently showing is obsolete. |
| @@ -201,6 +206,9 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, |
| } else if (identifier == POPUP_ITEM_ID_MAC_ACCESS_CONTACTS) { |
| #if defined(OS_MACOSX) && !defined(OS_IOS) |
| EmitHistogram(SELECTED_ACCESS_ADDRESS_BOOK_ENTRY); |
| + LOCAL_HISTOGRAM_ENUMERATION("Autofill.MacAddressBook.ShowedCount", |
|
Evan Stade
2014/09/18 22:06:09
instead of ShowedCount, how about NumShowsBeforeSe
erikchen
2014/09/18 22:49:50
Done.
|
| + manager_->AccessAddressBookPromptCount(), |
| + 30); |
|
erikchen
2014/09/18 21:55:58
This number is intentionally larger than 5, and al
|
| // User wants to give Chrome access to user's address book. |
| manager_->AccessAddressBook(); |