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 eaa1fd547eacc9a2b63c08b7e86670686f58a3bb..a81613d0b6dce6e19a52e3b0b24c9c8e72d66769 100644 |
--- a/components/autofill/core/browser/autofill_external_delegate.cc |
+++ b/components/autofill/core/browser/autofill_external_delegate.cc |
@@ -35,6 +35,7 @@ AutofillExternalDelegate::AutofillExternalDelegate(AutofillManager* manager, |
has_suggestion_(false), |
has_shown_popup_for_current_edit_(false), |
should_show_scan_credit_card_(false), |
+ should_show_cc_signin_promo_(false), |
has_shown_address_book_prompt(false), |
weak_ptr_factory_(this) { |
DCHECK(manager); |
@@ -55,6 +56,8 @@ void AutofillExternalDelegate::OnQuery(int query_id, |
element_bounds_ = element_bounds; |
should_show_scan_credit_card_ = |
manager_->ShouldShowScanCreditCard(query_form_, query_field_); |
+ should_show_cc_signin_promo_ = |
+ manager_->ShouldShowCreditCardSigninPromo(query_form_, query_field_); |
} |
void AutofillExternalDelegate::OnSuggestionsReturned( |
@@ -100,6 +103,22 @@ void AutofillExternalDelegate::OnSuggestionsReturned( |
if (has_suggestion_) |
ApplyAutofillOptions(&suggestions); |
+ // Append the credit card signin promo, if appropriate. |
+ if (has_suggestion_ && should_show_cc_signin_promo_) { |
+// No separator on Android. |
+#if !defined(OS_ANDROID) |
+ Suggestion separator; |
+ separator.frontend_id = POPUP_ITEM_ID_SEPARATOR; |
+ suggestions.push_back(separator); |
+#endif |
+ |
+ Suggestion signin_promo_suggestion( |
+ l10n_util::GetStringUTF16(IDS_AUTOFILL_CREDIT_CARD_SIGNIN_PROMO)); |
+ signin_promo_suggestion.frontend_id = |
+ POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO; |
+ suggestions.push_back(signin_promo_suggestion); |
+ } |
+ |
#if !defined(OS_ANDROID) |
// Remove the separator if it is the last element. |
DCHECK_GT(suggestions.size(), 0U); |
@@ -181,6 +200,8 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const base::string16& value, |
} else if (identifier == POPUP_ITEM_ID_SCAN_CREDIT_CARD) { |
manager_->client()->ScanCreditCard(base::Bind( |
&AutofillExternalDelegate::OnCreditCardScanned, GetWeakPtr())); |
+ } else if (identifier == POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) { |
+ manager_->client()->StartSigninFlow(); |
} else { |
if (identifier > 0) // Denotes an Autofill suggestion. |
AutofillMetrics::LogAutofillSuggestionAcceptedIndex(position); |