Commit fd364bbd authored by siashah's avatar siashah Committed by Commit Bot

Populate the item tag if offer is present

Currently we're populating the item tag only for the autofill popup.
We'll populate for the autofill keyboard accessory as a follow up after
implementing the UI for the keyboard accessory.

Bug: 1093057
Change-Id: I909569e16ccaced0bc3dde01e0f03d9de3204706
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436862
Commit-Queue: Siddharth Shah <siashah@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812964}
parent 5b6ee3ad
...@@ -170,11 +170,11 @@ public class AutofillPopupBridge implements AutofillDelegate, DialogInterface.On ...@@ -170,11 +170,11 @@ public class AutofillPopupBridge implements AutofillDelegate, DialogInterface.On
*/ */
@CalledByNative @CalledByNative
private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index, private static void addToAutofillSuggestionArray(AutofillSuggestion[] array, int index,
String label, String sublabel, int iconId, boolean isIconAtStart, String label, String sublabel, String itemTag, int iconId, boolean isIconAtStart,
int suggestionId, boolean isDeletable, boolean isLabelMultiline, boolean isLabelBold) { int suggestionId, boolean isDeletable, boolean isLabelMultiline, boolean isLabelBold) {
int drawableId = iconId == 0 ? DropdownItem.NO_ICON : iconId; int drawableId = iconId == 0 ? DropdownItem.NO_ICON : iconId;
array[index] = new AutofillSuggestion(label, sublabel, /*itemTag= */ "", drawableId, array[index] = new AutofillSuggestion(label, sublabel, itemTag, drawableId, isIconAtStart,
isIconAtStart, suggestionId, isDeletable, isLabelMultiline, isLabelBold); suggestionId, isDeletable, isLabelMultiline, isLabelBold);
} }
@NativeMethods @NativeMethods
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/ui/autofill/autofill_popup_controller_utils.h" #include "chrome/browser/ui/autofill/autofill_popup_controller_utils.h"
#include "components/autofill/core/browser/ui/popup_item_ids.h" #include "components/autofill/core/browser/ui/popup_item_ids.h"
#include "components/autofill/core/browser/ui/suggestion.h" #include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/autofill/core/common/autofill_util.h" #include "components/autofill/core/common/autofill_util.h"
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "ui/android/view_android.h" #include "ui/android/view_android.h"
...@@ -94,8 +95,15 @@ void AutofillPopupViewAndroid::OnSuggestionsChanged() { ...@@ -94,8 +95,15 @@ void AutofillPopupViewAndroid::OnSuggestionsChanged() {
POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE || POPUP_ITEM_ID_INSECURE_CONTEXT_PAYMENT_DISABLED_MESSAGE ||
suggestion.frontend_id == POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO || suggestion.frontend_id == POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO ||
suggestion.frontend_id == POPUP_ITEM_ID_MIXED_FORM_MESSAGE; suggestion.frontend_id == POPUP_ITEM_ID_MIXED_FORM_MESSAGE;
// Set the offer title to display as the item tag.
ScopedJavaLocalRef<jstring> item_tag =
base::android::ConvertUTF16ToJavaString(
env, base::FeatureList::IsEnabled(
features::kAutofillEnableOffersInDownstream)
? suggestion.offer_label
: base::string16());
Java_AutofillPopupBridge_addToAutofillSuggestionArray( Java_AutofillPopupBridge_addToAutofillSuggestionArray(
env, data_array, i, value, label, android_icon_id, env, data_array, i, value, label, item_tag, android_icon_id,
/*icon_at_start=*/false, suggestion.frontend_id, is_deletable, /*icon_at_start=*/false, suggestion.frontend_id, is_deletable,
is_label_multiline, /*isLabelBold*/ false); is_label_multiline, /*isLabelBold*/ false);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment